From 373b8b3dfeeabfee380da5163f8e2e7b6104548d Mon Sep 17 00:00:00 2001 From: Sultan Iman Date: Wed, 22 May 2024 12:08:39 +0200 Subject: [PATCH] Add a new section about resource_defaults --- .../docs/general-usage/http/rest-client.md | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/website/docs/general-usage/http/rest-client.md b/docs/website/docs/general-usage/http/rest-client.md index 45f7ce2fe7..8c2317f6f9 100644 --- a/docs/website/docs/general-usage/http/rest-client.md +++ b/docs/website/docs/general-usage/http/rest-client.md @@ -80,7 +80,7 @@ For example, if the API response looks like this: } ``` -The `data_selector` should be set to `"posts"` to extract the list of posts from the response. +The `data_selector` should be set to `"posts"` or `"$.posts"` to extract the list of posts from the response. For a nested structure like this: @@ -96,7 +96,7 @@ For a nested structure like this: } ``` -The `data_selector` needs to be set to `"results.posts"`. Read more about [JSONPath syntax](https://github.com/h2non/jsonpath-ng?tab=readme-ov-file#jsonpath-syntax) to learn how to write selectors. +The `data_selector` needs to be set to `"results.posts"` or `"$.results.posts"`. Read more about [JSONPath syntax](https://github.com/h2non/jsonpath-ng?tab=readme-ov-file#jsonpath-syntax) to learn how to write selectors. ### PageData @@ -432,6 +432,26 @@ for page in client.paginate("/protected/resource"): print(page) ``` +## Common resource defaults + +In `RESTAPIConfig` you can provide via `resource_defaults` which will then be applied to all requests + +```py +my_params = { + "from_year": 2018, + "end_year": 2024, +} + +source_config: RESTAPIConfig = { + "client": {...}, + "resource_defaults": { + "endpoint": { + "params": my_params, + } + } +} +``` + ### API key authentication API Key Authentication (`ApiKeyAuth`) is an auth method where the client sends an API key in a custom header (e.g. `X-API-Key: `, or as a query parameter).