You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# This workflow will upload a Python Package using Twine when a release is created
2
-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3
-
4
-
# This workflow uses actions that are not certified by GitHub.
5
-
# They are provided by a third-party and are governed by
6
-
# separate terms of service, privacy policy, and support
7
-
# documentation.
1
+
# Upload to PyPI when a GitHub release is published.
This is the official Convoy Python SDK. It contains methods for easily interacting with Convoy's API. Below are examples to get you started. See our [API Reference](https://getconvoy.io/docs/api-reference/welcome) for more.
3
+
Official Convoy Python SDK: an OpenAPI-generated API client plus hand-written webhook signature verification. See the [API Reference](https://getconvoy.io/docs/api-reference/welcome) for endpoint details.
4
+
5
+
Requires **Python 3.11+**.
4
6
5
7
## Installation
6
8
7
-
Install convoy-python with
9
+
`1.0.0a1` is a pre-release. Plain `pip install convoy-python` still resolves to `0.2.0` until a final `1.0.0` is published.
8
10
9
11
```bash
10
-
pip install convoy-python
12
+
pip install --pre convoy-python
13
+
# or pin explicitly:
14
+
pip install convoy-python==1.0.0a1
11
15
```
12
16
17
+
If you are upgrading from `0.2.0`, see [MIGRATION.md](./MIGRATION.md) and the release notes for the breaking changes.
18
+
13
19
## Setup Client
14
20
15
-
Import the `convoy` module and set it up with your instance URL, API key, and project ID. Both the API key and project ID are available from your **Project Settings** page.
21
+
Construct an `AuthenticatedClient`with your instance API root and API key. The project ID is passed per call (it is not embedded in the client).
16
22
17
23
```python
18
-
from convoy importConvoy
24
+
from convoy importAuthenticatedClient
19
25
20
-
convoy=Convoy({
21
-
"api_key": "your_api_key",
22
-
"uri": "https://us.getconvoy.cloud/api/v1",
23
-
"project_id": "your_project_id",
24
-
})
26
+
client=AuthenticatedClient(
27
+
base_url="https://us.getconvoy.cloud/api", # no /v1, no project id
28
+
token="your_api_key",
29
+
)
30
+
project_id ="your_project_id"
25
31
```
26
32
27
-
Your instance URL depends on where your project lives:
33
+
Your base URL depends on where your project lives:
Each method takes a query dict and returns a `(response, status)` tuple.
41
+
Each operation lives under `convoy.api.*`and exposes `sync`, `sync_detailed`, `asyncio`, and `asyncio_detailed`. Request bodies use typed models from `convoy.models`.
36
42
37
43
### Create an Endpoint
38
44
39
-
An endpoint represents a target URL to receive events.
result = create_endpoint_event.sync(project_id, client=client, body=body)
74
+
# async:
75
+
# result = await create_endpoint_event.asyncio(project_id, client=client, body=body)
88
76
```
89
77
90
78
### Verify Webhook Signatures
91
79
92
-
Verify with the raw request body, before parsing it. `verify_signature` returns `True`for a valid signature and `False`otherwise (it fails closed), so a plain boolean check is safe.
80
+
Verify with the raw request body, before parsing it. `verify_signature` returns a strict `True`/ `False`(never a truthy error string).
93
81
94
82
```python
95
83
from convoy.utils.webhook import Webhook
@@ -107,9 +95,15 @@ if not webhook.verify_signature(payload, signature):
107
95
## Testing
108
96
109
97
```bash
110
-
pytest test/test.py
98
+
pytest test/
111
99
```
112
100
101
+
## Generated API client
102
+
103
+
The HTTP API client under `src/convoy/api/` and `src/convoy/models/` is generated from Convoy's OpenAPI spec via [openapi-python-client](https://github.com/openapi-generators/openapi-python-client). **Do not edit generated files by hand**; regenerate with `./scripts/generate.sh` (CI on `frain-dev/convoy` dispatches this when the spec changes).
104
+
105
+
Webhook signature verification remains hand-written (`src/convoy/utils/webhook.py`) and is covered by shared `test/signature-vectors.json`.
106
+
113
107
## Contributing
114
108
115
109
Please see [CONTRIBUTING](CONTRIBUTING.MD) for details.
@@ -121,7 +115,3 @@ Please see [CONTRIBUTING](CONTRIBUTING.MD) for details.
121
115
## License
122
116
123
117
The MIT License (MIT). Please see [License File](LICENSE) for more information.
124
-
125
-
## Generated API client
126
-
127
-
The HTTP API client is generated from Convoy's OpenAPI spec via [openapi-python-client](https://github.com/openapi-generators/openapi-python-client). **Webhook signature verification remains hand-written** (`convoy/utils/webhook.py`) and is covered by shared `test/signature-vectors.json`. See [MIGRATION.md](./MIGRATION.md).
0 commit comments