Skip to content

Commit 55bf27d

Browse files
docs(readme): document how to make undocumented requests (#329)
1 parent 3fdcf2e commit 55bf27d

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

+35
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,41 @@ with client.hris.directory.with_streaming_response.list() as response:
336336

337337
The context manager is required so that the response will reliably be closed.
338338

339+
### Making custom/undocumented requests
340+
341+
This library is typed for convenient access the documented API.
342+
343+
If you need to access undocumented endpoints, params, or response properties, the library can still be used.
344+
345+
#### Undocumented endpoints
346+
347+
To make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other
348+
http verbs. Options on the client will be respected (such as retries) will be respected when making this
349+
request.
350+
351+
```py
352+
import httpx
353+
354+
response = client.post(
355+
"/foo",
356+
cast_to=httpx.Response,
357+
body={"my_param": True},
358+
)
359+
360+
print(response.headers.get("x-foo"))
361+
```
362+
363+
#### Undocumented params
364+
365+
If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request
366+
options.
367+
368+
#### Undocumented properties
369+
370+
To access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You
371+
can also get all the extra fields on the Pydantic model as a dict with
372+
[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).
373+
339374
### Configuring the HTTP client
340375

341376
You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:

0 commit comments

Comments
 (0)