billkit-sdk 0.0.6__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 (149) hide show
  1. billkit_sdk-0.0.6/LICENSE +21 -0
  2. billkit_sdk-0.0.6/PKG-INFO +212 -0
  3. billkit_sdk-0.0.6/README.md +178 -0
  4. billkit_sdk-0.0.6/pyproject.toml +98 -0
  5. billkit_sdk-0.0.6/src/billkit/__init__.py +329 -0
  6. billkit_sdk-0.0.6/src/billkit/_default_clients.py +30 -0
  7. billkit_sdk-0.0.6/src/billkit/addons/__init__.py +4 -0
  8. billkit_sdk-0.0.6/src/billkit/addons/client.py +245 -0
  9. billkit_sdk-0.0.6/src/billkit/addons/raw_client.py +446 -0
  10. billkit_sdk-0.0.6/src/billkit/api_keys/__init__.py +4 -0
  11. billkit_sdk-0.0.6/src/billkit/api_keys/client.py +342 -0
  12. billkit_sdk-0.0.6/src/billkit/api_keys/raw_client.py +643 -0
  13. billkit_sdk-0.0.6/src/billkit/assignments/__init__.py +4 -0
  14. billkit_sdk-0.0.6/src/billkit/assignments/client.py +231 -0
  15. billkit_sdk-0.0.6/src/billkit/assignments/raw_client.py +414 -0
  16. billkit_sdk-0.0.6/src/billkit/billing/__init__.py +4 -0
  17. billkit_sdk-0.0.6/src/billkit/billing/client.py +409 -0
  18. billkit_sdk-0.0.6/src/billkit/billing/raw_client.py +729 -0
  19. billkit_sdk-0.0.6/src/billkit/client.py +409 -0
  20. billkit_sdk-0.0.6/src/billkit/contracts/__init__.py +4 -0
  21. billkit_sdk-0.0.6/src/billkit/contracts/client.py +235 -0
  22. billkit_sdk-0.0.6/src/billkit/contracts/raw_client.py +440 -0
  23. billkit_sdk-0.0.6/src/billkit/core/__init__.py +127 -0
  24. billkit_sdk-0.0.6/src/billkit/core/api_error.py +23 -0
  25. billkit_sdk-0.0.6/src/billkit/core/client_wrapper.py +141 -0
  26. billkit_sdk-0.0.6/src/billkit/core/datetime_utils.py +70 -0
  27. billkit_sdk-0.0.6/src/billkit/core/file.py +67 -0
  28. billkit_sdk-0.0.6/src/billkit/core/force_multipart.py +18 -0
  29. billkit_sdk-0.0.6/src/billkit/core/http_client.py +940 -0
  30. billkit_sdk-0.0.6/src/billkit/core/http_response.py +59 -0
  31. billkit_sdk-0.0.6/src/billkit/core/http_sse/__init__.py +42 -0
  32. billkit_sdk-0.0.6/src/billkit/core/http_sse/_api.py +455 -0
  33. billkit_sdk-0.0.6/src/billkit/core/http_sse/_decoders.py +74 -0
  34. billkit_sdk-0.0.6/src/billkit/core/http_sse/_exceptions.py +7 -0
  35. billkit_sdk-0.0.6/src/billkit/core/http_sse/_models.py +17 -0
  36. billkit_sdk-0.0.6/src/billkit/core/jsonable_encoder.py +133 -0
  37. billkit_sdk-0.0.6/src/billkit/core/logging.py +107 -0
  38. billkit_sdk-0.0.6/src/billkit/core/parse_error.py +36 -0
  39. billkit_sdk-0.0.6/src/billkit/core/pydantic_utilities.py +508 -0
  40. billkit_sdk-0.0.6/src/billkit/core/query_encoder.py +58 -0
  41. billkit_sdk-0.0.6/src/billkit/core/remove_none_from_dict.py +11 -0
  42. billkit_sdk-0.0.6/src/billkit/core/request_options.py +40 -0
  43. billkit_sdk-0.0.6/src/billkit/core/serialization.py +347 -0
  44. billkit_sdk-0.0.6/src/billkit/entitlements/__init__.py +4 -0
  45. billkit_sdk-0.0.6/src/billkit/entitlements/client.py +143 -0
  46. billkit_sdk-0.0.6/src/billkit/entitlements/raw_client.py +307 -0
  47. billkit_sdk-0.0.6/src/billkit/errors/__init__.py +68 -0
  48. billkit_sdk-0.0.6/src/billkit/errors/bad_gateway_error.py +10 -0
  49. billkit_sdk-0.0.6/src/billkit/errors/bad_request_error.py +10 -0
  50. billkit_sdk-0.0.6/src/billkit/errors/conflict_error.py +10 -0
  51. billkit_sdk-0.0.6/src/billkit/errors/forbidden_error.py +10 -0
  52. billkit_sdk-0.0.6/src/billkit/errors/internal_server_error.py +10 -0
  53. billkit_sdk-0.0.6/src/billkit/errors/not_found_error.py +10 -0
  54. billkit_sdk-0.0.6/src/billkit/errors/payment_required_error.py +10 -0
  55. billkit_sdk-0.0.6/src/billkit/errors/service_unavailable_error.py +10 -0
  56. billkit_sdk-0.0.6/src/billkit/errors/too_many_requests_error.py +10 -0
  57. billkit_sdk-0.0.6/src/billkit/errors/unauthorized_error.py +10 -0
  58. billkit_sdk-0.0.6/src/billkit/errors/unprocessable_entity_error.py +10 -0
  59. billkit_sdk-0.0.6/src/billkit/invoices/__init__.py +4 -0
  60. billkit_sdk-0.0.6/src/billkit/invoices/client.py +552 -0
  61. billkit_sdk-0.0.6/src/billkit/invoices/raw_client.py +925 -0
  62. billkit_sdk-0.0.6/src/billkit/pricing/__init__.py +4 -0
  63. billkit_sdk-0.0.6/src/billkit/pricing/client.py +120 -0
  64. billkit_sdk-0.0.6/src/billkit/pricing/raw_client.py +188 -0
  65. billkit_sdk-0.0.6/src/billkit/py.typed +0 -0
  66. billkit_sdk-0.0.6/src/billkit/schema/__init__.py +34 -0
  67. billkit_sdk-0.0.6/src/billkit/schema/client.py +352 -0
  68. billkit_sdk-0.0.6/src/billkit/schema/raw_client.py +607 -0
  69. billkit_sdk-0.0.6/src/billkit/schema/types/__init__.py +38 -0
  70. billkit_sdk-0.0.6/src/billkit/schema/types/get_schema_request_format.py +5 -0
  71. billkit_sdk-0.0.6/src/billkit/schema/types/validate_schema_request_format.py +5 -0
  72. billkit_sdk-0.0.6/src/billkit/subjects/__init__.py +4 -0
  73. billkit_sdk-0.0.6/src/billkit/subjects/client.py +469 -0
  74. billkit_sdk-0.0.6/src/billkit/subjects/raw_client.py +796 -0
  75. billkit_sdk-0.0.6/src/billkit/tenants/__init__.py +4 -0
  76. billkit_sdk-0.0.6/src/billkit/tenants/client.py +130 -0
  77. billkit_sdk-0.0.6/src/billkit/tenants/raw_client.py +200 -0
  78. billkit_sdk-0.0.6/src/billkit/types/__init__.py +236 -0
  79. billkit_sdk-0.0.6/src/billkit/types/addon_definition.py +26 -0
  80. billkit_sdk-0.0.6/src/billkit/types/addon_type.py +5 -0
  81. billkit_sdk-0.0.6/src/billkit/types/apply_contract_response.py +24 -0
  82. billkit_sdk-0.0.6/src/billkit/types/attach_addon_response.py +25 -0
  83. billkit_sdk-0.0.6/src/billkit/types/attribute_data_type.py +5 -0
  84. billkit_sdk-0.0.6/src/billkit/types/batch_register_response.py +24 -0
  85. billkit_sdk-0.0.6/src/billkit/types/batch_subject_result.py +26 -0
  86. billkit_sdk-0.0.6/src/billkit/types/billing_config.py +47 -0
  87. billkit_sdk-0.0.6/src/billkit/types/billing_cycle.py +5 -0
  88. billkit_sdk-0.0.6/src/billkit/types/cadence.py +5 -0
  89. billkit_sdk-0.0.6/src/billkit/types/change_plan_response.py +51 -0
  90. billkit_sdk-0.0.6/src/billkit/types/contract_definition.py +25 -0
  91. billkit_sdk-0.0.6/src/billkit/types/create_assignment_response.py +25 -0
  92. billkit_sdk-0.0.6/src/billkit/types/create_key_response.py +28 -0
  93. billkit_sdk-0.0.6/src/billkit/types/create_portal_token_response.py +36 -0
  94. billkit_sdk-0.0.6/src/billkit/types/decision.py +5 -0
  95. billkit_sdk-0.0.6/src/billkit/types/feature_definition.py +26 -0
  96. billkit_sdk-0.0.6/src/billkit/types/feature_type.py +5 -0
  97. billkit_sdk-0.0.6/src/billkit/types/feature_usage.py +63 -0
  98. billkit_sdk-0.0.6/src/billkit/types/feature_value.py +27 -0
  99. billkit_sdk-0.0.6/src/billkit/types/gate_response.py +27 -0
  100. billkit_sdk-0.0.6/src/billkit/types/invoice_failure_item.py +30 -0
  101. billkit_sdk-0.0.6/src/billkit/types/invoice_line_item_response.py +24 -0
  102. billkit_sdk-0.0.6/src/billkit/types/invoice_list_item.py +34 -0
  103. billkit_sdk-0.0.6/src/billkit/types/invoice_preview_response.py +31 -0
  104. billkit_sdk-0.0.6/src/billkit/types/key_list_item.py +31 -0
  105. billkit_sdk-0.0.6/src/billkit/types/limit.py +7 -0
  106. billkit_sdk-0.0.6/src/billkit/types/limit_definition.py +29 -0
  107. billkit_sdk-0.0.6/src/billkit/types/limit_one.py +5 -0
  108. billkit_sdk-0.0.6/src/billkit/types/list_invoice_failures_params.py +42 -0
  109. billkit_sdk-0.0.6/src/billkit/types/list_invoice_failures_response.py +33 -0
  110. billkit_sdk-0.0.6/src/billkit/types/list_invoices_params.py +54 -0
  111. billkit_sdk-0.0.6/src/billkit/types/list_invoices_response.py +33 -0
  112. billkit_sdk-0.0.6/src/billkit/types/list_keys_response.py +24 -0
  113. billkit_sdk-0.0.6/src/billkit/types/list_platform_invoices_response.py +27 -0
  114. billkit_sdk-0.0.6/src/billkit/types/monthly_revenue.py +41 -0
  115. billkit_sdk-0.0.6/src/billkit/types/overage_info.py +24 -0
  116. billkit_sdk-0.0.6/src/billkit/types/overage_policy.py +5 -0
  117. billkit_sdk-0.0.6/src/billkit/types/pagination_query.py +31 -0
  118. billkit_sdk-0.0.6/src/billkit/types/plan_definition.py +29 -0
  119. billkit_sdk-0.0.6/src/billkit/types/platform_invoice_item.py +46 -0
  120. billkit_sdk-0.0.6/src/billkit/types/portal_list_invoices_response.py +33 -0
  121. billkit_sdk-0.0.6/src/billkit/types/preview_overage_item.py +28 -0
  122. billkit_sdk-0.0.6/src/billkit/types/pricing_billing.py +24 -0
  123. billkit_sdk-0.0.6/src/billkit/types/pricing_feature.py +25 -0
  124. billkit_sdk-0.0.6/src/billkit/types/pricing_metadata.py +24 -0
  125. billkit_sdk-0.0.6/src/billkit/types/pricing_plan.py +28 -0
  126. billkit_sdk-0.0.6/src/billkit/types/pricing_response.py +32 -0
  127. billkit_sdk-0.0.6/src/billkit/types/rate_card_dimension.py +29 -0
  128. billkit_sdk-0.0.6/src/billkit/types/rate_card_response.py +24 -0
  129. billkit_sdk-0.0.6/src/billkit/types/register_subject_request.py +38 -0
  130. billkit_sdk-0.0.6/src/billkit/types/register_subject_response.py +28 -0
  131. billkit_sdk-0.0.6/src/billkit/types/revenue_response.py +43 -0
  132. billkit_sdk-0.0.6/src/billkit/types/revoke_key_response.py +23 -0
  133. billkit_sdk-0.0.6/src/billkit/types/rotate_key_response.py +24 -0
  134. billkit_sdk-0.0.6/src/billkit/types/schema_document.py +34 -0
  135. billkit_sdk-0.0.6/src/billkit/types/schema_format.py +5 -0
  136. billkit_sdk-0.0.6/src/billkit/types/set_usage_rejection.py +46 -0
  137. billkit_sdk-0.0.6/src/billkit/types/set_usage_response.py +41 -0
  138. billkit_sdk-0.0.6/src/billkit/types/subject_detail_response.py +32 -0
  139. billkit_sdk-0.0.6/src/billkit/types/subject_info.py +27 -0
  140. billkit_sdk-0.0.6/src/billkit/types/subjects_response.py +34 -0
  141. billkit_sdk-0.0.6/src/billkit/types/tenant_me_response.py +32 -0
  142. billkit_sdk-0.0.6/src/billkit/types/usage_response.py +39 -0
  143. billkit_sdk-0.0.6/src/billkit/types/validation_error.py +24 -0
  144. billkit_sdk-0.0.6/src/billkit/types/validation_error_response.py +27 -0
  145. billkit_sdk-0.0.6/src/billkit/types/validation_warning.py +24 -0
  146. billkit_sdk-0.0.6/src/billkit/usage/__init__.py +4 -0
  147. billkit_sdk-0.0.6/src/billkit/usage/client.py +252 -0
  148. billkit_sdk-0.0.6/src/billkit/usage/raw_client.py +412 -0
  149. billkit_sdk-0.0.6/src/billkit/version.py +3 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Billkit.
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,212 @@
1
+ Metadata-Version: 2.1
2
+ Name: billkit-sdk
3
+ Version: 0.0.6
4
+ Summary:
5
+ License: MIT
6
+ Requires-Python: >=3.10,<4.0
7
+ Classifier: Intended Audience :: Developers
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: MacOS
10
+ Classifier: Operating System :: Microsoft :: Windows
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Operating System :: POSIX
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
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: Programming Language :: Python :: 3.15
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Typing :: Typed
24
+ Provides-Extra: aiohttp
25
+ Requires-Dist: aiohttp (>=3.14.1,<4) ; (python_version >= "3.10") and (extra == "aiohttp")
26
+ Requires-Dist: httpx (>=0.21.2)
27
+ Requires-Dist: httpx-aiohttp (>=0.1.8,<0.2.0) ; (python_version >= "3.10") and (extra == "aiohttp")
28
+ Requires-Dist: pydantic (>=1.9.2)
29
+ Requires-Dist: pydantic-core (>=2.18.2,<3.0.0)
30
+ Requires-Dist: typing_extensions (>=4.0.0)
31
+ Project-URL: Repository, https://github.com/billkit-io/billkit-python
32
+ Description-Content-Type: text/markdown
33
+
34
+ # Billkit Python Library
35
+
36
+ [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fbillkit-io%2Fbillkit-python)
37
+ [![pypi](https://img.shields.io/pypi/v/billkit-sdk)](https://pypi.python.org/pypi/billkit-sdk)
38
+
39
+ The Billkit Python library provides convenient access to the Billkit APIs from Python.
40
+
41
+ ## Table of Contents
42
+
43
+ - [Installation](#installation)
44
+ - [Reference](#reference)
45
+ - [Usage](#usage)
46
+ - [Async Client](#async-client)
47
+ - [Exception Handling](#exception-handling)
48
+ - [Advanced](#advanced)
49
+ - [Access Raw Response Data](#access-raw-response-data)
50
+ - [Retries](#retries)
51
+ - [Timeouts](#timeouts)
52
+ - [Custom Client](#custom-client)
53
+ - [Contributing](#contributing)
54
+
55
+ ## Installation
56
+
57
+ ```sh
58
+ pip install billkit-sdk
59
+ ```
60
+
61
+ ## Reference
62
+
63
+ A full reference for this library is available [here](https://github.com/billkit-io/billkit-python/blob/HEAD/./reference.md).
64
+
65
+ ## Usage
66
+
67
+ Instantiate and use the client with the following:
68
+
69
+ ```python
70
+ from billkit import BillkitApi
71
+
72
+ client = BillkitApi(
73
+ api_key="<value>",
74
+ base_url="https://yourhost.com/path/to/api",
75
+ )
76
+
77
+ client.addons.attach_addon(
78
+ addon_key="addon_key",
79
+ subject_id="subject_id",
80
+ )
81
+ ```
82
+
83
+ ## Async Client
84
+
85
+ The SDK also exports an `async` client so that you can make non-blocking calls to our API. Note that if you are constructing an Async httpx client class to pass into this client, use `httpx.AsyncClient()` instead of `httpx.Client()` (e.g. for the `httpx_client` parameter of this client).
86
+
87
+ ```python
88
+ import asyncio
89
+
90
+ from billkit import AsyncBillkitApi
91
+
92
+ client = AsyncBillkitApi(
93
+ api_key="<value>",
94
+ base_url="https://yourhost.com/path/to/api",
95
+ )
96
+
97
+
98
+ async def main() -> None:
99
+ await client.addons.attach_addon(
100
+ addon_key="addon_key",
101
+ subject_id="subject_id",
102
+ )
103
+
104
+
105
+ asyncio.run(main())
106
+ ```
107
+
108
+ ## Exception Handling
109
+
110
+ When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
111
+ will be thrown.
112
+
113
+ ```python
114
+ from billkit.core.api_error import ApiError
115
+
116
+ try:
117
+ client.addons.attach_addon(...)
118
+ except ApiError as e:
119
+ print(e.status_code)
120
+ print(e.body)
121
+ ```
122
+
123
+ ## Advanced
124
+
125
+ ### Access Raw Response Data
126
+
127
+ The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
128
+ The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
129
+
130
+ ```python
131
+ from billkit import BillkitApi
132
+
133
+ client = BillkitApi(...)
134
+ response = client.addons.with_raw_response.attach_addon(...)
135
+ print(response.headers) # access the response headers
136
+ print(response.status_code) # access the response status code
137
+ print(response.data) # access the underlying object
138
+ ```
139
+
140
+ ### Retries
141
+
142
+ The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
143
+ as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
144
+ retry limit (default: 2).
145
+
146
+ Which status codes are retried depends on the `retryStatusCodes` generator configuration:
147
+
148
+ **`legacy`** (current default): retries on
149
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
150
+ - [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
151
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
152
+ - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) (All server errors, including 500)
153
+
154
+ **`recommended`**: retries on
155
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
156
+ - [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
157
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
158
+ - [502](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502) (Bad Gateway)
159
+ - [503](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) (Service Unavailable)
160
+ - [504](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504) (Gateway Timeout)
161
+
162
+ Use the `max_retries` request option to configure this behavior.
163
+
164
+ ```python
165
+ client.addons.attach_addon(..., request_options={
166
+ "max_retries": 1
167
+ })
168
+ ```
169
+
170
+ ### Timeouts
171
+
172
+ The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
173
+
174
+ ```python
175
+ from billkit import BillkitApi
176
+
177
+ client = BillkitApi(..., timeout=20.0)
178
+
179
+ # Override timeout for a specific method
180
+ client.addons.attach_addon(..., request_options={
181
+ "timeout": 1
182
+ })
183
+ ```
184
+
185
+ ### Custom Client
186
+
187
+ You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
188
+ and transports.
189
+
190
+ ```python
191
+ import httpx
192
+ from billkit import BillkitApi
193
+
194
+ client = BillkitApi(
195
+ ...,
196
+ httpx_client=httpx.Client(
197
+ proxy="http://my.test.proxy.example.com",
198
+ transport=httpx.HTTPTransport(local_address="0.0.0.0"),
199
+ ),
200
+ )
201
+ ```
202
+
203
+ ## Contributing
204
+
205
+ While we value open-source contributions to this SDK, this library is generated programmatically.
206
+ Additions made directly to this library would have to be moved over to our generation code,
207
+ otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
208
+ a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
209
+ an issue first to discuss with us!
210
+
211
+ On the other hand, contributions to the README are always very welcome!
212
+
@@ -0,0 +1,178 @@
1
+ # Billkit Python Library
2
+
3
+ [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fbillkit-io%2Fbillkit-python)
4
+ [![pypi](https://img.shields.io/pypi/v/billkit-sdk)](https://pypi.python.org/pypi/billkit-sdk)
5
+
6
+ The Billkit Python library provides convenient access to the Billkit APIs from Python.
7
+
8
+ ## Table of Contents
9
+
10
+ - [Installation](#installation)
11
+ - [Reference](#reference)
12
+ - [Usage](#usage)
13
+ - [Async Client](#async-client)
14
+ - [Exception Handling](#exception-handling)
15
+ - [Advanced](#advanced)
16
+ - [Access Raw Response Data](#access-raw-response-data)
17
+ - [Retries](#retries)
18
+ - [Timeouts](#timeouts)
19
+ - [Custom Client](#custom-client)
20
+ - [Contributing](#contributing)
21
+
22
+ ## Installation
23
+
24
+ ```sh
25
+ pip install billkit-sdk
26
+ ```
27
+
28
+ ## Reference
29
+
30
+ A full reference for this library is available [here](https://github.com/billkit-io/billkit-python/blob/HEAD/./reference.md).
31
+
32
+ ## Usage
33
+
34
+ Instantiate and use the client with the following:
35
+
36
+ ```python
37
+ from billkit import BillkitApi
38
+
39
+ client = BillkitApi(
40
+ api_key="<value>",
41
+ base_url="https://yourhost.com/path/to/api",
42
+ )
43
+
44
+ client.addons.attach_addon(
45
+ addon_key="addon_key",
46
+ subject_id="subject_id",
47
+ )
48
+ ```
49
+
50
+ ## Async Client
51
+
52
+ The SDK also exports an `async` client so that you can make non-blocking calls to our API. Note that if you are constructing an Async httpx client class to pass into this client, use `httpx.AsyncClient()` instead of `httpx.Client()` (e.g. for the `httpx_client` parameter of this client).
53
+
54
+ ```python
55
+ import asyncio
56
+
57
+ from billkit import AsyncBillkitApi
58
+
59
+ client = AsyncBillkitApi(
60
+ api_key="<value>",
61
+ base_url="https://yourhost.com/path/to/api",
62
+ )
63
+
64
+
65
+ async def main() -> None:
66
+ await client.addons.attach_addon(
67
+ addon_key="addon_key",
68
+ subject_id="subject_id",
69
+ )
70
+
71
+
72
+ asyncio.run(main())
73
+ ```
74
+
75
+ ## Exception Handling
76
+
77
+ When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
78
+ will be thrown.
79
+
80
+ ```python
81
+ from billkit.core.api_error import ApiError
82
+
83
+ try:
84
+ client.addons.attach_addon(...)
85
+ except ApiError as e:
86
+ print(e.status_code)
87
+ print(e.body)
88
+ ```
89
+
90
+ ## Advanced
91
+
92
+ ### Access Raw Response Data
93
+
94
+ The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
95
+ The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
96
+
97
+ ```python
98
+ from billkit import BillkitApi
99
+
100
+ client = BillkitApi(...)
101
+ response = client.addons.with_raw_response.attach_addon(...)
102
+ print(response.headers) # access the response headers
103
+ print(response.status_code) # access the response status code
104
+ print(response.data) # access the underlying object
105
+ ```
106
+
107
+ ### Retries
108
+
109
+ The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
110
+ as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
111
+ retry limit (default: 2).
112
+
113
+ Which status codes are retried depends on the `retryStatusCodes` generator configuration:
114
+
115
+ **`legacy`** (current default): retries on
116
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
117
+ - [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
118
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
119
+ - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) (All server errors, including 500)
120
+
121
+ **`recommended`**: retries on
122
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
123
+ - [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
124
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
125
+ - [502](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502) (Bad Gateway)
126
+ - [503](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) (Service Unavailable)
127
+ - [504](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504) (Gateway Timeout)
128
+
129
+ Use the `max_retries` request option to configure this behavior.
130
+
131
+ ```python
132
+ client.addons.attach_addon(..., request_options={
133
+ "max_retries": 1
134
+ })
135
+ ```
136
+
137
+ ### Timeouts
138
+
139
+ The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
140
+
141
+ ```python
142
+ from billkit import BillkitApi
143
+
144
+ client = BillkitApi(..., timeout=20.0)
145
+
146
+ # Override timeout for a specific method
147
+ client.addons.attach_addon(..., request_options={
148
+ "timeout": 1
149
+ })
150
+ ```
151
+
152
+ ### Custom Client
153
+
154
+ You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
155
+ and transports.
156
+
157
+ ```python
158
+ import httpx
159
+ from billkit import BillkitApi
160
+
161
+ client = BillkitApi(
162
+ ...,
163
+ httpx_client=httpx.Client(
164
+ proxy="http://my.test.proxy.example.com",
165
+ transport=httpx.HTTPTransport(local_address="0.0.0.0"),
166
+ ),
167
+ )
168
+ ```
169
+
170
+ ## Contributing
171
+
172
+ While we value open-source contributions to this SDK, this library is generated programmatically.
173
+ Additions made directly to this library would have to be moved over to our generation code,
174
+ otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
175
+ a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
176
+ an issue first to discuss with us!
177
+
178
+ On the other hand, contributions to the README are always very welcome!
@@ -0,0 +1,98 @@
1
+ [project]
2
+ name = "billkit-sdk"
3
+ dynamic = ["version"]
4
+
5
+ [tool.poetry]
6
+ name = "billkit-sdk"
7
+ version = "0.0.6"
8
+ description = ""
9
+ readme = "README.md"
10
+ authors = []
11
+ keywords = []
12
+ license = "MIT"
13
+ classifiers = [
14
+ "Intended Audience :: Developers",
15
+ "Programming Language :: Python",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Programming Language :: Python :: 3.14",
22
+ "Programming Language :: Python :: 3.15",
23
+ "Operating System :: OS Independent",
24
+ "Operating System :: POSIX",
25
+ "Operating System :: MacOS",
26
+ "Operating System :: POSIX :: Linux",
27
+ "Operating System :: Microsoft :: Windows",
28
+ "Topic :: Software Development :: Libraries :: Python Modules",
29
+ "Typing :: Typed",
30
+ "License :: OSI Approved :: MIT License"
31
+ ]
32
+ packages = [
33
+ { include = "billkit", from = "src"}
34
+ ]
35
+
36
+ [tool.poetry.urls]
37
+ Repository = 'https://github.com/billkit-io/billkit-python'
38
+
39
+ [tool.poetry.dependencies]
40
+ python = "^3.10"
41
+ aiohttp = { version = ">=3.14.1,<4", optional = true, python = ">=3.10"}
42
+ httpx = ">=0.21.2"
43
+ httpx-aiohttp = { version = "^0.1.8", optional = true, python = ">=3.10"}
44
+ pydantic = ">= 1.9.2"
45
+ pydantic-core = ">=2.18.2,<3.0.0"
46
+ typing_extensions = ">= 4.0.0"
47
+
48
+ [tool.poetry.group.dev.dependencies]
49
+ mypy = "==1.13.0"
50
+ pytest = "^9.0.3"
51
+ pytest-asyncio = "^1.0.0"
52
+ pytest-xdist = "^3.6.1"
53
+ python-dateutil = "^2.9.0"
54
+ types-python-dateutil = "^2.9.0.20240316"
55
+ urllib3 = ">=2.6.3,<3.0.0"
56
+ ruff = "==0.11.5"
57
+
58
+ [tool.pytest.ini_options]
59
+ testpaths = [ "tests" ]
60
+ asyncio_mode = "auto"
61
+ norecursedirs = [ "src" ]
62
+ markers = [
63
+ "aiohttp: tests that require httpx_aiohttp to be installed",
64
+ ]
65
+
66
+ [tool.mypy]
67
+ plugins = ["pydantic.mypy"]
68
+
69
+ [tool.ruff]
70
+ line-length = 120
71
+
72
+ [tool.ruff.lint]
73
+ select = [
74
+ "E", # pycodestyle errors
75
+ "F", # pyflakes
76
+ "I", # isort
77
+ ]
78
+ ignore = [
79
+ "E402", # Module level import not at top of file
80
+ "E501", # Line too long
81
+ "E711", # Comparison to `None` should be `cond is not None`
82
+ "E712", # Avoid equality comparisons to `True`; use `if ...:` checks
83
+ "E721", # Use `is` and `is not` for type comparisons, or `isinstance()` for insinstance checks
84
+ "E722", # Do not use bare `except`
85
+ "E731", # Do not assign a `lambda` expression, use a `def`
86
+ "F821", # Undefined name
87
+ "F841" # Local variable ... is assigned to but never used
88
+ ]
89
+
90
+ [tool.ruff.lint.isort]
91
+ section-order = ["future", "standard-library", "third-party", "first-party"]
92
+
93
+ [build-system]
94
+ requires = ["poetry-core"]
95
+ build-backend = "poetry.core.masonry.api"
96
+
97
+ [tool.poetry.extras]
98
+ aiohttp=["aiohttp", "httpx-aiohttp"]