FDA / openfda

openFDA is an FDA project to provide open APIs, raw data downloads, documentation and examples, and a developer community for an important collection of FDA public datasets.
https://open.fda.gov
Creative Commons Zero v1.0 Universal
569 stars 131 forks source link

Added link header pagination #104

Closed beckyconning closed 4 years ago

beckyconning commented 4 years ago

103

beckyconning commented 4 years ago

Oh I accidentally tied it to one specific endpoint, will fix that.

beckyconning commented 4 years ago

This is ready for review : )

beckyconning commented 4 years ago

Anything I can do to move this forwards?

violetcrestedwren commented 4 years ago

Hi @beckyconning, is a header like the one below accurate to what you'd expect given the request?

Request: http://api.fda.gov/drug/label.json?skip=100&limit=100

Header: Link →<http://api.fda.gov/drug/label.json?skip=200&limit=100>; rel="next"

beckyconning commented 4 years ago

Sorry for the slow reply. Yes thats exactly right if <http://api.fda.gov/drug/label.json?skip=200&limit=100>; rel="next" is the header value and Link is the header name.

beckyconning commented 4 years ago

Other parameters should be passed over as well so for example.

http://api.fda.gov/drug/label.json?skip=100&limit=100&search=original_receive_date:[20040101+TO+20161107]

should return

Link <http://api.fda.gov/drug/label.json?skip=200&limit=100&search=original_receive_date:[20040101+TO+20161107]>; rel="next"

or equivalent

beckyconning commented 4 years ago

@beardedfinch let me know if there is anything I can do to help 😀

dkrylovsb commented 4 years ago

@beckyconning This is being pushed to Production as we speak; we'll let you know once done. 👍

beckyconning commented 4 years ago

Fantastic, thank you so much @dkrylovsb et al!

beckyconning commented 4 years ago

Just a note I think the per_page values in the link header next relation should be set to the max allowed by the service when not specified in the initial request.

beckyconning commented 4 years ago

we'll let you know once done

Will you let me know here or elsewhere?

dkrylovsb commented 4 years ago

@beckyconning Hi Becky, it's in Production.

beckyconning commented 4 years ago

Fantastic! Seems to work great. One change I'd love to see is if the page size was set to 100 rather than 1 by default. Thanks so much for your work! Where is the code for this? Is it this PR or another PR? I can't see it in the repo. Thanks again!

beckyconning commented 4 years ago

Additionally api key and other provided query parameters are not shown in the link header next relation.

beckyconning commented 4 years ago

Closing this as this has been implemented elsewhere since I opened this. Note you will need to provide API key as basic auth username for this to work.