Skip to main content

Python bindings to automate requestrepo.com

Project description

requestrepo Python client

Python bindings to automate requestrepo.com

Installation

pip install requestrepo

Basic Usage

Instantiate the Requestrepo class:

from requestrepo import Requestrepo  # Requestrepo, RequestRepo and requestrepo are accepted imports

client = Requestrepo() # new token printed to console
client = Requestrepo("your-token-here")

or via environment variables:

REQUESTREPO_TOKEN=token python your_script.py

Examples

Example 1: Async request retrieval via on_request

from requestrepo import Requestrepo

def on_request(request_data):
   print("New Request Received:", request_data)

client = Requestrepo(token="your-token-here")

print(client.subdomain) # abcd1234
print(client.domain) # abcd1234.requestrepo.com

client.await_requests()

Example 2: Synchronous request retrieval

from requestrepo import Requestrepo

client = Requestrepo(token="your_api_token")

print(client.subdomain) # abcd1234
print(client.domain) # abcd1234.requestrepo.com

# Get the latest request (blocks until one is received)
new_request = client.get_request()
print("Latest Request:", new_request)

Example 3: Retrieve old requests

You can iterate over all requests that are stored on the server:

from requestrepo import Requestrepo

client = Requestrepo(token="your_api_token")

for request in client.get_old_requests():
    print("Request:", request)

client.delete_all_requests() # clear all requests on the server

Example 4: Update HTTP response

You can update the response of a request by calling update_http method:

from requestrepo import Requestrepo # pip install requestrepo

client = Requestrepo(token="your_api_token")

print(client.subdomain) # abcd1234
print(client.domain) # abcd1234.requestrepo.com

client.update_http(raw=b"hello world")

# Get the latest request (blocks until one is received)
new_request = client.get_request()
print("Latest Request:", new_request)

Contributing

Contributions are welcome! Please submit a pull request or open an issue if you have any ideas or suggestions.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

requestrepo-0.1.2.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

requestrepo-0.1.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file requestrepo-0.1.2.tar.gz.

File metadata

  • Download URL: requestrepo-0.1.2.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.16

File hashes

Hashes for requestrepo-0.1.2.tar.gz
Algorithm Hash digest
SHA256 cfd3b63c39916c8b0eb262d6ef21c6e232a58919615327b9b9e33f52c1f17840
MD5 37fd0ef59082e12a1e9c7df66d7806c4
BLAKE2b-256 1f8a533b08a517bc53b4105f29db5e96fcb0e231038d6bf21194d39b9934938e

See more details on using hashes here.

File details

Details for the file requestrepo-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: requestrepo-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.16

File hashes

Hashes for requestrepo-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e3feebca57dce2f31831604e57b647290263b51248e8942ab8cfa26872ed0220
MD5 7b124bfc86b871e3508e4dd05218341c
BLAKE2b-256 07aaa61e9c2757fdc665b76cc322422f2eb60243c271aaea6206f7f6daf6e817

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page