Help

Re: How to query a table on a separate base?

1062 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Nicole_Lopez
6 - Interface Innovator
6 - Interface Innovator

Is it possible to programmatically with Airtable scripting load a different base from the one in which the script is running? I’d like to automatically sync views from one base to another with the scripting block, but it’s looking like that might not be possible?

6 Replies 6

It definitely is possible, but requires use of the standard Airtable API from within the Scripting Block script.

Also, syncing is a tricky problem to solve. One-way syncing isn’t too bad - if you just want to update “Base 2” with whatever the current state is of “Base 1”, that can be done relatively easily by making a GET request to “Base 1” with the Airtable API, and matching up records from the GET request to records in “Base 2”, and then using the Scripting Block’s updateRecordsAsync() method to update “Base 2” so that it looks like “Base 1”.

Two-way syncing is a whole different issue - now you have to move data both ways, resolve conflicts, and determine which Base’s data should win out. This does not lend itself to a short forum explanation :slightly_smiling_face:

I’m only looking for a one-way sync here so this is great news! Muchas gracias!

De nada.

You can access the standard API with specifics for the base you want to access from the “Help” menu of the base you want to access.

image

Hey, I am trying to do the same! @Nicole_Lopez, did you manage to do it? Do you have any resource or example you could share as a reference?

Thanks a lot!

I’m trying to do this in an app (to archive old data from one base into a separate one.)

I’d come to the same conclusion, that the only way to achieve it inside Airtable is to use the standard REST API. But I can’t see how to make that happen within a scripting app: there’s no airtable.js package available, and so I don’t see how I can get access to the client.

Do I have to make raw HTTPS calls as per the curl examples in the documentation instead?

Josh_Cooper
6 - Interface Innovator
6 - Interface Innovator

@Jonathan_Frank ,

The simple answer is yes, that is exactly what you have to do. An example would look like this.

let response = await fetch('https://api.airtable.com/v0/YOUR_APP_ID/YOUR_TABLE_NAME?api_key=YOUR_API_KEY');
console.log(await response.json());

At that point, you just need to look through the JSON response and figure out how you get the data out of the object structure.

Hope this helps.