Convoy SDK for Python
This is the Convoy Python SDK. This SDK contains methods for easily interacting with Convoy's API. Below are examples to get you started. For additional examples, please see our official documentation at (https://convoy.readme.io/reference)
Install convoy-python with
pip install convoy-pythonNext, import the convoy module and setup with your auth credentials.
from convoy import Convoy
convoy = Convoy({"api_key":"your_api_key", "project_id": "your_project_id"})The SDK also supports authenticating via Basic Auth by defining your username and password.
In the event you're using a self-hosted convoy instance, uri should contain the hostname:port combination (see example below).
convoy = Convoy({ "api_key": 'your_api_key', "uri": 'http://localhost:5005', "project_id": "your_project_id"})(response, status) = convoy.group.all({ "perPage": 10, "page": 1 })An endpoint represents a target URL to receive events.
endpointData = {
"url": "https://0d87-102-89-2-172.ngrok.io",
"description": "Default Endpoint",
"secret": "endpoint-secret",
"events": ["*"],
}
(response, status) = convoy.endpoint.create({}, endpointData)
endpoint_id = response["data"]["uid"]To send an event, you'll need the uid we created in the earlier section.
eventData = {
"endpoint_id": endpoint_id,
"event_type": "payment.success",
"data": {
"event": "payment.success",
"data": {
"status": "Completed",
"description": "Transaction Successful",
"userID": "test_user_id808",
},
},
}
(response, status) = convoy.event.create({}, eventData)pytest ./test/test.pyPlease see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.