-
Notifications
You must be signed in to change notification settings - Fork 4
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
Response headers? #15
Comments
Hello @gotdan please share a full example |
Sure @lmangani! For example, one could use the request below to get the recently merged pull requests in the duckdb repo. It's only able to retrieve the first page of API results (in this case a max of 100 pull requests), since the url to get the next page of API results is passed to the client in a "link" response header. If there was a way to get a map of the response headers in addition to the response body (maybe Note that you currently need to hard code a github API token in the request Authorization header for this query to work correctly (maybe in the future, the duckdb secrets manager could be used in some way for this?). WITH raw_pulls AS (
SELECT http_get(
'https://api.github.com/repos/duckdb/duckdb/pulls',
headers => MAP {
'Accept': 'application/vnd.github+json',
'Authorization': 'Bearer {token},
'X-GitHub-Api-Version': '2022-11-28'
},
params => MAP {
'state': 'closed',
'sort': 'updated',
'direction': 'desc',
'per_page': '100'
}
) AS res
),
pulls AS (
SELECT
(res->>'status')::INT AS status,
(res->>'reason') AS reason,
unnest ( (res->>'body')::JSON[] ) AS body
FROM
raw_pulls
),
pull_detail AS (
SELECT from_json(body,
'{"headers": "JSON", "merged_at": "DATETIME", "title":"VARCHAR", "body": "VARCHAR"}'
) AS props
FROM pulls
)
SELECT props.* FROM pull_detail WHERE props.merged_at IS NOT NULL |
Are the response headers exposed in some way? I'm experimenting with using this extension to pull in data directly from the github API and they return a "link" header for paging.
The text was updated successfully, but these errors were encountered: