0
votes

I'm trying to pull all the shop items from Square Connect API, and the pagination seems to be broken. Here is the request I'm making:

$ http https://connect.squareup.com/v1/{location id}/items 'Authorization: Bearer XXXXXXXXXXXX'
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Link
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Tue, 29 Nov 2016 09:25:50 GMT
ETag: "-307839789"
Keep-Alive: timeout=60
Strict-Transport-Security: max-age=631152000
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: DENY
X-Request-Id: ed/QSsnKQaeuhjoT4K/R
X-Response-Time: 529ms
X-XSS-Protection: 1; mode=block
transfer-encoding: chunked

[
...
]

Critically, the Link header is missing. The documentation here https://docs.connect.squareup.com/api/connect/v1/#pagination describes pagination, and it seems like the header should be present when there are more than 10 results (which there are).

Am I doing something wrong?

1
Is that the request or the response? Are you sure that you have enough items to paginate? - tristansokol
That's the request, I removed the contents of the response [...] as it's not relevant and very long. Yes I'm sure I have enough items to paginate. - Sam Lee
I think you might have the two mixed up, an http request to the items endpoint would look like this GET /v1/LOCATION/items HTTP/1.1 Host: connect.squareup.com Authorization: Bearer sq0atp-Szwdidde-kKILsQCJYyETA Content-Type: application/json Cache-Control: no-cache and wouldn't have a response code like 200 OK - tristansokol
err, right, the request is http https://connect.squareup.com/v1/{location id}/items 'Authorization: Bearer XXXXXXXXXXXX' and the rest of it is the response. Sorry for being unclear. - Sam Lee

1 Answers

0
votes

I think you are mixing up items and variations. The response you get from the list items endpoints will give you each of your unique items (in your case ~140), each of those item objects will include additional information about their variations. If you expect to have more items you might actually be counting each variation as a different item.