Hi @Acefast
Here is an example of an API request that writes to the Airtable base
let table = base.getTable('Table 1');
//Fetch url and translate to json
let url = await fetch('https://reqres.in/api/users');
let json = await url.json();
//Name your columns 'First Name', 'Last Name' and 'Email'
//Loop over the json object (key/value pairs)
for (i=0; i < json.data.length; i++) {
let recordId = await table.createRecordAsync({
"First Name": json.data[i].first_name,
"Last Name": json.data[i].last_name,
"Email": json.data[i].email
})
}
I am unsure what you want to do with the data once you get it. You need to review the JSON data and determine which parts of it you want to put in a cell.
for (let i=0; i < json.included.length; i++) {
let recordId = await table.createRecordAsync({
"HMRC JSON": json.included[i].attributes.title
})
}
This will get you the records that have title in the JSON and put them in the field. But looking at the API there is a lot more that can be extracted.
I have no idea if you will hit any limits. I pulled 1 code and it gave me 500+ records. The thing is, ‘the whole lot’ is a bunch of things that can be a number of different types of data (text, numbers…) so if you want to put that data into airtable the type of field needs to match the type of data you have.
Since you are going through the effort of writing a script, you should review the data you are getting and put it in the appropriate place in airtable.
It looks like each object has an id, type and attributes (amongst other things). Try just putting in the id and see how that data looks. Then add the type and grow it from there.
Airtable unlike excel does not have a native split to cells function. There may be an app that does this but I don’t know.
You can use formulas to FIND() aspects of your text, then you can use LEFT(), RIGHT() or MID() to pull out the text in the location returned from FIND().
I am not sure what your end goal is, but I would guess there is something in that API that you want to keep in Airtable. Instead of using airtable to sort through all of the data, manually keeping only what you want. I would review the data and have my script only gather what I need. I guess the effort would pay off better in the long run.