-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Add missing parts for rest client docs #1397
Changes from 2 commits
931111a
373b8b3
8b88d65
415c3c6
0e1e7b1
7c6dcbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
--- | ||
title: RESTClient | ||
description: Learn how to use the RESTClient class to interact with RESTful APIs | ||
keywords: [api, http, rest, request, extract, restclient, client, pagination, json, response, data_selector, session, auth, paginator, jsonresponsepaginator, headerlinkpaginator, offsetpaginator, jsonresponsecursorpaginator, queryparampaginator, bearer, token, authentication] | ||
keywords: [api, http, rest, request, extract, restclient, client, pagination, json, response, data_selector, session, auth, paginator, jsonresponsepaginator, headerlinkpaginator, offsetpaginator, jsonresponsecursorpaginator, queryparampaginator, bearer, token, authentication, reverse etl, json path, openapi, swagger] | ||
--- | ||
|
||
The `RESTClient` class offers an interface for interacting with RESTful APIs, including features like: | ||
|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And for this. Why would we need to have an alternative declaration here? |
||
|
||
### 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, | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Comment on lines
+442
to
+461
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part does not belong to this document. This is documentation for RESTClient and not rest_api. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, I will remove it |
||
### 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). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the rationale for this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some people are used to use JSONPath starting with
$.
so this is just to give relation to it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, but I think if they know JSONPath already they would know that extended syntax anyway. I would try to optimize here for those unfamiliar with JSONPath. We also link JSONPath docs twice for those who need advanced JSONPath.