Elliptic SDK for Python - A Requests wrapper for connecting to Elliptic APIs
Project description
Elliptic SDK for Python
Installation
The SDK is available on PyPI:
python -m pip install elliptic-python
This package requires Python 3.7 or greater
Usage
The SDK provides an instance of the popular Requests package, adding the necessary steps to authenticate each request using your Elliptic API key and secret.
from elliptic import AML
aml = AML(key="YOUR_ELLIPTIC_API_KEY", secret="YOUR_ELLIPTIC_API_SECRET")
# aml.client is an instance of a requests session
response = aml.client.get("/v2/analyses")
Webhook Signature Verification
Elliptic signs the webhook events it sends to your endpoint, allowing
you to validate that they were not sent by a third-party. You can use
the WebhookRequestVerifier
class to verify the signature of a webhook
request:
from http.server import HTTPServer, BaseHTTPRequestHandler
from elliptic import WebhookRequestVerifier
verifier = WebhookRequestVerifier(
trusted_public_key="<Trusted public key, available from the Elliptic docs>",
expected_endpoint_id="<Your endpoint id - this will be provided when your webhook integration is set up by Elliptic>",
)
class SimpleHandler(BaseHTTPRequestHandler):
def do_POST(self):
try:
content_length = int(self.headers.get("Content-Length", 0))
post_data = self.rfile.read(content_length)
params = {
"webhook_id_header": self.headers.get("webhook-id"),
"webhook_timestamp_header": self.headers.get(
"webhook-timestamp"
),
"webhook_signature_header": self.headers.get(
"webhook-signature"
),
"req_body": post_data,
}
message_id = verifier.verify(params)
print("Verification successful, message ID:", message_id)
self.send_response(200)
self.end_headers()
self.wfile.write(b"Webhook received")
except Exception as e:
print("Verification failed:", e)
self.send_response(401)
self.end_headers()
def run(port=1337):
server_address = ("", port)
httpd = HTTPServer(server_address, SimpleHandler)
print(f"Starting server on port {port}")
httpd.serve_forever()
if __name__ == "__main__":
run()
API Documentation
Documentation for Elliptic APIs can be found at the Elliptic Developer Center
License
This SDK is distributed under the Apache License, Version 2.0, see LICENSE and NOTICE for more information.
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
Built Distribution
File details
Details for the file elliptic_python-0.9.0.tar.gz
.
File metadata
- Download URL: elliptic_python-0.9.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/5.15.0-1057-aws
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
b53b461e2a6d9e58caf86e817929439b5116e29cf5e2d6f96cb7f3bd115383f6
|
|
MD5 |
6e1fe08f235f17f7be4ba8189d05b415
|
|
BLAKE2b-256 |
185925897c764d6ee4a10ed0fe04315e3962adf3e9a45c8490cf3ef47b0d8e17
|
File details
Details for the file elliptic_python-0.9.0-py3-none-any.whl
.
File metadata
- Download URL: elliptic_python-0.9.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/5.15.0-1057-aws
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
9ace9c93d6ee634e3a91861d728fda0a863a1bd770bc760db5c3ec1c490520b4
|
|
MD5 |
541c4f82e662213b9146b9de566eb4de
|
|
BLAKE2b-256 |
cbd6fb49c124084bd7305b8103609a574b2ac44c89064aa6d1d59d2a963bdab4
|