leto-domain-api 1.0.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.
Files changed (50) hide show
  1. leto_domain_api-1.0.0/.gitignore +9 -0
  2. leto_domain_api-1.0.0/CHANGELOG.md +24 -0
  3. leto_domain_api-1.0.0/LICENSE +21 -0
  4. leto_domain_api-1.0.0/OPERATIONS.md +185 -0
  5. leto_domain_api-1.0.0/PKG-INFO +391 -0
  6. leto_domain_api-1.0.0/README.md +363 -0
  7. leto_domain_api-1.0.0/examples/quickstart.py +138 -0
  8. leto_domain_api-1.0.0/pyproject.toml +81 -0
  9. leto_domain_api-1.0.0/src/leto_domain_api/__init__.py +75 -0
  10. leto_domain_api-1.0.0/src/leto_domain_api/_client.py +172 -0
  11. leto_domain_api-1.0.0/src/leto_domain_api/_config.py +112 -0
  12. leto_domain_api-1.0.0/src/leto_domain_api/_errors.py +384 -0
  13. leto_domain_api-1.0.0/src/leto_domain_api/_helpers.py +251 -0
  14. leto_domain_api-1.0.0/src/leto_domain_api/_idempotency.py +24 -0
  15. leto_domain_api-1.0.0/src/leto_domain_api/_options.py +52 -0
  16. leto_domain_api-1.0.0/src/leto_domain_api/_page.py +220 -0
  17. leto_domain_api-1.0.0/src/leto_domain_api/_response.py +47 -0
  18. leto_domain_api-1.0.0/src/leto_domain_api/_retry_after.py +32 -0
  19. leto_domain_api-1.0.0/src/leto_domain_api/_transport.py +435 -0
  20. leto_domain_api-1.0.0/src/leto_domain_api/py.typed +0 -0
  21. leto_domain_api-1.0.0/src/leto_domain_api/resources/__init__.py +50 -0
  22. leto_domain_api-1.0.0/src/leto_domain_api/resources/_accessors.py +214 -0
  23. leto_domain_api-1.0.0/src/leto_domain_api/resources/account.py +222 -0
  24. leto_domain_api-1.0.0/src/leto_domain_api/resources/addons.py +205 -0
  25. leto_domain_api-1.0.0/src/leto_domain_api/resources/contacts.py +499 -0
  26. leto_domain_api-1.0.0/src/leto_domain_api/resources/dns.py +1681 -0
  27. leto_domain_api-1.0.0/src/leto_domain_api/resources/domain_security.py +495 -0
  28. leto_domain_api-1.0.0/src/leto_domain_api/resources/domains.py +1832 -0
  29. leto_domain_api-1.0.0/src/leto_domain_api/resources/email_forwarding.py +1287 -0
  30. leto_domain_api-1.0.0/src/leto_domain_api/resources/events.py +495 -0
  31. leto_domain_api-1.0.0/src/leto_domain_api/resources/jobs.py +538 -0
  32. leto_domain_api-1.0.0/src/leto_domain_api/resources/pricing.py +328 -0
  33. leto_domain_api-1.0.0/src/leto_domain_api/resources/statistics.py +118 -0
  34. leto_domain_api-1.0.0/src/leto_domain_api/resources/transactions.py +370 -0
  35. leto_domain_api-1.0.0/src/leto_domain_api/resources/transfers.py +1487 -0
  36. leto_domain_api-1.0.0/src/leto_domain_api/resources/url_forwarding.py +1090 -0
  37. leto_domain_api-1.0.0/src/leto_domain_api/types.py +4012 -0
  38. leto_domain_api-1.0.0/src/leto_domain_api/version.py +22 -0
  39. leto_domain_api-1.0.0/tests/__init__.py +0 -0
  40. leto_domain_api-1.0.0/tests/conftest.py +58 -0
  41. leto_domain_api-1.0.0/tests/smoke/__init__.py +0 -0
  42. leto_domain_api-1.0.0/tests/smoke/test_sandbox.py +48 -0
  43. leto_domain_api-1.0.0/tests/support.py +112 -0
  44. leto_domain_api-1.0.0/tests/test_async_client.py +75 -0
  45. leto_domain_api-1.0.0/tests/test_client.py +280 -0
  46. leto_domain_api-1.0.0/tests/test_errors.py +195 -0
  47. leto_domain_api-1.0.0/tests/test_idempotency.py +231 -0
  48. leto_domain_api-1.0.0/tests/test_pagination.py +218 -0
  49. leto_domain_api-1.0.0/tests/test_quote_helpers.py +165 -0
  50. leto_domain_api-1.0.0/tests/test_retry.py +216 -0
@@ -0,0 +1,9 @@
1
+ /.venv/
2
+ __pycache__/
3
+ *.py[cod]
4
+ /.pytest_cache/
5
+ /.mypy_cache/
6
+ /.ruff_cache/
7
+ /dist/
8
+ /build/
9
+ *.egg-info/
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ All notable changes to this package are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the package uses
5
+ [semantic versioning](https://semver.org).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [1.0.0] - 2026-11-20
10
+
11
+ ### Added
12
+
13
+ - First version of the Python SDK, generated from the LETO Domain API OpenAPI document 1.1.0:
14
+ 108 operations in 14 resources, on `LetoClient` (synchronous) and `AsyncLetoClient` (asyncio).
15
+ - Bearer API key authentication, User-Agent `leto-domain-sdk-python/<version>`.
16
+ - Exceptions per error class with the API error code, data, extra fields and request ID.
17
+ - Retries with backoff and `Retry-After` for GET requests and requests with an Idempotency-Key.
18
+ A charging request is not resent after a 502 or 504 error from the API itself (the registry
19
+ may have applied it), only after a proxy error page, a connection error, 429 or 503.
20
+ - Automatic `Idempotency-Key` on registration, renewal, restore and transfer.
21
+ - `Page` and `AsyncPage` with `auto_paginate()` for every list endpoint, including
22
+ `GET /transactions`.
23
+ - `register_with_quote()`, `renew_with_quote()` and `initiate_with_quote()` helpers.
24
+ - `TypedDict` shapes for every request and response, and `py.typed`.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Feather IT Inc.
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.
@@ -0,0 +1,185 @@
1
+ <!-- Generated by the leto-sdk generator from spec/partner.json. Do not edit by hand. -->
2
+
3
+ # Operations
4
+
5
+ LETO Domain API 1.1.0: 108 operations in 14 resources. The same methods are on `LetoClient` and, as coroutines, on `AsyncLetoClient`. Every method also takes the keyword argument `options` (`RequestOptions`). Optional query parameters go in the keyword argument `query`, a dict with the parameter names of the API reference.
6
+
7
+ Legend: **charges** = charges the balance and sends an `Idempotency-Key`; **page** = returns a `Page` (`AsyncPage` on the async client, use `auto_paginate()`).
8
+
9
+ ## Account: `client.account`
10
+
11
+ | Method | HTTP | Summary |
12
+ |---|---|---|
13
+ | `get_status()` | `GET /api/v1/account/status` | Get account status and balance |
14
+ | `get_contact()` | `GET /api/v1/account/contact` | Get account notification contact |
15
+ | `update_contact(body)` | `PATCH /api/v1/account/contact` | Update account notification contact |
16
+
17
+ ## Pricing: `client.pricing`
18
+
19
+ | Method | HTTP | Summary |
20
+ |---|---|---|
21
+ | `list_tlds(query={...})` | `GET /api/v1/domain/tlds` | List TLD prices (**page**) |
22
+ | `get_tld(tld)` | `GET /api/v1/domain/tlds/{tld}` | Get the price of one TLD |
23
+ | `quote(domain, query={...})` | `GET /api/v1/domain/quote` | Get a price quote |
24
+
25
+ ## Domains: `client.domains`
26
+
27
+ | Method | HTTP | Summary |
28
+ |---|---|---|
29
+ | `check(domain)` | `GET /api/v1/domain/check` | Check domain availability |
30
+ | `list(query={...})` | `GET /api/v1/domain` | List domains (**page**) |
31
+ | `get(domain_name)` | `GET /api/v1/domain/{domainName}` | Get a domain |
32
+ | `register(body)` | `POST /api/v1/domain` | Register a domain (**charges**) |
33
+ | `renew(domain_name, body)` | `POST /api/v1/domain/{domainName}/renewal` | Renew a domain (**charges**) |
34
+ | `restore(domain_name)` | `POST /api/v1/domain/{domainName}/restore` | Restore a deleted domain (**charges**) |
35
+ | `list_renewals(domain_name)` | `GET /api/v1/domain/{domainName}/renewal` | List renewals of a domain |
36
+ | `list_renewal_records(domain_name, query={...})` | `GET /api/v1/domain/{domainName}/renewals` | List renewal records (paginated) (**page**) |
37
+ | `cancel_renewal(domain_name, transaction_id)` | `DELETE /api/v1/domain/{domainName}/renewal/{transactionId}` | Cancel a renewal (and refund) |
38
+ | `list_transactions(domain_name, query={...})` | `GET /api/v1/domain/{domainName}/transactions` | List transactions of a domain (paginated) (**page**) |
39
+ | `get_contacts(domain_name)` | `GET /api/v1/domain/{domainName}/contact` | Get domain contacts |
40
+ | `update_contacts(domain_name, body)` | `PUT /api/v1/domain/{domainName}/contact` | Change domain contacts |
41
+ | `release_local_presence(domain_name, body=None)` | `DELETE /api/v1/domain/{domainName}/local-presence` | Release local presence |
42
+ | `get_deletion_eligibility(domain_name)` | `GET /api/v1/domain/{domainName}/deletion-eligibility` | Check whether a domain can be deleted |
43
+ | `delete(domain_name)` | `DELETE /api/v1/domain/{domainName}` | Delete a domain (and refund) |
44
+ | `delete_by_post(domain_name)` | `POST /api/v1/domain/{domainName}/delete` | Delete a domain (and refund) |
45
+ | `whois(domain_name)` | `GET /api/v1/domain/{domainname}/whois` | Look up WHOIS |
46
+
47
+ ## Contacts: `client.contacts`
48
+
49
+ | Method | HTTP | Summary |
50
+ |---|---|---|
51
+ | `list(query={...})` | `GET /api/v1/contacts` | List contacts (**page**) |
52
+ | `get(contact_id)` | `GET /api/v1/contacts/{contactId}` | Get a contact |
53
+ | `create(body)` | `POST /api/v1/contacts` | Create a contact |
54
+ | `update(contact_id, body)` | `PUT /api/v1/contacts/{contactId}` | Update a contact |
55
+ | `delete(contact_id)` | `DELETE /api/v1/contacts/{contactId}` | Delete a contact |
56
+
57
+ ## Domain Security: `client.domain_security`
58
+
59
+ | Method | HTTP | Summary |
60
+ |---|---|---|
61
+ | `get_locks(domain_name)` | `GET /api/v1/domain/{domainName}/locks` | Get the domain lock status |
62
+ | `get_update_lock(domain_name)` | `GET /api/v1/domain/{domainName}/updatelock` | Get the update lock |
63
+ | `set_update_lock(domain_name, body)` | `PUT /api/v1/domain/{domainName}/updatelock` | Turn the update lock on or off |
64
+ | `get_krnic_privacy(domain_name)` | `GET /api/v1/domain/{domainName}/krnic-privacy` | Get the KISA WHOIS disclosure setting |
65
+ | `set_krnic_privacy(domain_name, body)` | `PUT /api/v1/domain/{domainName}/krnic-privacy` | Change the KISA WHOIS disclosure setting |
66
+
67
+ ## Transfers: `client.transfers`
68
+
69
+ | Method | HTTP | Summary |
70
+ |---|---|---|
71
+ | `initiate(body)` | `POST /api/v1/domain/transfer` | Request a transfer into your account (**charges**) |
72
+ | `list(query={...})` | `GET /api/v1/domain/transfer` | List your transfers (**page**) |
73
+ | `get(transfer_id)` | `GET /api/v1/domain/transfer/{transferId}` | Get a transfer |
74
+ | `list_for_domain(domain_name)` | `GET /api/v1/domain/{domainName}/transfer` | List transfers of a domain |
75
+ | `resolve_domain(transfer_id)` | `GET /api/v1/domain/transfer/{transferId}/domain` | Get the domain of a transfer |
76
+ | `approve(transfer_id)` | `POST /api/v1/domain/transfer/{transferId}/approve` | Approve an outgoing transfer |
77
+ | `reject(transfer_id, body=None)` | `POST /api/v1/domain/transfer/{transferId}/reject` | Reject an outgoing transfer |
78
+ | `cancel(transfer_id)` | `POST /api/v1/domain/transfer/{transferId}/cancel` | Cancel your transfer request |
79
+ | `get_auth_code(domain_name)` | `GET /api/v1/domain/{domainName}/transfer/auth-code` | Get the auth code |
80
+ | `rotate_auth_code(domain_name)` | `PUT /api/v1/domain/{domainName}/transfer/auth-code` | Rotate the auth code |
81
+ | `verify_auth_code(body)` | `POST /api/v1/domain/transfer/auth-code/verify` | Verify an auth code before a transfer |
82
+ | `get_lock(domain_name)` | `GET /api/v1/domain/{domainName}/transferlock` | Get the transfer lock |
83
+ | `set_lock(domain_name, body)` | `PUT /api/v1/domain/{domainName}/transferlock` | Turn the transfer lock on or off |
84
+ | `get_auto_reject(domain_name)` | `GET /api/v1/domain/{domainName}/transferautoreject` | Get the transfer auto-reject setting |
85
+ | `set_auto_reject(domain_name, body)` | `PUT /api/v1/domain/{domainName}/transferautoreject` | Turn transfer auto-reject on or off |
86
+
87
+ ## DNS: `client.dns`
88
+
89
+ | Method | HTTP | Summary |
90
+ |---|---|---|
91
+ | `list_zones(query={...})` | `GET /api/v1/dns/zones` | List DNS zones (**page**) |
92
+ | `create_zone(body)` | `POST /api/v1/dns/zones` | Create a DNS zone |
93
+ | `get_zone(zone_id)` | `GET /api/v1/dns/zones/{zoneId}` | Get a DNS zone with its records |
94
+ | `delete_zone(zone_id)` | `DELETE /api/v1/dns/zones/{zoneId}` | Delete a DNS zone |
95
+ | `list_records(zone_id)` | `GET /api/v1/dns/zones/{zoneId}/records` | List records of a zone |
96
+ | `create_record(zone_id, body)` | `POST /api/v1/dns/zones/{zoneId}/records` | Create a DNS record |
97
+ | `get_record(zone_id, record_id)` | `GET /api/v1/dns/zones/{zoneId}/records/{recordId}` | Get a DNS record |
98
+ | `update_record(zone_id, record_id, body)` | `PATCH /api/v1/dns/zones/{zoneId}/records/{recordId}` | Update a DNS record |
99
+ | `delete_record(zone_id, record_id)` | `DELETE /api/v1/dns/zones/{zoneId}/records/{recordId}` | Delete a DNS record |
100
+ | `get_nameservers(domain_name)` | `GET /api/v1/domain/{domainName}/nameservers` | Get domain nameservers |
101
+ | `set_nameservers(domain_name, body)` | `PUT /api/v1/domain/{domainName}/nameservers` | Replace domain nameservers |
102
+ | `get_dnssec(domain_name)` | `GET /api/v1/domain/{domainName}/dnssec` | Get DNSSEC for a domain |
103
+ | `set_dnssec(domain_name, body)` | `POST /api/v1/domain/{domainName}/dnssec` | Set DNSSEC (DS record) for a domain |
104
+ | `delete_dnssec(domain_name)` | `DELETE /api/v1/domain/{domainName}/dnssec` | Remove DNSSEC from a domain |
105
+ | `list_glue_records(domain_name)` | `GET /api/v1/domain/{domainName}/glue-records` | List glue records |
106
+ | `create_glue_record(domain_name, body)` | `POST /api/v1/domain/{domainName}/glue-records` | Create a glue record |
107
+ | `delete_glue_record(domain_name, glue_record_id)` | `DELETE /api/v1/domain/{domainName}/glue-records/{glueRecordId}` | Delete a glue record |
108
+
109
+ ## Add-ons: `client.addons`
110
+
111
+ | Method | HTTP | Summary |
112
+ |---|---|---|
113
+ | `get_fees(query={...})` | `GET /api/v1/addons/fees` | Get add-on fees |
114
+ | `list_for_domain(domain_name)` | `GET /api/v1/domain/{domainName}/addons` | List the add-ons of a domain |
115
+
116
+ ## URL Forwarding: `client.url_forwarding`
117
+
118
+ | Method | HTTP | Summary |
119
+ |---|---|---|
120
+ | `list_rules(query={...})` | `GET /api/v1/forward/rules` | List URL forwarding rules (**page**) |
121
+ | `create_rule(body)` | `POST /api/v1/forward/rules` | Create a URL forwarding rule |
122
+ | `get_rule(id)` | `GET /api/v1/forward/rules/{id}` | Get a URL forwarding rule |
123
+ | `update_rule(id, body)` | `PATCH /api/v1/forward/rules/{id}` | Update a URL forwarding rule |
124
+ | `delete_rule(id)` | `DELETE /api/v1/forward/rules/{id}` | Delete a URL forwarding rule |
125
+ | `list_rules_for_domain(domain_name)` | `GET /api/v1/forward/rules/domain/{domainName}` | List forwarding rules for a domain and its subdomains |
126
+ | `recheck_rule_dns(id)` | `POST /api/v1/forward/rules/{id}/dns-check` | Recheck the DNS of a forwarding rule |
127
+ | `list_templates(query={...})` | `GET /api/v1/forward/templates` | List forwarding page templates (**page**) |
128
+ | `create_template(body)` | `POST /api/v1/forward/templates` | Create a forwarding page template |
129
+ | `get_template(id)` | `GET /api/v1/forward/templates/{id}` | Get a forwarding page template |
130
+ | `update_template(id, body)` | `PATCH /api/v1/forward/templates/{id}` | Update a forwarding page template |
131
+ | `delete_template(id)` | `DELETE /api/v1/forward/templates/{id}` | Delete a forwarding page template |
132
+
133
+ ## Email Forwarding: `client.email_forwarding`
134
+
135
+ | Method | HTTP | Summary |
136
+ |---|---|---|
137
+ | `list_domains(query={...})` | `GET /api/v1/email-forward/domains` | List email forwarding domains (**page**) |
138
+ | `create_domain(body)` | `POST /api/v1/email-forward/domains` | Enable email forwarding for a domain |
139
+ | `get_domain(id)` | `GET /api/v1/email-forward/domains/{id}` | Get an email forwarding domain |
140
+ | `update_domain(id, body)` | `PATCH /api/v1/email-forward/domains/{id}` | Update email forwarding domain settings |
141
+ | `delete_domain(id)` | `DELETE /api/v1/email-forward/domains/{id}` | Disable email forwarding for a domain |
142
+ | `recheck_domain_dns(id)` | `POST /api/v1/email-forward/domains/{id}/dns-check` | Recheck the MX of an email forwarding domain |
143
+ | `list_rules(query={...})` | `GET /api/v1/email-forward/rules` | List email forwarding addresses (**page**) |
144
+ | `create_rule(body)` | `POST /api/v1/email-forward/rules` | Create an email forwarding address |
145
+ | `get_rule(id)` | `GET /api/v1/email-forward/rules/{id}` | Get an email forwarding address |
146
+ | `update_rule(id, body)` | `PATCH /api/v1/email-forward/rules/{id}` | Update an email forwarding address |
147
+ | `delete_rule(id)` | `DELETE /api/v1/email-forward/rules/{id}` | Delete an email forwarding address |
148
+ | `list_rules_for_domain(domain_id, query={...})` | `GET /api/v1/email-forward/rules/by-domain/{domainId}` | List email forwarding addresses of a domain (**page**) |
149
+ | `get_stats()` | `GET /api/v1/email-forward/stats` | Get email forwarding statistics |
150
+ | `list_logs(query={...})` | `GET /api/v1/email-forward/logs` | List email forwarding logs (**page**) |
151
+
152
+ ## Events: `client.events`
153
+
154
+ | Method | HTTP | Summary |
155
+ |---|---|---|
156
+ | `list(query={...})` | `GET /api/v1/events` | List events (**page**) |
157
+ | `get(id)` | `GET /api/v1/events/{id}` | Get an event |
158
+ | `acknowledge(id)` | `PATCH /api/v1/events/{id}` | Acknowledge an event |
159
+ | `acknowledge_many(body)` | `POST /api/v1/events/ack` | Acknowledge events in bulk |
160
+
161
+ ## Bulk Jobs: `client.jobs`
162
+
163
+ | Method | HTTP | Summary |
164
+ |---|---|---|
165
+ | `create(body)` | `POST /api/v1/jobs` | Create a batch of asynchronous jobs |
166
+ | `list(query={...})` | `GET /api/v1/jobs` | List job batches (**page**) |
167
+ | `get(batch_id)` | `GET /api/v1/jobs/{batchId}` | Get a job batch |
168
+ | `list_items(batch_id, query={...})` | `GET /api/v1/jobs/{batchId}/items` | List the jobs of a batch (**page**) |
169
+ | `cancel(batch_id)` | `POST /api/v1/jobs/{batchId}/cancel` | Cancel the queued jobs of a batch |
170
+ | `retry(batch_id, body=None)` | `POST /api/v1/jobs/{batchId}/retry` | Retry the failed jobs of a batch |
171
+
172
+ ## Transactions: `client.transactions`
173
+
174
+ | Method | HTTP | Summary |
175
+ |---|---|---|
176
+ | `list(query={...})` | `GET /api/v1/transactions` | List balance transactions (**page**) |
177
+ | `summary(query={...})` | `GET /api/v1/transactions/summary` | Summarize balance transactions |
178
+ | `get(id)` | `GET /api/v1/transactions/{id}` | Get a balance transaction |
179
+ | `list_refundable()` | `GET /api/v1/transactions/refundable/list` | List refundable charge transactions |
180
+
181
+ ## Statistics: `client.statistics`
182
+
183
+ | Method | HTTP | Summary |
184
+ |---|---|---|
185
+ | `get(query={...})` | `GET /api/v1/statistics` | Get domain operation counts |
@@ -0,0 +1,391 @@
1
+ Metadata-Version: 2.5
2
+ Name: leto-domain-api
3
+ Version: 1.0.0
4
+ Summary: Python client for the LETO Domain API (domain registration, DNS, transfers and more for LETO partners).
5
+ Project-URL: Homepage, https://partners.leto.kr/docs
6
+ Project-URL: Documentation, https://partners.leto.kr/docs
7
+ Project-URL: Changelog, https://github.com/Feather-IT/leto-domain-sdk-python/blob/main/CHANGELOG.md
8
+ Author: Feather IT Inc.
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: api,dns,domain,leto,registrar,reseller,sdk
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Internet :: Name Service (DNS)
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: httpx<1,>=0.27
26
+ Requires-Dist: typing-extensions>=4.7
27
+ Description-Content-Type: text/markdown
28
+
29
+ # LETO Domain API for Python
30
+
31
+ Python client for the [LETO Domain API](https://partners.leto.kr/docs): register, renew and
32
+ transfer domains, manage DNS, contacts, forwarding and more from your own platform, billed to
33
+ your LETO partner balance.
34
+
35
+ - Every API operation as a typed method (`client.domains.register(...)`), generated from the
36
+ API's OpenAPI document. See [OPERATIONS.md](OPERATIONS.md) for the full list.
37
+ - A synchronous client (`LetoClient`) and an asyncio client (`AsyncLetoClient`) with the same
38
+ methods.
39
+ - Errors as exceptions with the API's stable error `code`.
40
+ - Safe retries, automatic `Idempotency-Key` on requests that charge your balance.
41
+ - Page iteration over every list endpoint.
42
+ - `TypedDict` request and response shapes for mypy, pyright and your editor (`py.typed`).
43
+
44
+ ## Requirements
45
+
46
+ - Python 3.10 or later
47
+ - [httpx](https://www.python-httpx.org) 0.27 or later (installed with the package)
48
+
49
+ ## Installation
50
+
51
+ ```bash
52
+ pip install leto-domain-api
53
+ ```
54
+
55
+ ## Quick start
56
+
57
+ Create an API key in the partner console (it starts with `leto_sk_`). Keep it on the server.
58
+
59
+ ```python
60
+ import os
61
+
62
+ from leto_domain_api import LetoClient
63
+
64
+ client = LetoClient(os.environ["LETO_API_KEY"])
65
+
66
+ status = client.account.get_status()
67
+ print(status["balance"]["amount"], status["balance"]["currency"])
68
+ ```
69
+
70
+ Responses are the decoded JSON bodies (plain dicts), as documented in the API reference. Most
71
+ have the standard envelope `{ code, message, data, timestamp, success }`; the result is in
72
+ `data`.
73
+
74
+ The client keeps a connection pool. Create one, reuse it, and close it when you are done
75
+ (`client.close()`, or `with LetoClient(...) as client:`).
76
+
77
+ ### Method arguments
78
+
79
+ ```
80
+ method(path parameters..., required query parameters..., body, *, query=None, options=None)
81
+ ```
82
+
83
+ Path parameters, required query parameters and the body are positional, in that order. Optional
84
+ query parameters go in the `query` dict, with the parameter names of the API reference
85
+ (`{"size": 100}`). `options` is a `RequestOptions` for that one call.
86
+
87
+ ### Async
88
+
89
+ `AsyncLetoClient` has the same resources and methods as coroutines.
90
+
91
+ ```python
92
+ import asyncio
93
+ import os
94
+
95
+ from leto_domain_api import AsyncLetoClient
96
+
97
+
98
+ async def main() -> None:
99
+ async with AsyncLetoClient(os.environ["LETO_API_KEY"]) as client:
100
+ status = await client.account.get_status()
101
+ print(status["balance"]["amount"], status["balance"]["currency"])
102
+
103
+ page = await client.domains.list(query={"size": 100})
104
+ async for domain in page.auto_paginate():
105
+ print(domain["domainName"])
106
+
107
+
108
+ asyncio.run(main())
109
+ ```
110
+
111
+ ### TLD prices
112
+
113
+ ```python
114
+ # One TLD
115
+ com = client.pricing.get_tld("com")["data"][0]
116
+ print(com["prices"]["registration"], com["currency"])
117
+
118
+ # Every TLD, loading the pages as you go
119
+ for tld in client.pricing.list_tlds(query={"size": 100}).auto_paginate():
120
+ print(tld["tld"], tld["prices"]["registration"], tld["currency"])
121
+ ```
122
+
123
+ ### Quote, then register at that price
124
+
125
+ Prices can change (a promotion ends, a price list is updated). Get a quote, show it, and send
126
+ its `total` as `expectedPrice`. If the price changed in the meantime, the API refuses the order
127
+ with `PRICE_CHANGED` and charges nothing.
128
+
129
+ ```python
130
+ from leto_domain_api import RequestOptions
131
+
132
+ if client.domains.check("example.com")["data"]["available"]:
133
+ quote = client.pricing.quote("example.com", query={"period": 1})["data"]
134
+ # Show quote["total"] and quote["currency"] to your customer, then:
135
+
136
+ result = client.domains.register(
137
+ {
138
+ "domain": "example.com",
139
+ "period": 1,
140
+ "contact": {"registrant": contact_id, "administrative": contact_id},
141
+ "nameservers": ["ns1.example.net", "ns2.example.net"],
142
+ "expectedPrice": quote["total"],
143
+ },
144
+ options=RequestOptions(idempotency_key=order.idempotency_key),
145
+ )
146
+ print("Expires", result["data"]["expiresAt"])
147
+ ```
148
+
149
+ The same in one call, with an optional check before anything is charged:
150
+
151
+ ```python
152
+ result = client.domains.register_with_quote(
153
+ body, # the register() body without expectedPrice
154
+ lambda quote: quote["total"] <= max_price,
155
+ )
156
+ ```
157
+
158
+ `renew_with_quote(domain_name, body)` and `client.transfers.initiate_with_quote(body)` work the
159
+ same way. When the callback does not return `True`, `QuoteDeclinedError` is raised and nothing
160
+ is charged. On the async client the callback may also be a coroutine function.
161
+
162
+ Contacts are created first with `client.contacts.create({...})`; use the `id` from the response
163
+ as `registrant` and `administrative`.
164
+
165
+ ### Errors
166
+
167
+ Every API error is a `LetoApiError`. Branch on `e.error_code` (stable, only ever added to), not
168
+ on the message. Common cases have their own subclasses.
169
+
170
+ ```python
171
+ from leto_domain_api import (
172
+ ApiConnectionError,
173
+ InsufficientBalanceError,
174
+ LetoApiError,
175
+ NotFoundError,
176
+ PriceChangedError,
177
+ )
178
+
179
+ try:
180
+ client.domains.renew("example.com", {"period": 1, "expectedPrice": 10.99})
181
+ except PriceChangedError as e:
182
+ # Nothing was charged. Ask again with the new price.
183
+ print(f"Now {e.actual} {e.currency} instead of {e.expected}")
184
+ except InsufficientBalanceError:
185
+ print("Top up your balance")
186
+ except NotFoundError:
187
+ print("No such domain in your account")
188
+ except LetoApiError as e:
189
+ # e.http_status, e.error_code, e.message, e.data, e.extra
190
+ print(f"{e.error_code}: {e.message} (request {e.request_id})")
191
+ except ApiConnectionError as e:
192
+ # The API could not be reached. For a charging request the outcome is unknown:
193
+ # send it again later with the same key (e.idempotency_key).
194
+ ...
195
+ ```
196
+
197
+ #### When a registry call fails or times out
198
+
199
+ A charging request (registration, renewal, restore, transfer) can fail with a `ServerError`
200
+ whose `error_code` is `API_TIMEOUT` (504), `NETWORK_ERROR` or `REGISTRY_CONNECTION_FAILED` (502).
201
+ Your balance was not charged, but the registry may still have carried out the request. The SDK
202
+ does not resend these requests by itself; sending one again is your call, and it is safe:
203
+
204
+ - Registration, restore and transfer: the registry refuses a second request for the same domain,
205
+ so a request that already went through fails instead of being applied twice.
206
+ - Renewal: the next renewal of the same domain (within 7 days) first reads the registry expiry
207
+ date. If the earlier renewal was applied, the API does not renew again; it records the earlier
208
+ renewal, charges it once and returns the registry expiry date. Send the same `period`, otherwise
209
+ the API answers 409 `OPERATION_NOT_ALLOWED`. If the registry cannot be read, you get 502 and
210
+ nothing is charged; try again later.
211
+
212
+ Use the same Idempotency-Key when you send it again.
213
+
214
+ | Exception | When |
215
+ |---|---|
216
+ | `BadRequestError` | 400, 422 (`ValidationError` for `VALIDATION_FAILED` with `fields`, `IdempotencyKeyReusedError`) |
217
+ | `AuthenticationError` | 401: missing, wrong or revoked API key |
218
+ | `InsufficientBalanceError` | `BALANCE_INSUFFICIENT`, `BALANCE_NEGATIVE`, `TRANSFER_INSUFFICIENT_BALANCE` |
219
+ | `PermissionDeniedError` | 403 (`IpNotAllowedError` for `IP_NOT_ALLOWED`) |
220
+ | `NotFoundError` | 404 |
221
+ | `ConflictError` | 409 (`PriceChangedError`, `IdempotencyInProgressError`) |
222
+ | `RateLimitError` | 429, with `retry_after` |
223
+ | `ServerError` | 5xx except 501 |
224
+ | `ApiConnectionError` | no response (DNS, TLS, connection, timeout) |
225
+ | `UnexpectedResponseError` | a 2xx response without a JSON body |
226
+ | `InvalidArgumentError` | an argument the SDK refuses before sending (also a `ValueError`) |
227
+
228
+ All of them inherit from `LetoError`. `e.request_id` is the `X-Request-Id` of the response;
229
+ quote it when you contact LETO about a failed call.
230
+
231
+ ### Pages
232
+
233
+ List methods return a `Page` (`AsyncPage` on the async client). Iterate it for the items of
234
+ that page, or call `auto_paginate()` for every item of every page (the next page is loaded only
235
+ when you get there).
236
+
237
+ ```python
238
+ page = client.domains.list(query={"status": ["active", "expired"], "size": 100})
239
+ print(page.total, "domains")
240
+
241
+ for domain in page.auto_paginate():
242
+ print(domain["domainName"], domain["expiresAt"]["date"])
243
+
244
+ # GET /transactions keeps its items in data.transactions; the Page handles that.
245
+ for tx in client.transactions.list(query={"type": "charge", "limit": 100}).auto_paginate():
246
+ print(tx["createdAt"], tx["amount"], tx["currency"])
247
+ ```
248
+
249
+ `page.items`, `page.body`, `page.pagination`, `page.total`, `page.has_next_page()`,
250
+ `page.next_page()` and `page.pages()` are there when you need them.
251
+
252
+ ### Idempotency
253
+
254
+ Registration, renewal, restore and transfer charge your balance. The SDK sends an
255
+ `Idempotency-Key` with each of these calls (a new UUID unless you pass one), so it can retry them
256
+ after a lost connection without charging twice. A request with the same key within 24 hours
257
+ returns the first successful result.
258
+
259
+ When a retry might happen in another process (a queue worker, a crash, the next cron run),
260
+ create the key yourself and store it with your order before calling:
261
+
262
+ ```python
263
+ from leto_domain_api import RequestOptions, generate_idempotency_key
264
+
265
+ order.idempotency_key = order.idempotency_key or generate_idempotency_key() # save the order here
266
+ client.domains.renew("example.com", {"period": 1}, options=RequestOptions(idempotency_key=order.idempotency_key))
267
+
268
+ client.last_response.replayed # True when the API returned the stored first result
269
+ ```
270
+
271
+ Other endpoints do not accept a key; passing one raises `InvalidArgumentError`.
272
+
273
+ ### Retries and timeouts
274
+
275
+ Up to 2 retries by default. The SDK waits as long as `Retry-After` says (up to `max_retry_after`
276
+ seconds) or backs off exponentially (about 0.5 s, 1 s, 2 s).
277
+
278
+ - GET requests: connection errors, 429, 502, 503 and 504.
279
+ - Requests with an Idempotency-Key: connection errors, 429, 503, 409
280
+ `IDEMPOTENCY_REQUEST_IN_PROGRESS`, and 502 or 504 pages from a proxy in front of the API. A
281
+ 502 or 504 error from the API itself is not retried (see "When a registry call fails or times
282
+ out").
283
+ - Other requests are never retried automatically.
284
+
285
+ ```python
286
+ client = LetoClient(
287
+ api_key,
288
+ timeout=30, # seconds per network operation, default 60 (connect at most 10)
289
+ max_retries=3, # default 2, 0 turns retries off
290
+ max_retry_after=30, # longest Retry-After to wait for, default 60
291
+ user_agent_suffix="my-panel/2.1",
292
+ )
293
+
294
+ # Per call
295
+ client.domains.get("example.com", options=RequestOptions(max_retries=0))
296
+ ```
297
+
298
+ `timeout` also accepts an `httpx.Timeout` when you want separate connect, read, write and pool
299
+ limits.
300
+
301
+ ### Your own HTTP client
302
+
303
+ Pass an `httpx.Client` (an `httpx.AsyncClient` for `AsyncLetoClient`) to use your own proxies,
304
+ certificates, transport or event hooks. Its timeouts apply unless you also pass `timeout`. The
305
+ SDK does not close a client you passed in.
306
+
307
+ ```python
308
+ import httpx
309
+
310
+ client = LetoClient(api_key, http_client=httpx.Client(proxy="http://proxy.internal:3128"))
311
+ ```
312
+
313
+ ### Type checking
314
+
315
+ The package ships type information (`py.typed`). Every method declares the `TypedDict` it takes
316
+ and returns (in `leto_domain_api.types`), so mypy, pyright and your editor know the keys:
317
+
318
+ ```python
319
+ status = client.account.get_status()
320
+ status["balance"]["amout"] # mypy: TypedDict "AccountBalanceDto" has no key "amout"
321
+ ```
322
+
323
+ ```python
324
+ from leto_domain_api.types import CreateDomainDto
325
+
326
+ body: CreateDomainDto = {"domain": "example.com", "period": 1, "contact": {...}}
327
+ ```
328
+
329
+ Enum values are `Literal` types in requests and plain `str` in responses, because the API may
330
+ add values. At runtime the values are ordinary dicts; fields the API adds later pass through.
331
+
332
+ ### Request details
333
+
334
+ ```python
335
+ info = client.last_response
336
+ info.status_code # 200
337
+ info.request_id # X-Request-Id
338
+ info.idempotency_key # key sent with the last request, if any
339
+ info.attempts # 1, or more after retries
340
+ ```
341
+
342
+ With concurrent calls on one `AsyncLetoClient`, `last_response` is whichever response arrived
343
+ last. Every `LetoApiError` carries its own `e.response`.
344
+
345
+ ## Versioning
346
+
347
+ The SDK follows [semantic versioning](https://semver.org). The API itself only changes in
348
+ backward compatible ways; new endpoints and fields arrive in minor SDK releases.
349
+ `leto_domain_api.version.API` is the API document version the release was built from, and
350
+ `leto_domain_api.__version__` the version of the package.
351
+
352
+ ## License
353
+
354
+ MIT. See [LICENSE](LICENSE).
355
+
356
+ ---
357
+
358
+ ## 한국어 안내
359
+
360
+ LETO 도메인 도매 API 의 Python SDK 입니다. Python 3.10 이상에서 동작하고, HTTP 클라이언트로
361
+ httpx 를 씁니다. 동기(`LetoClient`)와 asyncio(`AsyncLetoClient`) 클라이언트가 같은 메서드를
362
+ 갖습니다.
363
+
364
+ ```bash
365
+ pip install leto-domain-api
366
+ ```
367
+
368
+ ```python
369
+ from leto_domain_api import LetoClient
370
+
371
+ client = LetoClient(os.environ["LETO_API_KEY"])
372
+ status = client.account.get_status() # 잔액·통화
373
+ page = client.domains.list(query={"size": 100}) # 목록은 Page, auto_paginate() 로 전체 순회
374
+ ```
375
+
376
+ - API 키는 파트너 콘솔에서 발급하며 `Authorization: Bearer` 로 보냅니다. 서버에만 두세요.
377
+ - 오류는 `LetoApiError` 로 던집니다. 분기는 메시지가 아니라 `e.error_code` 로 합니다. 문의할
378
+ 때는 `e.request_id`(X-Request-Id)를 함께 알려 주세요.
379
+ - 등록·갱신·복원·이전 요청에는 `Idempotency-Key` 를 자동으로 붙이고, 연결 오류·429·503 에서
380
+ 같은 키로 다시 보냅니다. 다른 프로세스에서 다시 시도할 수 있다면 키를 직접 만들어 주문과 함께
381
+ 저장해 두세요(`generate_idempotency_key()`).
382
+ - 이 요청이 `API_TIMEOUT`(504)이나 `NETWORK_ERROR`·`REGISTRY_CONNECTION_FAILED`(502)로 실패하면
383
+ 잔액은 차감되지 않았지만 레지스트리에서는 처리됐을 수 있습니다. SDK 는 저절로 다시 보내지 않지만,
384
+ 같은 키로 다시 보내도 안전합니다. 등록·복원·이전은 레지스트리가 두 번째 요청을 거절하고, 갱신은
385
+ API 가 레지스트리 만료일을 먼저 확인해 이미 갱신됐으면 다시 갱신하지 않고 한 번만 기록·과금합니다
386
+ (같은 `period` 로 보내야 하며, 다르면 409).
387
+ - 가격이 바뀌는 사이에 결제되지 않게 하려면 견적의 `total` 을 `expectedPrice` 로 보내거나
388
+ `register_with_quote()` 를 쓰세요. 가격이 달라졌으면 `PriceChangedError` 가 나고 차감되지
389
+ 않습니다.
390
+ - 전체 메서드 목록은 [OPERATIONS.md](OPERATIONS.md), API 문서는 https://partners.leto.kr/docs 에
391
+ 있습니다.