I have a question about how pagination works in the API, and I in general. I'm a newb to web APIs so I may be overthinking or overlooking something, so bear with me.
When getting feed data, the response includes a link header that currently looks like this:
<https://the/original/url>;rel="next", <https://the/next/url>
When parsed using the links method of requests.Response (I'm working in Python) you get this:
Code: Select all
{'next': {'url': 'https://the/original/url', 'rel': 'next'},
'https://the/next/url': {'url': 'https://the/next/url'}}
Code: Select all
response.links['next']['url']
The documentation links to this example, which uses a regular expression to parse the url after rel="next"; but I don't think this regular expression is necessary.
If it instead looked like this:
<https://the/original/url>;rel="last", <https://the/next/url>;rel="next"
(note the rel="next" parameter is associated with the appropriate link)
then
Code: Select all
response.links['next']['url']
So I guess my question is, am I understanding all of this right?
The question may be academic, I suspect this API has been in production long enough that changing it would break more than it would fix. But as I said I'm a newb trying to learn and just taking the time to write up this question has taught me a lot. I just want to make sure I'm not completely missing something, and maybe it'll help the next newb struggling with the same issue.
Thanks!