You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Finch Python library provides convenient access to the Finch REST API from any Python 3.7+
6
-
application. It includes type definitions for all request params and response fields,
6
+
application. The library includes type definitions for all request params and response fields,
7
7
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).
8
8
9
9
## Documentation
10
10
11
-
The API documentation can be found [here](https://developer.tryfinch.com/).
11
+
The API documentation can be found at [https://developer.tryfinch.com/](https://developer.tryfinch.com/).
12
12
13
13
## Installation
14
14
@@ -34,7 +34,7 @@ directory = page.individuals[0]
34
34
print(directory.first_name)
35
35
```
36
36
37
-
## Async Usage
37
+
## Async usage
38
38
39
39
Simply import `AsyncFinch` instead of `Finch` and use `await` with each API call:
40
40
@@ -58,11 +58,11 @@ asyncio.run(main())
58
58
59
59
Functionality between the synchronous and asynchronous clients is otherwise identical.
60
60
61
-
## Using Types
61
+
## Using types
62
62
63
-
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev), which provide helper methods for things like serializing back into json ([v1](https://docs.pydantic.dev/1.10/usage/models/), [v2](https://docs.pydantic.dev/latest/usage/serialization/)). To get a dictionary, you can call `dict(model)`.
63
+
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev), which provide helper methods for things like serializing back into JSON ([v1](https://docs.pydantic.dev/1.10/usage/models/), [v2](https://docs.pydantic.dev/latest/usage/serialization/)). To get a dictionary, call `dict(model)`.
64
64
65
-
This helps provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `"basic"`.
65
+
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
When the library is unable to connect to the API (e.g., due to network connection problems or a timeout), a subclass of `finch.APIConnectionError` is raised.
172
+
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `finch.APIConnectionError` is raised.
173
173
174
-
When the API returns a non-success status code (i.e., 4xx or 5xx
175
-
response), a subclass of `finch.APIStatusError`will be raised, containing `status_code` and `response` properties.
174
+
When the API returns a non-success status code (that is, 4xx or 5xx
175
+
response), a subclass of `finch.APIStatusError`is raised, containing `status_code` and `response` properties.
176
176
177
177
All errors inherit from `finch.APIError`.
178
178
@@ -210,11 +210,11 @@ Error codes are as followed:
210
210
211
211
### Retries
212
212
213
-
Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
213
+
Certain errors are automatically retried 2 times by default, with a short exponential backoff.
214
214
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
215
-
429 Rate Limit, and >=500 Internal errors will all be retried by default.
215
+
429 Rate Limit, and >=500 Internal errors are all retried by default.
216
216
217
-
You can use the `max_retries` option to configure or disable this:
217
+
You can use the `max_retries` option to configure or disable retry settings:
Note that requests which time out will be[retried twice by default](#retries).
257
+
Note that requests that time out are[retried twice by default](#retries).
258
258
259
259
## Default Headers
260
260
@@ -276,7 +276,7 @@ client = Finch(
276
276
277
277
### How to tell whether `None` means `null` or missing
278
278
279
-
In an API response, a field may be explicitly null, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:
279
+
In an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:
280
280
281
281
```py
282
282
if response.my_field isNone:
@@ -286,27 +286,30 @@ if response.my_field is None:
286
286
print('Got json like {"my_field": null}.')
287
287
```
288
288
289
-
### Configuring custom URLs, proxies, and transports
289
+
### Configuring the HTTP client
290
290
291
-
You can configure the following keyword arguments when instantiating the client:
291
+
You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:
See the httpx documentation for information about the [`proxies`](https://www.python-httpx.org/advanced/#http-proxying) and [`transport`](https://www.python-httpx.org/advanced/#custom-transports) keyword arguments.
306
-
307
310
### Managing HTTP resources
308
311
309
-
By default we will close the underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__) is called but you can also manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.
312
+
By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.
0 commit comments