Skip to content

Commit

Permalink
Add a new section about resource_defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
sultaniman committed May 22, 2024
1 parent 931111a commit 373b8b3
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions docs/website/docs/general-usage/http/rest-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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

Expand Down Expand Up @@ -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: <key>`, or as a query parameter).
Expand Down

0 comments on commit 373b8b3

Please sign in to comment.