Help

The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.

Randomizing the results from an API call

Topic Labels: API
Solved
Jump to Solution
1895 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Assaf_Barnir
4 - Data Explorer
4 - Data Explorer

I built a small table and am accessing it via Airtable API.
Any tip as to how I can randomize the results I’m getting?
Meaning: for each API call, get the value of a different row.

Cheers

1 Solution

Accepted Solutions
kuovonne
18 - Pluto
18 - Pluto

Welcome to the Airtable community!

The REST API is not designed to return random records. You can get the specific record you request, you can get records in a specific sort order, or you can get records in default order.

If you want a random record, you will need a method of adding that randomness in your code. For example, you could do an initial query of only the record IDs for all the records in the table, pick a random record ID, and then request that specific record. If your table has many records, this may be very cumbersome.

See Solution in Thread

1 Reply 1
kuovonne
18 - Pluto
18 - Pluto

Welcome to the Airtable community!

The REST API is not designed to return random records. You can get the specific record you request, you can get records in a specific sort order, or you can get records in default order.

If you want a random record, you will need a method of adding that randomness in your code. For example, you could do an initial query of only the record IDs for all the records in the table, pick a random record ID, and then request that specific record. If your table has many records, this may be very cumbersome.