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.
Metadata
Release files for elliptic-python 0.9.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| elliptic_python-0.9.1.tar.gz | 5.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| elliptic_python-0.9.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.1 kB
Release files / elliptic_python-0.9.1.tar.gz
| Download URL | elliptic_python-0.9.1.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
975e0c9a25cd8f8b3f3a6cc2707f5d7761bc86f6b5f1dc740b0e5ebd57c6d5bd
|
|
BLAKE2b-256 checksum How to use checksums |
a2cffcacc1233b648c676249f65d83891f64ef24153f0c756aaec2f9bf75171a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.11.3 Linux/6.8.0-1031-aws
|
Release files / elliptic_python-0.9.1-py3-none-any.whl
| Download URL | elliptic_python-0.9.1-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ceb16a128c77e1735a26878ad31bb88c0192b4e3016b33fc90d0eb9402f0931b
|
|
BLAKE2b-256 checksum How to use checksums |
69f9b1457e3f7d53d8b14de5752431c2d9820cd75161861658e78c21fac37fc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.11.3 Linux/6.8.0-1031-aws
|