Help

Save the date! Join us on October 16 for our Product Ops launch event. Register here.

Re: Randomizing the results from an API call

Solved
Jump to Solution
1127 0
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.