Why cursor-based pagination in shopify ignores last page? - shopify

I'm using shopify api to get list of orders
For first request I use this URL:
https://my-shop-name.myshopify.com/admin/orders.json?status=any&order=created_at+desc&limit=250
and for all next use link to next page from response headers like described here:
Pagination with a link header
The problem is that last page or orders always gets ignored, because request for previous page doesn't contain link to next one.
That's weird, because it takes all orders from 4403 to 1153 (with 250 limit it's 13 pages) and it should make one more request (latest order number is 1101), to get latest 52 orders. Maybe the problem is in 250 limit parameter, but I don't know how to bypass it if I don't know exact number of orders

Related

Shopware 6 Product API limit with offset

When using Shopware 6 /api/product REST-API I do get an timeout.
I found out i can set an limit and an offset.
When I call the API with /api/product?limit=240&offset=240 I still get the first 240 products.
Also tried using Shopware 5 offset variant, where you use start instead of offset.
Both give the same result.
I also tried doing an POST instead of an GET request, also no success.
I even using /api/search/product...
Does anyone know how to correctly perform an offset?
In the shopware 6 API you can request paginated data by using limit and page parameters. The page roughly translates to the offset that is being used, instead of doing a request with an offset of 240 (as in your example) you would request the page=2 with a limit of 240 this would give you the results 241-480.
So instead of
/api/product?limit=240&offset=240
you should use
/api/product?limit=240&page=2
The limit and page parameters can be used in GET-Requests, but also in POST-Request in the JSON-Body or in the search endpoint.
Take a look at the official docs for reference.

Unpredictable soundcloud api tracklist

I need to get whole user's tracklist by SC api.
Before I use the next link format:
https://api.soundcloud.com/users/{user_id}/tracks/?page_size=200&linked_partitioning=1&client_id={app_id}
But it has stopped to work correct recently.
Changes:
limit has been decreased by SC from 200 tracks to 50;
returned tracks have become random (eg user has 300 tracks, but request above returns 54 tracks and link to the next page of tracks where fields "offset=50&limit=50" are appearing;
when I change field "page_size" from 200 to 50, SC returns only 18 tracks).
Also I've tried to use fields "offset" and "limit" instead of "page_size" but it has worked incorrect, too.
How I can get whole user's tracklist?
You need to parse the response and read next_href then change the url to the next_href value.
It's better to do this as a loop until there is no more next_href
Some recent updates on pagination from the API can be found below. You need to rely on the cursor rather than offset
https://developers.soundcloud.com/blog/pagination-updates-on-our-api

How to fetch specific amount of users using github api v3?

When I want to fetch github users using this api: https://api.github.com/users it gives me back exactly 46 users. How can I fetch e.g. just 10 of them?
You can try and add the per_page directive in your API URL
By passing the per_page parameter, you can specify how many items you want each page to return, up to 100 items.
Let's try asking for 10 items about addClass:
curl -I "https://api.github.com/search/code?q=addClass+user:mozilla&per_page=10"
Apply the same idea to api.github.com/users
The first "page" of result would be 10 users.

How to get maximum number of tweets on an user

i have this code
("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser.'&count=500'
But it is giving me only 200 records , I found in twitter document that it will give 3200 tweets.Is i am doing wrong what should i do to get that much tweet.
Since there is no page system in twitter 's API, to go throught timelines, you must use the "max_id" parameter.
Here is an helpful link that explains how to work with timelines with nice illustrations: https://dev.twitter.com/rest/public/timelines.
Edit: here is how you do it.
"To use max_id correctly, an application’s first request to a timeline endpoint should only specify a count."
Make your request "https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser.'&count=500 (you can put 200).
Then when you get all your data, " keep track of the lowest ID received" and use it as parameter (the same way you do for the count) for your next request. it will give you the 200 next posts with a lower id than the one you specified. Do it again until you reach the end.

Angellist api: How to get to second page of data?

I was looking at Angel list api (https://angel.co/api) and I noticed a section on pagination. It says entries are limited to max of 50 (for eg. https://api.angel.co/1/users/135/roles has 2 pages work of data but returns only 1 page). The documentation mentions pagination but does not say how to get 2nd page.
Any ideas?
Chetan
Add ?page=2 to the end of the request to get the second page.