sendurl 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.
@@ -0,0 +1,14 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .venv/
5
+ venv/
6
+ dist/
7
+ build/
8
+ .pytest_cache/
9
+ .mypy_cache/
10
+ .ruff_cache/
11
+ .coverage
12
+ htmlcov/
13
+ .env
14
+ .env.*
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
5
+ [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.0] - 2026-11-27
10
+
11
+ ### Added
12
+
13
+ - First release: `SendURL` (sync) and `AsyncSendURL` (async) clients for the SendURL REST API
14
+ (API-key auth): account, links (create, list, get, update, delete, A/B test winner, stats,
15
+ clicks, CSV export), analytics (overview, breakdown, clicks), folders, tags and domains.
16
+ - Auto-pagination iterators and single-page methods, typed responses (`TypedDict`), one
17
+ exception per error kind, and retries with backoff for GET requests only.
18
+ - README: an intro to SendURL, how to get an API key, links to the feature pages, pricing and docs,
19
+ and a Links section. Package metadata lists the API, pricing, repository, issues and changelog URLs.
sendurl-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DRG Technologies and Consultancy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
sendurl-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,495 @@
1
+ Metadata-Version: 2.5
2
+ Name: sendurl
3
+ Version: 0.1.0
4
+ Summary: Official Python client for the SendURL REST API: short links, QR codes and click analytics.
5
+ Project-URL: Homepage, https://sendurl.to
6
+ Project-URL: Documentation, https://sendurl.to/docs
7
+ Project-URL: API, https://sendurl.to/features/api
8
+ Project-URL: Pricing, https://sendurl.to/pricing
9
+ Project-URL: Repository, https://github.com/sendurl-to/sendurl-python
10
+ Project-URL: Issues, https://github.com/sendurl-to/sendurl-python/issues
11
+ Project-URL: Changelog, https://github.com/sendurl-to/sendurl-python/blob/main/CHANGELOG.md
12
+ Author: DRG Technologies and Consultancy
13
+ License-Expression: MIT
14
+ License-File: LICENSE
15
+ Keywords: analytics,api,qr codes,sdk,sendurl,short links,url shortener
16
+ Classifier: Development Status :: 4 - Beta
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3 :: Only
22
+ Classifier: Programming Language :: Python :: 3.9
23
+ Classifier: Programming Language :: Python :: 3.10
24
+ Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
26
+ Classifier: Programming Language :: Python :: 3.13
27
+ Classifier: Topic :: Internet :: WWW/HTTP
28
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
29
+ Classifier: Typing :: Typed
30
+ Requires-Python: >=3.9
31
+ Requires-Dist: httpx<1,>=0.24
32
+ Description-Content-Type: text/markdown
33
+
34
+ # SendURL Python SDK
35
+
36
+ [SendURL](https://sendurl.to) is a URL shortener with click analytics, QR codes and custom domains. This is the
37
+ official Python client for its [REST API](https://sendurl.to/features/api) ([API reference](https://sendurl.to/docs)): create short links
38
+ and QR codes, organize them in folders and tags, and read click analytics.
39
+
40
+ - Sync (`SendURL`) and async (`AsyncSendURL`) clients with the same methods
41
+ - Typed responses (`TypedDict`s) and a `py.typed` marker
42
+ - Lists you can iterate, with pagination handled for you
43
+ - One exception class per kind of error, carrying the API's stable error `code`
44
+ - GET requests retried on network errors, 429, 502, 503 and 504, honouring `Retry-After`
45
+ - Python 3.9 or later; its only dependency is [`httpx`](https://www.python-httpx.org/)
46
+
47
+ ## Install
48
+
49
+ ```sh
50
+ pip install sendurl
51
+ ```
52
+
53
+ ## Quick start
54
+
55
+ [Create a free SendURL account](https://console.sendurl.to/signup), then create an API key on the console's [API keys page](https://console.sendurl.to/api-keys), then:
56
+
57
+ ```python
58
+ from sendurl import SendURL
59
+
60
+ client = SendURL(api_key="snu_...") # or set SENDURL_API_KEY and call SendURL()
61
+
62
+ link = client.links.create(destination_url="https://example.com/launch", slug="launch")
63
+ print(link["shortUrl"]) # https://snu.to/launch
64
+ print(link["qrUrl"]) # the URL a QR code of this link should encode
65
+
66
+ for link in client.links.list(status="active"):
67
+ print(link["slug"], link["totalClicks"])
68
+
69
+ client.close()
70
+ ```
71
+
72
+ You can use the client as a context manager instead, so it closes itself:
73
+
74
+ ```python
75
+ with SendURL() as client:
76
+ me = client.account.get()
77
+ print(me["plan"]["name"], me["usage"]["linksUsed"], "/", me["plan"]["linksLimit"])
78
+ ```
79
+
80
+ ### Async
81
+
82
+ ```python
83
+ import asyncio
84
+ from sendurl import AsyncSendURL
85
+
86
+
87
+ async def main() -> None:
88
+ async with AsyncSendURL() as client:
89
+ link = await client.links.create(destination_url="https://example.com")
90
+ async for click in client.links.clicks.list(link["id"]):
91
+ print(click["clickedAt"], click["country"])
92
+
93
+
94
+ asyncio.run(main())
95
+ ```
96
+
97
+ The async client has the same methods as the sync one. Await every call, and use `async for`
98
+ with the `list()` methods.
99
+
100
+ ## Responses
101
+
102
+ Every method returns the API's JSON as plain Python dicts and lists. The keys are **camelCase,
103
+ as they are on the wire** (`link["shortUrl"]`, `link["destinationUrl"]`), so the
104
+ [API reference](https://sendurl.to/docs) applies as written. The `TypedDict`s in `sendurl`
105
+ (`Link`, `LinkList`, `Click`, `Account`, `Overview`, ...) describe them for your editor and type
106
+ checker. They are all `total=False`, so a field the server adds later shows up in the dict
107
+ and never breaks your code.
108
+
109
+ Arguments are snake_case keyword arguments and are mapped to the API's camelCase for you
110
+ (`destination_url` becomes `destinationUrl`, `folder_id` becomes `folderId`).
111
+
112
+ ## Reference
113
+
114
+ The examples below use the sync client; for the async client, add `await` (or `async for`).
115
+
116
+ ### Account
117
+
118
+ ```python
119
+ me = client.account.get() # GET /me
120
+ me["org"]["name"], me["plan"]["linksLimit"], me["usage"]["linksUsed"]
121
+ me["key"]["scopes"] # None = every scope
122
+ me["folder"] # the folder a folder-level key is limited to, else None
123
+ ```
124
+
125
+ ### Links
126
+
127
+ A link can also send phones to [mobile app targets](https://sendurl.to/features/mobile-targets), [expire](https://sendurl.to/features/link-expiration) or ask for a [password](https://sendurl.to/features/password-protected-links), carry a [styled QR code](https://sendurl.to/features/qr-codes) and a [custom link preview](https://sendurl.to/features/link-previews), and split its visitors in an [A/B test](https://sendurl.to/features/ab-testing).
128
+
129
+ ```python
130
+ from datetime import datetime, timezone
131
+
132
+ link = client.links.create(
133
+ destination_url="https://example.com/spring", # required
134
+ slug="spring", # default: a random slug
135
+ title="Spring campaign",
136
+ folder_id="…", # default: the Default folder (or a folder key's own)
137
+ domain_id="…", # a live domain (client.domains); can't be changed later
138
+ tag_ids=["…", "…"],
139
+ ios_url="https://apps.apple.com/app/id123", # where iPhone and iPad visitors go
140
+ android_url="https://play.google.com/store/apps/details?id=x",
141
+ expires_at=datetime(2027, 1, 1, tzinfo=timezone.utc), # Pro and above
142
+ password="s3cret!", # Pro and above; never returned to an API key
143
+ qr_style={"fg": "#1a1a2e", "bg": "#ffffff", "dots": "rounded", "corners": "dots"}, # "v": 1 is added
144
+ preview={"title": "Spring sale", "description": "Up to 40% off", "image": "https://…/card.png"},
145
+ ab_test={
146
+ "variants": [
147
+ {"id": "a", "url": "https://example.com/spring", "weight": 50},
148
+ {"id": "b", "url": "https://example.com/spring-b", "weight": 50},
149
+ ]
150
+ },
151
+ )
152
+
153
+ link = client.links.get(link["id"]) # adds totalClicks, qrScans, tags, domain
154
+ client.links.delete(link["id"]) # paid plans; on Free, disable it instead
155
+ ```
156
+
157
+ `expires_at` takes a timezone-aware `datetime` or an ISO 8601 string with an offset
158
+ (`"2027-01-01T00:00:00Z"`). A naive `datetime` raises `ValueError`, because the API needs to
159
+ know the time zone.
160
+
161
+ **Update** changes only the fields you pass. Passing `None` clears a field (it is sent as JSON
162
+ `null`); leaving a field out leaves it as it is:
163
+
164
+ ```python
165
+ client.links.update(link_id, title="New title") # only the title changes
166
+ client.links.update(link_id, ios_url=None) # remove the iOS target
167
+ client.links.update(link_id, expires_at=None) # never expire
168
+ client.links.update(link_id, active=False) # disable the link
169
+ client.links.update(link_id, destination_url="https://…") # Pro and above
170
+ client.links.update(link_id, ab_test=None) # end the A/B test without a winner
171
+ ```
172
+
173
+ The default of every `update()` argument is `sendurl.NOT_GIVEN`, which means "not passed".
174
+
175
+ **A/B test winner**: end a running test and make one variant's URL the destination:
176
+
177
+ ```python
178
+ client.links.pick_winner(link_id, variant_id="b") # POST /links/:id/ab-test/winner
179
+ ```
180
+
181
+ **List and search**:
182
+
183
+ ```python
184
+ for link in client.links.list(
185
+ status=["active", "expired"], # any of: active, disabled, expired, protected, limit_reached
186
+ q="spring", # searches slug, destination and title
187
+ sort="clicks_desc", # created_desc (default), clicks_desc, clicks_asc
188
+ folder_id="…",
189
+ tag_ids=["…"], # links with any of these tags
190
+ ):
191
+ ...
192
+
193
+ page = client.links.list_page(limit=10) # one page, with summary, usage and pagination
194
+ page["summary"] # {"totalLinks", "activeLinks", "totalClicks"}, or None for very large workspaces
195
+ page["usage"] # {"linksUsed", "linksLimit"}
196
+ ```
197
+
198
+ The clicks sorts follow the live click counter, so a link can move between pages while you
199
+ page through them; deduplicate by `id` if that matters.
200
+
201
+ **Stats and clicks**:
202
+
203
+ ```python
204
+ client.links.stats(link_id) # [{"date": "2026-11-01", "count": 12}, ...] all-time, UTC days with clicks
205
+
206
+ for click in client.links.clicks.list(link_id): # newest first
207
+ click["clickedAt"], click["country"], click["device"], click["source"] # "qr" for a QR scan
208
+
209
+ page = client.links.clicks.list_page(link_id, limit=10)
210
+ click = client.links.clicks.get(link_id, click_id)
211
+ ```
212
+
213
+ A click never includes the visitor's IP address. On the Free plan `city` is `None` and
214
+ `cityLocked` is `True`.
215
+
216
+ **[CSV export](https://sendurl.to/features/export)** of every link matching the filters, streamed:
217
+
218
+ ```python
219
+ with client.links.export(status="active") as csv: # GET /links/export.csv
220
+ for chunk in csv: # bytes
221
+ ...
222
+
223
+ client.links.export_to_file("links.csv", folder_id="…") # returns the number of bytes written
224
+ ```
225
+
226
+ On the async client, `csv = await client.links.export()`, then `async with csv:` and
227
+ `async for chunk in csv:`.
228
+
229
+ ### Analytics
230
+
231
+ [Analytics](https://sendurl.to/features/link-analytics) dates are `datetime.date` objects or `"YYYY-MM-DD"` strings, inclusive, in `tz` (an IANA
232
+ name such as `"Europe/Paris"`, default UTC). The range must lie within your plan's analytics
233
+ history (otherwise you get `BadRequestError` with code `range_outside_history`). Pass
234
+ `folder_id` or `link_id` to narrow the scope; without either an org key reads the whole
235
+ workspace.
236
+
237
+ ```python
238
+ from datetime import date
239
+
240
+ overview = client.analytics.overview(from_=date(2026, 11, 1), to=date(2026, 11, 7), tz="Europe/Paris")
241
+ overview["kpis"]["clicks"], overview["series"], overview["topLinks"], overview["breakdowns"]["country"]
242
+
243
+ top = client.analytics.breakdown(
244
+ from_="2026-11-01",
245
+ to="2026-11-07",
246
+ # link, country, device, browser, os, referrer, variant (needs link_id),
247
+ # and on Pro and above city and utm
248
+ dimension="country",
249
+ order="desc",
250
+ limit=10,
251
+ )
252
+ client.analytics.breakdown(from_="2026-11-01", to="2026-11-07", dimension="utm", by="campaign")
253
+ client.analytics.breakdown(from_="2026-11-01", to="2026-11-07", dimension="referrer", category="social")
254
+ client.analytics.breakdown(from_="2026-11-01", to="2026-11-07", dimension="city", count_only=True)
255
+
256
+ for click in client.analytics.clicks(from_="2026-11-01", to="2026-11-07", link_id=link_id):
257
+ click["clickedAt"], click["referrer"]["label"]
258
+
259
+ page = client.analytics.clicks_page(from_="2026-11-01", to="2026-11-07") # pagination.total on page 1
260
+ ```
261
+
262
+ The `utm` breakdown reads the [UTM parameters](https://sendurl.to/features/utm) in each link's destination URL; the free [UTM builder](https://sendurl.to/tools/utm-builder) writes them for you.
263
+
264
+ `from_` has a trailing underscore because `from` is a Python keyword. Send analytics requests
265
+ one at a time: when analytics are busy the API answers 503 `analytics_unavailable`, which the
266
+ client retries for you after `Retry-After` seconds.
267
+
268
+ ### Folders
269
+
270
+ ```python
271
+ for folder in client.folders.list(): # Default first; org-level keys only
272
+ folder["name"], folder["linksCount"]
273
+
274
+ page = client.folders.list_page()
275
+ folder = client.folders.create(name="Marketing")
276
+ ```
277
+
278
+ ### Tags
279
+
280
+ ```python
281
+ for tag in client.tags.list():
282
+ tag["id"], tag["name"], tag["color"], tag["linksCount"]
283
+
284
+ page = client.tags.list_page() # adds usage: {"tagsUsed", "tagsLimit"}
285
+ ```
286
+
287
+ [Tags](https://sendurl.to/features/folders-and-tags) are created and edited in the console; use their ids in `tag_ids`.
288
+
289
+ ### Domains
290
+
291
+ Read only for API keys: [custom domains](https://sendurl.to/features/custom-domains) are added in the console.
292
+
293
+ ```python
294
+ for domain in client.domains.list():
295
+ domain["hostname"], domain["type"], domain["status"] # subdomain | custom; pending | active | failed
296
+
297
+ page = client.domains.list_page()
298
+ domain = client.domains.get(domain_id)
299
+ ```
300
+
301
+ ## Pagination
302
+
303
+ Every list endpoint returns at most 10 items per page. Each resource gives you two ways to
304
+ read it:
305
+
306
+ - `list(...)` returns an iterator over **every** item. It fetches the next page (following
307
+ `pagination.nextCursor`) only when you reach the end of the current one, and nothing at all
308
+ until you start iterating. Its `limit` argument is the page size (1-10), not a total.
309
+ - `list_page(..., cursor=None)` returns one page as the API sends it (the items, `pagination`,
310
+ and extras such as `summary` and `usage`). Pass `page["pagination"]["nextCursor"]` as
311
+ `cursor` to read the next page.
312
+
313
+ ```python
314
+ page = client.links.list_page()
315
+ while True:
316
+ for link in page["links"]:
317
+ ...
318
+ if not page["pagination"]["hasMore"]:
319
+ break
320
+ page = client.links.list_page(cursor=page["pagination"]["nextCursor"])
321
+ ```
322
+
323
+ ## Errors
324
+
325
+ Every API error raises a subclass of `sendurl.SendURLError`:
326
+
327
+ | Exception | When |
328
+ |---|---|
329
+ | `BadRequestError` | 400: `validation_error` (see `issues`), `range_outside_history`, ... |
330
+ | `AuthenticationError` | 401: missing, invalid, revoked or expired API key |
331
+ | `PermissionDeniedError` | 403: `insufficient_scope`, `plan_upgrade_required` (a [paid plan](https://sendurl.to/pricing) feature), `link_limit_reached`, ... |
332
+ | `NotFoundError` | 404: `link_not_found`, `click_not_found`, `domain_not_found`, ... |
333
+ | `ConflictError` | 409: `slug_taken`, `project_name_taken`, `domain_not_active` |
334
+ | `UnprocessableEntityError` | 422: `unsafe_destination`, `too_many_urls` |
335
+ | `RateLimitError` | 429 |
336
+ | `InternalServerError` | 5xx |
337
+ | `ServiceUnavailableError` | 503 (a subclass of `InternalServerError`): `analytics_unavailable`, `export_unavailable`, `domains_unavailable` |
338
+ | `APIConnectionError` | no response: DNS failure, refused or reset connection |
339
+ | `APITimeoutError` | the request timed out (a subclass of `APIConnectionError`) |
340
+
341
+ Each error carries:
342
+
343
+ - `status_code`: the HTTP status (`None` for connection errors)
344
+ - `code`: the API's stable error code. **Branch on `code`, never on `message`.**
345
+ - `message`: a sentence for a person
346
+ - `issues`: the field issues of a `validation_error`
347
+ - `body`: the whole JSON error body, with extra fields such as `limit`, `current`, `feature`
348
+ and `requiredPlan`
349
+ - `retry_after`: seconds to wait, when the API said so
350
+
351
+ ```python
352
+ from sendurl import ConflictError, PermissionDeniedError
353
+
354
+ try:
355
+ client.links.create(destination_url="https://example.com", slug="launch")
356
+ except ConflictError as e:
357
+ if e.code == "slug_taken":
358
+ ...
359
+ except PermissionDeniedError as e:
360
+ if e.code == "link_limit_reached":
361
+ print(f"{e.body['current']} of {e.body['limit']} links used")
362
+ elif e.code == "plan_upgrade_required":
363
+ print("Needs the", e.body["requiredPlan"], "plan")
364
+ ```
365
+
366
+ ## Retries and timeouts
367
+
368
+ GET requests are retried up to `max_retries` times (default 2) on connection errors and
369
+ timeouts, and on 429, 502, 503 and 504 responses. The client waits for `Retry-After` seconds
370
+ when the API sends it (at most 60), otherwise it backs off exponentially with jitter
371
+ (about 0.5 s, then 1 s, then 2 s, ...).
372
+
373
+ **POST, PATCH and DELETE are never retried**: the API has no idempotency key, so retrying a
374
+ create could make the same link twice. If one of them fails with a connection error, check
375
+ whether it went through (for example with `links.list(q=slug)`) before trying again.
376
+
377
+ Each request times out after `timeout` seconds (default 30).
378
+
379
+ ## Configuration
380
+
381
+ ```python
382
+ import httpx
383
+ from sendurl import SendURL
384
+
385
+ client = SendURL(
386
+ api_key="snu_...", # default: the SENDURL_API_KEY environment variable
387
+ base_url="https://api.sendurl.to/api/v1", # default: SENDURL_BASE_URL, else production
388
+ timeout=30.0, # seconds, or an httpx.Timeout
389
+ max_retries=2, # retries for GET requests; 0 turns them off
390
+ http_client=httpx.Client(proxy="http://proxy:8080"), # optional: your own httpx client
391
+ )
392
+ ```
393
+
394
+ `AsyncSendURL` takes the same arguments, with an `httpx.AsyncClient` as `http_client`. A client
395
+ you pass in is yours to close: `close()` / `aclose()` close only the one the SDK created.
396
+
397
+ `base_url` must be `https://`; plain `http://` is accepted only for `localhost`, `127.0.0.1`
398
+ and `::1` (a local platform), so the key never crosses a network in clear text. Redirects are
399
+ never followed, even by an `http_client` created with `follow_redirects=True`: a 3xx answer
400
+ raises `SendURLError` (usually a wrong `base_url`).
401
+
402
+ The API key is never included in `repr(client)` or in any error message. Keep it on the server:
403
+ a key shipped in browser or mobile code can be read by anyone.
404
+
405
+ ### Scopes
406
+
407
+ An API key can be limited to some scopes. Each method needs one:
408
+
409
+ | Scope | Methods |
410
+ |---|---|
411
+ | `links:read` | `links.list`, `list_page`, `get`, `stats`, `export`, `links.clicks.*` |
412
+ | `links:write` | `links.create`, `update`, `pick_winner` |
413
+ | `links:delete` | `links.delete` |
414
+ | `analytics:read` | `analytics.*` |
415
+ | `workspace:read` | `account.get`, `folders.list`, `tags.list`, `domains.*` |
416
+ | `folders:write` | `folders.create` |
417
+
418
+ A key without the scope gets `PermissionDeniedError` with code `insufficient_scope`.
419
+
420
+ ## Local development
421
+
422
+ To point the client at a SendURL platform running on your machine:
423
+
424
+ ```python
425
+ client = SendURL(api_key="snu_...", base_url="http://localhost:1911/api/v1")
426
+ ```
427
+
428
+ To work on this library:
429
+
430
+ ```sh
431
+ uv sync # create .venv with the dev tools
432
+ uv run ruff check .
433
+ uv run ruff format --check .
434
+ uv run mypy
435
+ uv run pytest
436
+ uv build
437
+ ```
438
+
439
+ The integration tests in `tests/test_integration.py` run against a real platform and are
440
+ skipped unless both variables are set:
441
+
442
+ ```sh
443
+ SENDURL_BASE_URL=http://localhost:1911/api/v1 SENDURL_API_KEY=snu_... uv run pytest tests/test_integration.py -v
444
+ ```
445
+
446
+ They create one link and delete it at the end (on the Free plan, where deleting isn't
447
+ allowed, they disable it instead).
448
+
449
+ ## Releasing
450
+
451
+ For maintainers. Releases are published from GitHub, never from a laptop:
452
+
453
+ 1. Bump the version in **both** `pyproject.toml` (`version`) and `src/sendurl/_version.py`
454
+ (`__version__`, which the `User-Agent` carries) to the same
455
+ [PEP 440](https://peps.python.org/pep-0440/) version, such as `0.2.0` or `0.2.0rc1`, and add
456
+ its section to `CHANGELOG.md` (`## [x.y.z] - YYYY-MM-DD`). A unit test and the release build
457
+ both fail when the two differ, so a mismatched version is never published.
458
+ 2. Merge to `main`.
459
+ 3. The Release workflow (`.github/workflows/release.yml`) runs on any `pyproject.toml` change on
460
+ `main`. If that exact version isn't on PyPI yet, it runs ruff, mypy and the tests, builds the
461
+ sdist and wheel, publishes them to PyPI with
462
+ [Trusted Publishing](https://docs.pypi.org/trusted-publishers/) (no PyPI token exists), and
463
+ creates the `vx.y.z` tag on that commit with a GitHub Release whose notes are the version's
464
+ CHANGELOG section. An `a`, `b`, `rc` or `dev` version is marked as a prerelease on GitHub
465
+ (pip installs it only when asked for it explicitly). A version already on PyPI is not
466
+ published again, so other `pyproject.toml` edits publish nothing.
467
+
468
+ It can also be started by hand (Actions → Release → Run workflow, on `main`). PyPI records no
469
+ commit for a release, so when a version is already on PyPI but has no GitHub Release yet (a
470
+ failed run), the run creates it only when you give `target_sha`: the full SHA of the commit on
471
+ `main` it was published from. Without it, the run only warns.
472
+
473
+ **The very first release (0.1.0)** needs two one-time steps: register a *pending* trusted
474
+ publisher on PyPI (PyPI project name `sendurl`, owner `sendurl-to`, repository `sendurl-python`,
475
+ workflow `release.yml`, environment `pypi`), then run the workflow once by hand (Actions → Release → Run workflow, on
476
+ `main`). The commit that added the workflow doesn't change `pyproject.toml`, so pushing it starts
477
+ no run.
478
+
479
+ Releases run from `main` only. PyPI trusts exactly this repository, the workflow file
480
+ `release.yml` and the GitHub environment `pypi`, whose deployment branch policy allows only
481
+ `main`. Renaming the workflow file breaks publishing until the trusted publisher is updated.
482
+
483
+ ## Links
484
+
485
+ - [SendURL website](https://sendurl.to): the URL shortener this SDK talks to
486
+ - [API reference](https://sendurl.to/docs): every endpoint, field and error code
487
+ - [Plans and pricing](https://sendurl.to/pricing): limits and the features each plan includes
488
+ - [Free URL shortener](https://sendurl.to/free-url-shortener): shorten a link without an account
489
+ - [Free link tools](https://sendurl.to/tools): a [UTM builder](https://sendurl.to/tools/utm-builder), a [QR code generator](https://sendurl.to/tools/qr-code-generator) and more
490
+ - [Guides](https://sendurl.to/guides) and the [SendURL blog](https://sendurl.to/blog)
491
+ - [SendURL console](https://console.sendurl.to): your links, analytics and API keys
492
+
493
+ ## License
494
+
495
+ MIT, see [LICENSE](LICENSE).