# Work in Progress: How to Bring Data from Airtable

{% hint style="info" %}
The best way for us to make use of big chunks of information on the flow is in the form of a JSON Object. Airtable has its own API for that!
{% endhint %}

### Step 1: Get your Airtable URL

* Go to "API documentation" on the Help menu of your base
* Select your table on the left side Menu
* Click on "List Records"
* On the "curl" window to the right, you'll see an example request
* Copy the URL and the authorization with your API key, you'll need that for later!

{% hint style="info" %}
To get your API key below the URL, you'll have to check the "Show API key" box on the top right corner of the curl window!
{% endhint %}

### Step 2: Create a Computed Field

* Go to the "All" Tab of the Left Sidebar
* Scroll down to the Computed Fields section and create a new one&#x20;
* Give it a cool, original name. Something like "airtable\_data"
* Scroll to the bottom of the Options Tab on the Right Sidebar
* Click on "Generate Sample Code", it will generate an empty function:

### Step 3: Fetch!

* Copy this code inside the function:

```
function result() {
  let url = "YOUR_URL";
  
  return fetch(url, {
    headers: {'Authorization': 'Bearer YOUR_API_KEY',
    }
  })
    .then((response) => response.json())
    .then(json => {
      // Do something with the data
      return json.records
    }); 
    
}
```

* Paste the URL you copied from Airtable where it says `YOUR_URL` , and your API key where it says `YOUR_API_KEY`
* Click on "Update" to save the code changes and you should be ready to go!

{% hint style="info" %}
Your Airtable URL from the example request has its maxRecords set to 3 by default. You can change that to a max of 100. This is what it looks like, you can change the number 3 on the URL: "<https://api.airtable.com/v0/apps1073vcOXbLbso/example\\_base?maxRecords=3\\&view=Grid%20view>"

{% endhint %}

### Security warning

Your Airtable API key is the same for every base on your account, so:

* We recommend creating an account that only has access to that base.
* Anyone with the account API key could have read/write access to that account bases.
* Even if write permission isn't an issue, they still get access to all the data.

{% hint style="info" %}
In most cases this isn't an issue, but if it is an issue for you, don't worry! We're working on it to make it safer.
{% endhint %}

&#x20;
