evva-partner 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- evva_partner-0.1.0/CHANGELOG.md +76 -0
- evva_partner-0.1.0/LICENSE +201 -0
- evva_partner-0.1.0/NOTICE +6 -0
- evva_partner-0.1.0/PKG-INFO +360 -0
- evva_partner-0.1.0/README.md +320 -0
- evva_partner-0.1.0/SECURITY.md +44 -0
- evva_partner-0.1.0/contract-manifest.json +1715 -0
- evva_partner-0.1.0/examples/connect.py +47 -0
- evva_partner-0.1.0/examples/lease_reply_handoff.py +60 -0
- evva_partner-0.1.0/examples/receive_messages.py +58 -0
- evva_partner-0.1.0/examples/replay_from_checkpoint.py +55 -0
- evva_partner-0.1.0/examples/send_media.py +29 -0
- evva_partner-0.1.0/examples/send_ppv.py +34 -0
- evva_partner-0.1.0/examples/send_text.py +36 -0
- evva_partner-0.1.0/examples/webhook_fastapi.py +32 -0
- evva_partner-0.1.0/examples/webhook_persistent_dedup.py +60 -0
- evva_partner-0.1.0/examples/webhook_verify.py +39 -0
- evva_partner-0.1.0/pyproject.toml +132 -0
- evva_partner-0.1.0/scripts/smoke.py +146 -0
- evva_partner-0.1.0/src/evva_partner/__init__.py +166 -0
- evva_partner-0.1.0/src/evva_partner/_common.py +155 -0
- evva_partner-0.1.0/src/evva_partner/_generated/__init__.py +5 -0
- evva_partner-0.1.0/src/evva_partner/_generated/operations.py +14909 -0
- evva_partner-0.1.0/src/evva_partner/_generated/spec.py +4524 -0
- evva_partner-0.1.0/src/evva_partner/_http.py +286 -0
- evva_partner-0.1.0/src/evva_partner/_jwt.py +119 -0
- evva_partner-0.1.0/src/evva_partner/_ops.py +814 -0
- evva_partner-0.1.0/src/evva_partner/_opspec.py +194 -0
- evva_partner-0.1.0/src/evva_partner/_version.py +3 -0
- evva_partner-0.1.0/src/evva_partner/async_client.py +1443 -0
- evva_partner-0.1.0/src/evva_partner/auth.py +452 -0
- evva_partner-0.1.0/src/evva_partner/client.py +1429 -0
- evva_partner-0.1.0/src/evva_partner/contract.py +689 -0
- evva_partner-0.1.0/src/evva_partner/errors.py +368 -0
- evva_partner-0.1.0/src/evva_partner/events/__init__.py +33 -0
- evva_partner-0.1.0/src/evva_partner/events/feed.py +361 -0
- evva_partner-0.1.0/src/evva_partner/events/model.py +89 -0
- evva_partner-0.1.0/src/evva_partner/events/stores.py +206 -0
- evva_partner-0.1.0/src/evva_partner/events/stream.py +172 -0
- evva_partner-0.1.0/src/evva_partner/leases.py +206 -0
- evva_partner-0.1.0/src/evva_partner/models.py +169 -0
- evva_partner-0.1.0/src/evva_partner/pagination.py +180 -0
- evva_partner-0.1.0/src/evva_partner/polling.py +225 -0
- evva_partner-0.1.0/src/evva_partner/py.typed +0 -0
- evva_partner-0.1.0/src/evva_partner/realtime/__init__.py +17 -0
- evva_partner-0.1.0/src/evva_partner/realtime/client.py +785 -0
- evva_partner-0.1.0/src/evva_partner/realtime/protocol.py +145 -0
- evva_partner-0.1.0/src/evva_partner/redaction.py +97 -0
- evva_partner-0.1.0/src/evva_partner/retry.py +109 -0
- evva_partner-0.1.0/src/evva_partner/schemas.py +3825 -0
- evva_partner-0.1.0/src/evva_partner/uploads.py +248 -0
- evva_partner-0.1.0/src/evva_partner/webhooks.py +397 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the EVVA Partner SDK for Python (`evva-partner`) are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
|
|
6
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-12-04
|
|
11
|
+
|
|
12
|
+
The first public version. It targets version 1.4.0 of the Partner API (`API-Version: v1`).
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Synchronous (`EvvaPartnerClient`) and asyncio (`AsyncEvvaPartnerClient`) clients for the EVVA Partner API.
|
|
17
|
+
- OAuth 2.0 `client_credentials` authentication with `client_secret_basic`, `client_secret_post` and `private_key_jwt`
|
|
18
|
+
(RS256, ES256); cached tokens renewed before expiry, one renewal at a time, one re-authentication on `401`, token
|
|
19
|
+
revocation.
|
|
20
|
+
- `client.operations` / `aclient.operations`: one typed method for every operation the Partner API opens to
|
|
21
|
+
integration applications, and the API's schemas as typed dictionaries (`evva_partner.schemas`). Every operation
|
|
22
|
+
takes per-call extra headers (`headers={"X-Creator-Id": creator_id}`); the headers the SDK sends itself
|
|
23
|
+
(`Authorization`, `Idempotency-Key`, `Partner-Approval-Id`, `X-Request-Id`, `User-Agent`, `Accept`,
|
|
24
|
+
`Content-Type`, …) cannot be set that way (`ValueError`). Path parameters are typed as the API types them
|
|
25
|
+
(`get_ai_workflow_revision(..., revision: int)`).
|
|
26
|
+
- An `iter_*` method for every paged list — the 19 cursor-paged lists (`cursor`, `before` or `after`, following
|
|
27
|
+
`nextCursor` or `newer`) and the 6 offset-paged ones (`skip` + `take`: `OffsetPaginator` /
|
|
28
|
+
`AsyncOffsetPaginator`), generated from the API description.
|
|
29
|
+
- Helpers for the common flows: accounts, conversations, messages (text, media, edits, retracts, status),
|
|
30
|
+
pay-per-view messages and quotes, subscribers and fan lists, media (streamed and multipart uploads, fetch grants and
|
|
31
|
+
downloads), content, profile, mass messages, automations, bulk sends and the event feed's consumer groups.
|
|
32
|
+
- Typed errors for every API error class, including `ApprovalRequiredError` for operations that need action approval
|
|
33
|
+
(re-send with `approval_id` under the same key — `ApprovalRequiredError.idempotency_key` is the key the call was
|
|
34
|
+
sent with), `RateLimitedError.level` and the conversation-coordination refusals. Which operations
|
|
35
|
+
(or which of their fields) need approval is part of the operation table.
|
|
36
|
+
- Events are identified by `event_id`, the deduplication key on every transport; the event feed delivers in one
|
|
37
|
+
deterministic order, webhooks in none.
|
|
38
|
+
- Message authorship declarations: `AI_AUTOMATED`, or `HUMAN_AUTHORED` / `AI_DRAFTED_HUMAN_SENT` with an operator
|
|
39
|
+
reference.
|
|
40
|
+
- Message status in the API's words (`receipt`, `paid.purchased`) with `message_status_of`, and the buyer pseudonym on
|
|
41
|
+
events (`Event.buyer_ref`).
|
|
42
|
+
- Conversation leases (`client.leases.hold`) with automatic renewal. Under a lease this client holds, the lease's
|
|
43
|
+
current fencing token is attached to every write into the conversation — send, paid send, AI fan-reply send, bulk
|
|
44
|
+
items, edit, retract, reaction, pin and unpin, through the helpers and `client.operations` alike — and a lost
|
|
45
|
+
lease refuses the write locally (`LeaseLostError`) instead of sending it without the token. A write under the
|
|
46
|
+
lease's token answered `409 STALE_FENCING_TOKEN` or `LEASE_HELD` (a bulk item too) marks the hold lost: later
|
|
47
|
+
writes are refused locally and no release is sent for it. Fencing tokens are compared for equality only.
|
|
48
|
+
- The durable event feed consumer (`FeedConsumer`, `AsyncFeedConsumer`) with pluggable checkpoint and deduplication
|
|
49
|
+
stores (`SQLiteStore` for durable state), at-least-once delivery and graceful shutdown.
|
|
50
|
+
- The realtime client (`RealtimeClient`) with acknowledgement after the handler, heartbeat, reconnect with full-jitter
|
|
51
|
+
backoff, resume by the feed cursor and retry of refused upgrades with `Retry-After`; `PartnerEventStream` combines
|
|
52
|
+
realtime and the feed.
|
|
53
|
+
- Webhook verification (Standard Webhooks) and receivers (`WebhookHandler`, `AsyncWebhookHandler`) with
|
|
54
|
+
deduplication by event id; an example whose deduplication survives a restart.
|
|
55
|
+
- Typed polling for statuses without an event (`client.waits`): media processing, AI images, AI workflow and
|
|
56
|
+
automation runs, scheduled posts.
|
|
57
|
+
- Support for Python 3.11, 3.12, 3.13 and 3.14.
|
|
58
|
+
|
|
59
|
+
### Changed before the first release
|
|
60
|
+
|
|
61
|
+
These changed while no version had been published, so no deprecation period applies.
|
|
62
|
+
|
|
63
|
+
- `client.messages.iter_after(creator_id, conversation_id, cursor=...)` reads forward with `listMessagesAfter`
|
|
64
|
+
(`GET …/messages/after?cursor=`, following `newer`); it took `after=` and sent an `after` query parameter to
|
|
65
|
+
`listMessages`, which has none. `client.messages.list(...)` no longer takes `after=`.
|
|
66
|
+
- `client.request(...)` refuses the SDK's own headers in `headers=` (`ValueError`) instead of letting them override
|
|
67
|
+
the transport's (`idempotency_key=`, `approval_id=` and `request_id=` set those).
|
|
68
|
+
- `get_ai_workflow_revision`'s `revision` is an `int` (it was typed `str`).
|
|
69
|
+
- The hand-written helpers send only the query parameters the API description declares:
|
|
70
|
+
`client.conversations.list|iter(creator_id, cursor=, take=)` (the `limit=` and `updated_since=` options sent
|
|
71
|
+
parameters the API does not serve); `client.subscribers.list|iter(creator_id, skip=, take=)` and
|
|
72
|
+
`client.media.list_assets|iter_assets(creator_id, skip=, take=, library=, kind=)` page by `skip` / `take` — their
|
|
73
|
+
`cursor=` / `limit=` options are gone and their iterators are `OffsetPaginator` / `AsyncOffsetPaginator`.
|
|
74
|
+
|
|
75
|
+
[Unreleased]: https://github.com/evvahub/partner-sdk-python/compare/v0.1.0...HEAD
|
|
76
|
+
[0.1.0]: https://github.com/evvahub/partner-sdk-python/releases/tag/v0.1.0
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: evva-partner
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The official server-side Python SDK for the EVVA Partner API (REST, durable event feed, realtime, webhooks).
|
|
5
|
+
Project-URL: Homepage, https://developers.evvahub.com/sdks/python
|
|
6
|
+
Project-URL: Documentation, https://developers.evvahub.com/sdks/python
|
|
7
|
+
Project-URL: Repository, https://github.com/evvahub/partner-sdk-python
|
|
8
|
+
Project-URL: Issues, https://github.com/evvahub/partner-sdk-python/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/evvahub/partner-sdk-python/blob/main/CHANGELOG.md
|
|
10
|
+
Author: EVVA
|
|
11
|
+
License-Expression: Apache-2.0
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
License-File: NOTICE
|
|
14
|
+
Keywords: evva,oauth2,partner,realtime,sdk,webhooks
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Requires-Dist: httpx<1,>=0.27
|
|
24
|
+
Requires-Dist: websockets<18,>=13
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: cryptography>=42; extra == 'dev'
|
|
27
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
30
|
+
Requires-Dist: pyyaml>=6; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
32
|
+
Provides-Extra: jwt
|
|
33
|
+
Requires-Dist: cryptography>=42; extra == 'jwt'
|
|
34
|
+
Provides-Extra: test
|
|
35
|
+
Requires-Dist: cryptography>=42; extra == 'test'
|
|
36
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == 'test'
|
|
37
|
+
Requires-Dist: pytest>=8; extra == 'test'
|
|
38
|
+
Requires-Dist: pyyaml>=6; extra == 'test'
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
|
|
41
|
+
# EVVA Partner SDK for Python
|
|
42
|
+
|
|
43
|
+
The official server-side Python SDK for the **EVVA Partner API**: an agency's backend, CRM or AI pipeline reads its
|
|
44
|
+
creators' conversations, answers them (text, media, pay-per-view), coordinates with the people in the agency, and
|
|
45
|
+
receives events over the durable event feed, realtime and webhooks.
|
|
46
|
+
|
|
47
|
+
**Documentation: https://developers.evvahub.com/sdks/python** · API reference:
|
|
48
|
+
https://developers.evvahub.com/api-reference
|
|
49
|
+
|
|
50
|
+
- Every operation the Partner API opens to integration applications, as a typed method
|
|
51
|
+
(`client.operations.<snake_case(operationId)>`), and every event type of the event catalogue.
|
|
52
|
+
- Synchronous **and** asyncio clients (`httpx`), realtime over `websockets`, fully typed (`py.typed`).
|
|
53
|
+
- Handles token acquisition and renewal, retries of safe operations only, `Retry-After`, idempotency keys,
|
|
54
|
+
pagination, streamed and multipart media uploads, realtime reconnect and resume, the durable feed's cursor, event
|
|
55
|
+
deduplication and graceful shutdown.
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
pip install evva-partner # client secret
|
|
61
|
+
pip install "evva-partner[jwt]" # private_key_jwt
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Requirements: Python 3.11 or later (3.14 recommended — see [Supported Python versions](#supported-python-versions)).
|
|
65
|
+
Runtime dependencies: `httpx`, `websockets`; `cryptography` for `private_key_jwt` client authentication (the `jwt`
|
|
66
|
+
extra).
|
|
67
|
+
|
|
68
|
+
## Quickstart
|
|
69
|
+
|
|
70
|
+
You need an application's `client_id` and `client_secret` (or a registered public key) from the *Integrations* page
|
|
71
|
+
of the Partner Hub, and at least one creator who granted your application access. Keep them in environment variables
|
|
72
|
+
or a secret manager — never in code or committed files.
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
import os
|
|
76
|
+
|
|
77
|
+
from evva_partner import ClientSecretBasic, EvvaPartnerClient
|
|
78
|
+
|
|
79
|
+
with EvvaPartnerClient(
|
|
80
|
+
base_url=os.environ["EVVA_BASE_URL"], # https://api.<your EVVA domain>
|
|
81
|
+
auth=ClientSecretBasic(os.environ["EVVA_CLIENT_ID"], os.environ["EVVA_CLIENT_SECRET"]),
|
|
82
|
+
) as client:
|
|
83
|
+
print(client.app.me())
|
|
84
|
+
for account in client.accounts.list():
|
|
85
|
+
creator_id = account["creatorId"]
|
|
86
|
+
for conversation in client.conversations.iter(creator_id, take=50):
|
|
87
|
+
print(creator_id, conversation["id"], conversation.get("lastMessageAt"))
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Receive events and reply (more in [`examples/`](examples/)):
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
import asyncio
|
|
94
|
+
import os
|
|
95
|
+
|
|
96
|
+
from evva_partner import AsyncEvvaPartnerClient, ClientSecretBasic, PartnerEventStream, SQLiteStore
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
async def main() -> None:
|
|
100
|
+
store = SQLiteStore("evva-state.db") # durable checkpoint + deduplication
|
|
101
|
+
auth = ClientSecretBasic(os.environ["EVVA_CLIENT_ID"], os.environ["EVVA_CLIENT_SECRET"])
|
|
102
|
+
async with AsyncEvvaPartnerClient(base_url=os.environ["EVVA_BASE_URL"], auth=auth) as client:
|
|
103
|
+
|
|
104
|
+
async def on_event(event):
|
|
105
|
+
if event.type == "message.received":
|
|
106
|
+
await client.messages.send_text(
|
|
107
|
+
event.creator_id, event.conversation_id, "Got it!", idempotency_key=f"reply-{event.event_id}"
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
stream = PartnerEventStream(client, consumer_id="replier", handler=on_event, checkpoints=store, dedup=store)
|
|
111
|
+
await stream.run()
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
asyncio.run(main())
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## What the SDK does for you
|
|
118
|
+
|
|
119
|
+
| Concern | Behaviour |
|
|
120
|
+
|---|---|
|
|
121
|
+
| Authentication | OAuth 2.0 `client_credentials` with `ClientSecretBasic` (default), `ClientSecretPost` or `PrivateKeyJwt` (RS256/ES256; `iss = sub = client_id`, `aud` = the token URL, `exp` ≤ 5 min, random `jti`, `kid`). A fresh assertion per attempt. |
|
|
122
|
+
| Tokens | Cached; renewed *before* expiry (`refresh_margin`, default 60 s); one renewal at a time across threads and tasks; a `401` drops the token and the request is sent once more with a new one. Tokens are opaque — never parsed. `client.tokens.revoke()` at shutdown. |
|
|
123
|
+
| Retries | Only `GET`/`HEAD`/`OPTIONS` and mutations that carry an `Idempotency-Key`; on network errors, `408`, `429`, `500`, `502`, `503`, `504` and `409 IDEMPOTENCY_IN_PROGRESS`. `Retry-After` is a floor plus a small random jitter (a value above `max_retry_after`, default 60 s, raises instead of waiting); otherwise exponential backoff with full jitter. `RetryPolicy(max_attempts=…)`. |
|
|
124
|
+
| Idempotency | An operation whose API contract declares `Idempotency-Key` (sends, paid messages, bulk sends, mass messages, content, marketplace money actions, …) gets a UUID v4 key, reused by its retries; pass `idempotency_key=` when *your* operation can be re-issued after a crash (for example `f"reply-{event.event_id}"`) so the server recognises the repeat. A mutation without one (lease acquire/renew/release, handoff, mark-read, uploads, …) is attempted once and never retried. |
|
|
125
|
+
| Approvals | A sensitive operation (deletes, prices and financial commitments, blocks, reports, view-once, fulfilment, paid AI jobs) may answer `202 APPROVAL_REQUIRED`: nothing was done. The SDK raises `ApprovalRequiredError` (`approval_id`, `approval_status`, `reason`, `expires_at`) and never retries it. Once a person in the agency approved it (your application sees `approval.decided` on the event feed), send the SAME call again with `approval_id=` (header `Partner-Approval-Id`) and the same `idempotency_key`: the approval covers exactly that request and is used once. Some operations are gated as a whole, others only when a call sets certain fields (a price, view-once, an expiry); `contract.OPERATION_SPECS_BY_ID[op].approval` / `.approval_fields` say which. A refused re-send is an `ApiError` with `APPROVAL_MISMATCH`, `APPROVAL_DECLINED`, `APPROVAL_INVALID` (403) or `APPROVAL_PENDING`, `APPROVAL_EXPIRED`, `APPROVAL_CONSUMED` (409). |
|
|
126
|
+
| Rate limits | `RateLimitedError` (`429`) with `retry_after` and `level` — whose limit refused: `conversation`, `sender`, `creator`, `application`, `agency` or `platform`. Limits are temporary: the SDK waits and retries safe and keyed calls by itself; if you keep hitting them, slow your own loop down. |
|
|
127
|
+
| Errors | `AuthError` 401, `PermissionDeniedError` 403, `NotFoundError` 404, `ConflictError` 409 (`IdempotencyConflictError`, `LeaseHeldError`, `StaleFencingTokenError`, `ConversationAdvancedError`, `AutomationPausedError`), `CursorExpiredError` / `WebhooksMovedError` 410, `RateLimitedError` 429, `ServerError` 5xx, `BadRequestError`, `NetworkError`, `UploadError`, `LeaseLostError`, `RealtimeError`, `WebhookVerificationError`. API errors carry `status`, `code`, `message`, `details`, `request_id`. |
|
|
128
|
+
| Observability | `User-Agent: evva-partner-sdk-python/<version>`; one `X-Request-Id` (UUID) per logical call, reused by its retries, surfaced on errors. Logger `evva_partner`; nothing logged contains a secret, token, signature or presigned URL query. |
|
|
129
|
+
| Pagination | `list(...)` returns one `Page`; `iter(...)` walks every page; every paged operation also has `client.operations.iter_<name>` — cursor-paged (`cursor` / `before` / `after`, following `nextCursor` / `newer`) and offset-paged (`skip` + `take`) alike. |
|
|
130
|
+
| Media | `client.media.upload(creator_id, source, mime_type=…)`: create → PUT the bytes straight to storage (never through the API, never with your token) → finalize. `resumable=True` lets a large file use a multipart session. |
|
|
131
|
+
| Events | `FeedConsumer` / `AsyncFeedConsumer` (durable, at-least-once), `RealtimeClient` (low latency), `PartnerEventStream` (both, deduplicated), `WebhookHandler` / `AsyncWebhookHandler`. |
|
|
132
|
+
|
|
133
|
+
## Every operation: `client.operations`
|
|
134
|
+
|
|
135
|
+
Every operation the Partner API opens to applications is one typed method named `snake_case(operationId)` — path
|
|
136
|
+
parameters positional, the JSON body as `body` (a `TypedDict` from `evva_partner.schemas`), query parameters
|
|
137
|
+
keyword-only:
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
asset = client.operations.get_media_asset(creator_id, media_asset_id) # schemas.MediaAssetDetail
|
|
141
|
+
orders = client.operations.list_creator_orders(creator_id, take=50) # schemas.SellerOrderPage
|
|
142
|
+
status = client.operations.get_message_status(creator_id, conversation_id, message_id)
|
|
143
|
+
for tag in client.operations.iter_list_media_tags(creator_id, q="beach"): # every page
|
|
144
|
+
print(tag["tagId"], tag["displayName"])
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Each call uses the same transport as the helpers below: the cached token, `X-Request-Id`, the `Idempotency-Key`
|
|
148
|
+
rule above, retries of safe and keyed calls only and typed errors. `request_id=`, `timeout=` and `headers=` (extra
|
|
149
|
+
request headers for that call, e.g. `headers={"X-Creator-Id": creator_id}`) are accepted everywhere — the headers
|
|
150
|
+
the SDK sets itself (`Authorization`, `Idempotency-Key`, `Partner-Approval-Id`, `X-Request-Id`, `User-Agent`,
|
|
151
|
+
`Accept`, `Content-Type`, …) are refused there; operations that need action approval take `approval_id=`.
|
|
152
|
+
`aclient.operations` is the same surface, awaited.
|
|
153
|
+
|
|
154
|
+
## Helpers for the common flows
|
|
155
|
+
|
|
156
|
+
`client.app.me()` / `.capabilities()` · `client.accounts.list()` ·
|
|
157
|
+
`client.conversations.list|iter(creator_id, cursor=, take=)`, `.context(...)`, `.mark_read(...)` ·
|
|
158
|
+
`client.messages.list|iter_history(...)`, `.iter_after(..., cursor=)`, `.send_text(...)`, `.send_media(...)`, `.edit(...)`,
|
|
159
|
+
`.retract(...)`, `.status(...)` · `client.paid_messages.send(..., price_minor=500, media=[...])`, `.quote(...)` ·
|
|
160
|
+
`client.subscribers.list|iter(creator_id, skip=, take=)`, `client.fan_lists.list|get` ·
|
|
161
|
+
`client.media.list_assets|iter_assets(creator_id, skip=, take=, library=, kind=)`, `.upload(...)`, `.fetch_grant(..., role=)`, `.download(..., role=)` ·
|
|
162
|
+
`client.content.list|create|update|attach_media` · `client.profile.get|update` ·
|
|
163
|
+
`client.mass_messages.list|create|queue|cancel` ·
|
|
164
|
+
`client.automations.list|get|put|delete|history|get_ice_breaker|put_ice_breaker` ·
|
|
165
|
+
`client.leases.hold|get|acquire|renew|release|handoff|observe|token_for` ·
|
|
166
|
+
`client.events.list|get_checkpoint|save_checkpoint` · `client.bulk.send_messages([...])` (≤ 100) ·
|
|
167
|
+
`client.waits.*` (below) · `client.request(method, path, ...)` for anything else.
|
|
168
|
+
|
|
169
|
+
A helper sends only the query parameters the API description declares for its operation: offset-paged lists
|
|
170
|
+
(subscribers, media assets, content, mass messages) take `skip` / `take` and their iterators advance `skip`;
|
|
171
|
+
cursor-paged ones take `cursor` (`before` for message history). Every other filter is on `client.operations`.
|
|
172
|
+
|
|
173
|
+
**Authorship.** An application declares how each message was written: `AI_AUTOMATED` (the default; scope
|
|
174
|
+
`write:messages:automated`) or, for a person writing through your CRM, `HUMAN_AUTHORED` / `AI_DRAFTED_HUMAN_SENT` with
|
|
175
|
+
`operator_ref=` — that person's opaque id, 1–64 printable characters (scope `write:messages:operator`). A malformed
|
|
176
|
+
declaration is refused before sending; a declaration the creator's consent does not cover is answered
|
|
177
|
+
`403 AUTHORSHIP_NOT_PERMITTED`. Either way the buyer sees an ordinary message from the creator.
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
client.messages.send_text(creator_id, conversation_id, "On it!", authorship="HUMAN_AUTHORED", operator_ref="crm-op-17")
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Message status.** A message's status uses the API's own words: `receipt` — `sent`, `delivered`, `read` — and
|
|
184
|
+
`paid.purchased` for a sold pay-per-view message. `message_status_of(message)` folds them into one word; the events
|
|
185
|
+
`message.sent`, `message.delivered`, `message.read` and `ppv.purchased` carry the same words (`event.message_status`).
|
|
186
|
+
A buyer is named only by your application's own pseudonym (`buyerRef` / `senderBuyerRef`, `event.buyer_ref`): stable,
|
|
187
|
+
the same on every transport, never a global id.
|
|
188
|
+
|
|
189
|
+
**Conversation leases.** `with client.leases.hold(creator_id, conversation_id) as held:` (`async with` on the async
|
|
190
|
+
client) holds ONE conversation while your automation answers it — 60 s by default (15–300 s), renewed in the
|
|
191
|
+
background, released on exit.
|
|
192
|
+
|
|
193
|
+
**The fencing token is mandatory under a lease.** While a lease on a conversation is live, every write into it — a
|
|
194
|
+
send, a paid send, an AI fan-reply send, each bulk item, an edit, a retract, a reaction, a pin or an unpin — must
|
|
195
|
+
carry that lease's *current* fencing token, your own application's other instances included. The client attaches
|
|
196
|
+
it for you, through the helpers and `client.operations` alike (`evva_partner.contract.LEASE_FENCED_OPERATIONS`;
|
|
197
|
+
`leases.token_for` reads it; `client.request` sends exactly what you give it), and once the lease is lost it raises
|
|
198
|
+
`LeaseLostError` instead of sending without it — for a bulk send, before any item goes out. The platform's answers:
|
|
199
|
+
|
|
200
|
+
| Refusal | When | Error |
|
|
201
|
+
|---|---|---|
|
|
202
|
+
| `409 LEASE_HELD` | Another holder (staff included) leases the conversation, or a write came without the live lease's token; `retry_after` is the lease's time left, when given | `LeaseHeldError` |
|
|
203
|
+
| `409 STALE_FENCING_TOKEN` | The token is not the live lease's current one | `StaleFencingTokenError` |
|
|
204
|
+
| `409 AUTOMATION_PAUSED` | A staff member replied (pause window, `retry_after`), or a person has taken up a handoff (no `retry_after`, until staff hands it back) | `AutomationPausedError` |
|
|
205
|
+
| `400 INVALID_REQUEST` | A malformed token | `BadRequestError` |
|
|
206
|
+
|
|
207
|
+
A `409 LEASE_HELD` or `STALE_FENCING_TOKEN` answered to a write under the hold's token — a bulk item's result
|
|
208
|
+
included — means the lease is gone: the SDK marks the hold lost (`held.lost`, `held.lost_error`), refuses every later
|
|
209
|
+
write under it locally (`LeaseLostError`) and sends no release for it. Tokens are opaque: compared for equality only,
|
|
210
|
+
never by size.
|
|
211
|
+
|
|
212
|
+
A person always wins: their takeover or reply ends your lease (`lease.lost` — route events through
|
|
213
|
+
`client.leases.observe(event)`). While staff holds the conversation your edits, retracts, reactions and pins are
|
|
214
|
+
refused too. In a bulk
|
|
215
|
+
send a refused item is that item's result (`error.code`), not an exception; a broadcast skips a recipient whose
|
|
216
|
+
conversation staff holds (skip reason `CONVERSATION_HELD`). These refusals are never retried in a loop.
|
|
217
|
+
`handoff(..., reason="buyer_requested_human")` passes the conversation to a person.
|
|
218
|
+
|
|
219
|
+
## Events
|
|
220
|
+
|
|
221
|
+
### Durable feed
|
|
222
|
+
|
|
223
|
+
```python
|
|
224
|
+
from evva_partner import FeedConsumer, SQLiteStore, stop_on_signals
|
|
225
|
+
|
|
226
|
+
store = SQLiteStore("/var/lib/my-app/evva.db")
|
|
227
|
+
consumer = FeedConsumer(client, consumer_id="crm-sync", handler=handle, checkpoints=store, dedup=store,
|
|
228
|
+
on_cursor_expired=resync_from_rest)
|
|
229
|
+
stop_on_signals(consumer) # SIGINT/SIGTERM -> finish the event in progress, save, return
|
|
230
|
+
consumer.run()
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Delivery guarantees and graceful shutdown
|
|
234
|
+
|
|
235
|
+
- **At-least-once.** An event can arrive more than once: after a crash or a restart, after a timeout, or once over
|
|
236
|
+
realtime and again from the feed or a webhook. Deduplicate on `event.event_id` — the dedup store does it for you.
|
|
237
|
+
- **The dedup mark and the checkpoint are written after your handler returns**, never before. If your process dies
|
|
238
|
+
while handling an event, the event is delivered again; if your handler raises, nothing is recorded and the event
|
|
239
|
+
is redelivered (the feed consumer stops with the error; a webhook is answered `500` so it is retried).
|
|
240
|
+
- **Graceful shutdown.** Call `consumer.stop()` / `stream.stop()` (or `stop_on_signals`) and wait for `run()` to
|
|
241
|
+
return: the event in progress finishes, its dedup mark and checkpoint are saved, then the consumer stops. Close
|
|
242
|
+
clients (`with` / `async with`) and optionally `client.tokens.revoke()`.
|
|
243
|
+
- **Order.** The event feed delivers in one deterministic order — the same on every read, replay and consumer-group
|
|
244
|
+
takeover. Webhooks promise no order (a retry or replay can arrive after a later event): deduplicate by `event_id`
|
|
245
|
+
and read the feed where strict order matters. `occurred_at` is informational; never order events by it alone.
|
|
246
|
+
- `410 CURSOR_EXPIRED` (offline longer than the
|
|
247
|
+
feed's retention, 7 days) calls `on_cursor_expired(error, cursor)`: re-read what you depend on, then return the
|
|
248
|
+
cursor to continue from.
|
|
249
|
+
|
|
250
|
+
### Realtime
|
|
251
|
+
|
|
252
|
+
`RealtimeClient` speaks the platform's realtime protocol on `wss://api.<domain>/realtime` (the token travels in the
|
|
253
|
+
first frame, never in the URL). It acknowledges each event only after your handler returned, pings every 25 s,
|
|
254
|
+
reconnects with full-jitter backoff and resumes where it stopped: it presents the feed `cursor` of the last event it
|
|
255
|
+
handled, so a reconnect needs no catch-up; only `RESUME_REJECTED` hands over to the durable feed. A refused WebSocket
|
|
256
|
+
upgrade (for example `503` with `Retry-After` when realtime capacity is full) is retried after at least its
|
|
257
|
+
`Retry-After` — indefinitely by default, never treated as an authentication failure. After a `4401` close the client
|
|
258
|
+
reconnects once with a fresh token; if that fails too — for example because the application was revoked — it stops.
|
|
259
|
+
However it ends, `client.state` is `"stopped"` when `run()` returns or raises. `PartnerEventStream` combines realtime
|
|
260
|
+
and the feed: one handler, one dedup set, the feed polled every 60 s while realtime is healthy and at once whenever
|
|
261
|
+
realtime reports a possible gap; only the feed moves the checkpoint.
|
|
262
|
+
|
|
263
|
+
### Storage for checkpoints and deduplication
|
|
264
|
+
|
|
265
|
+
Implement two small interfaces over your own database to share state across instances:
|
|
266
|
+
|
|
267
|
+
```python
|
|
268
|
+
class CheckpointStore(Protocol):
|
|
269
|
+
def load(self, consumer_id: str) -> str | None: ...
|
|
270
|
+
def save(self, consumer_id: str, cursor: str) -> None: ...
|
|
271
|
+
|
|
272
|
+
class DedupStore(Protocol):
|
|
273
|
+
def seen(self, event_id: str) -> bool: ...
|
|
274
|
+
def remember(self, event_id: str, ttl_seconds: float) -> None: ...
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
`async def` versions are accepted by the async consumer and the stream. Shipped: `InMemoryCheckpointStore` /
|
|
278
|
+
`InMemoryDedupStore` — **not durable**, for tests and demos — and `SQLiteStore` (durable on one host).
|
|
279
|
+
|
|
280
|
+
## Polling — only for statuses without an event
|
|
281
|
+
|
|
282
|
+
Prefer the feed, realtime and webhooks. A few statuses have no event; poll them with backoff:
|
|
283
|
+
|
|
284
|
+
```python
|
|
285
|
+
client.waits.media_processing(creator_id, [asset_id]) # until ready / failed / unavailable
|
|
286
|
+
client.waits.ai_studio_image(creator_id, generation_ref) # until SUCCEEDED / FAILED / CANCELLED / REFUSED
|
|
287
|
+
client.waits.ai_workflow_run(creator_id, run_ref)
|
|
288
|
+
client.waits.ai_automation_run(creator_id, run_ref)
|
|
289
|
+
client.waits.scheduled_content(creator_id, content_id) # until the post left its scheduled draft
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Full-jitter exponential backoff (1 s doubling up to 30 s, never below 0.5 s), at most `max_wait` seconds in all
|
|
293
|
+
(`PollTimeoutError` carries the last answer); a `429`/`503` waits at least its `Retry-After`. `wait_for` /
|
|
294
|
+
`async_wait_for` poll any read you pass. Financial events reach only applications whose creator consent includes
|
|
295
|
+
`read:revenue`.
|
|
296
|
+
|
|
297
|
+
## Webhooks
|
|
298
|
+
|
|
299
|
+
```python
|
|
300
|
+
from evva_partner import WebhookHandler # AsyncWebhookHandler for asyncio frameworks
|
|
301
|
+
|
|
302
|
+
webhooks = WebhookHandler(
|
|
303
|
+
[os.environ["EVVA_WEBHOOK_SECRET"]], # add the previous secret during a rotation
|
|
304
|
+
on_event=enqueue, # keep it short; the answer waits for it
|
|
305
|
+
dedup=store, # the SAME durable DedupStore your feed consumer uses (e.g. SQLiteStore)
|
|
306
|
+
)
|
|
307
|
+
result = webhooks.handle(raw_body_bytes, request.headers)
|
|
308
|
+
return result.status # 204 handled/duplicate · 401 signature · 400 payload · 500 retry me
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
- **Signatures.** Standard Webhooks over the **raw** body, secret `whsec_<base64>`, 5-minute timestamp tolerance.
|
|
312
|
+
During a secret rotation EVVA signs with both secrets: configure both until the old one is retired.
|
|
313
|
+
- **`event_id` is the dedup key.** `webhook-id` equals the event's `eventId` — stable across retries and replays and
|
|
314
|
+
equal to the id the feed and realtime carry. The handler records the event after `on_event` returned, answers a
|
|
315
|
+
repeat `204`, and runs two simultaneous deliveries of one event one after the other.
|
|
316
|
+
- **At-least-once, with retries.** A delivery not answered 2xx is retried with exponential backoff (up to 12 attempts
|
|
317
|
+
within 24 hours), then kept for replay. So a raising `on_event` answers `500`, a duplicate `204`.
|
|
318
|
+
- **Survives a restart.** [`examples/webhook_persistent_dedup.py`](examples/webhook_persistent_dedup.py) uses
|
|
319
|
+
`SQLiteStore`: the dedup record is committed before the answer, so an event handled before a crash or a deploy is
|
|
320
|
+
answered `204 duplicate` afterwards and `on_event` does not run twice.
|
|
321
|
+
- **One endpoint, every creator.** An endpoint receives the events of all creators your application may see; route on
|
|
322
|
+
`event.creator_id`. Webhook endpoints are managed by agency staff in the Partner Hub.
|
|
323
|
+
|
|
324
|
+
## Production notes
|
|
325
|
+
|
|
326
|
+
- **Secrets.** Load client secrets, private keys and webhook secrets from a secret manager or the environment; never
|
|
327
|
+
commit or log them. Prefer `PrivateKeyJwt`: the private key never leaves your host.
|
|
328
|
+
- **Clock.** Assertions and webhooks are time-checked (±5 minutes): keep hosts NTP-synchronised.
|
|
329
|
+
- **Durable state.** Use a durable `CheckpointStore`/`DedupStore` (SQLite on one host, or your database).
|
|
330
|
+
- **Several instances.** Do not run two consumers with the same `consumer_id` on one checkpoint without coordination;
|
|
331
|
+
use the server's consumer groups (`client.events.get_checkpoint` / `save_checkpoint`) or shard by creator.
|
|
332
|
+
- **Idempotency.** Derive `idempotency_key` from the inbound event id so a redelivered event cannot produce a second
|
|
333
|
+
reply.
|
|
334
|
+
|
|
335
|
+
## Supported Python versions
|
|
336
|
+
|
|
337
|
+
Python 3.11 or later; **3.14 is recommended**. A version is listed only after the full test suite, strict typing and
|
|
338
|
+
a dependency vulnerability audit passed on the newest patch release of that version:
|
|
339
|
+
|
|
340
|
+
| Python | Status | Tested on |
|
|
341
|
+
|---|---|---|
|
|
342
|
+
| 3.11 | supported | 3.11.18 |
|
|
343
|
+
| 3.12 | supported | 3.12.16 |
|
|
344
|
+
| 3.13 | supported | 3.13.18 |
|
|
345
|
+
| **3.14** | supported, recommended | 3.14.10 |
|
|
346
|
+
|
|
347
|
+
A Python version that is out of support upstream is not supported by the SDK.
|
|
348
|
+
|
|
349
|
+
## Versioning
|
|
350
|
+
|
|
351
|
+
The SDK follows [Semantic Versioning](https://semver.org/). During initial development (`0.y.z`) a breaking change
|
|
352
|
+
bumps the minor version: pin `~=0.y.0`. Changes are listed in [CHANGELOG.md](CHANGELOG.md).
|
|
353
|
+
|
|
354
|
+
## Security
|
|
355
|
+
|
|
356
|
+
Report vulnerabilities privately as described in [SECURITY.md](SECURITY.md).
|
|
357
|
+
|
|
358
|
+
## License
|
|
359
|
+
|
|
360
|
+
Apache License 2.0 — see [LICENSE](LICENSE) and [NOTICE](NOTICE).
|