Help

Using Offset Pagination to get multiple pages of records in GO

Topic Labels: API
Solved
Jump to Solution
7262 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Adam_Haffar1
5 - Automation Enthusiast
5 - Automation Enthusiast

I am working with the Airtable API in GoLang and I am using this client.

I have 150 records. I am trying to fetch the first 50, then next 50 and so on.

I do this by sending the following HTTP request (with the help of the client):

/v0/appXXXXXXX/tblXXXXXXXcellFormat=string&offset=50&pageSize=50&sort%5B0%5D%5Bdirection%5D=asc&sort%5B0%5D%5Bfield%5D=Name&timeZone=Europe%2FLondo
n&userLocale=en-gb

Note the &offset=50. When I send this request I get the following error:
“error”:{“type”:“INVALID_OFFSET_VALUE”,“message”:“The value of offset 50 is invalid”

I have tried removing the offset parameter and it gets me the first 50, but how am I supposed to get the next 50!

Below is my Go code using Mehanizm’s Client:
image

1 Solution

Accepted Solutions
Vivid-Squid
11 - Venus
11 - Venus

HI @Adam_Haffar1,
When you make a request that returns more than 100 records, the JSON data will contain an offset that you will use on the next call for the next 100 records

image

Then you add that offset to your query URL
fetch(https://api.airtable.com/v0/${remoteBaseID}/${remoteTableID}?api_key=${apiKey}&offset=${offset}`)`

See Solution in Thread

2 Replies 2
Vivid-Squid
11 - Venus
11 - Venus

HI @Adam_Haffar1,
When you make a request that returns more than 100 records, the JSON data will contain an offset that you will use on the next call for the next 100 records

image

Then you add that offset to your query URL
fetch(https://api.airtable.com/v0/${remoteBaseID}/${remoteTableID}?api_key=${apiKey}&offset=${offset}`)`

Thanks this worked!!