How to retrieve specific column data from Airtable API

I’m just starting with APIs and I successfully connected to Airtable to fetch data. However, my current setup pulls all the information from the table.

I need help with two things:

  1. How can I filter the response to only get data from one specific column? For example, I only want the “Title” column values.

  2. How can I verify if a particular value exists within that column?

Here’s my current code:

let baseUrl = "https://api.airtable.com/v0/"
let authToken = "Bearer abcdef123456"
let databaseId = "abcdef123456"
let sheetName = "/Main%20Sheet"
let completeUrl = baseUrl + databaseId + sheetName
console.log(baseUrl + databaseId + sheetName)

let request = new Request(completeUrl)

request.method = "GET"

request.headers={
  "Authorization":authToken,
  "Content-Type":"application/json",
  "fields":"Title"
}

let result = await request.loadString()

console.log(result)

Any guidance would be appreciated!

yup, no headers for query params! just append ?fields=Title to your completeUrl. for checking a value, after parsing the response do JSON.parse(result).records.find(r => r.fields.Title === 'whatever'). it returns undefined if there’s no match.

You’re treating fields as a header when it’s actually a URL parameter. Remove that fields line from your headers and fix your URL construction instead. I build the query string separately then append it: let queryParams = "?fields[]=Title" let completeUrl = baseUrl + databaseId + sheetName + queryParams. Those square brackets in fields matter - they handle multiple fields way better if you add more later. To check if a value exists, parse your result to JSON first, then filter: let jsonData = JSON.parse(result) let hasValue = jsonData.records.filter(record => record.fields.Title === "target value").length > 0. Airtable always wraps your data in a records array, and each record has a fields object. This threw me off at first since most APIs just return data directly.

Your headers approach won’t work - fields is a query parameter, not a header. Drop that line completely.

Build your URL like this instead:

let fieldsParam = "?fields=Title"
let completeUrl = baseUrl + databaseId + sheetName + fieldsParam

To check if a value exists in that column, parse the JSON response:

let data = JSON.parse(result)
let titleExists = data.records.some(record => record.fields.Title === "your search value")

I hit this same issue when I started with Airtable’s API. The response buries your data inside records[].fields.ColumnName, so you’ve got to dig into that nested structure.

The some() method returns true if it finds a match, false if not. Much cleaner than writing your own loop.

the fields parameter should go in the url, not the headers. so add ?fields=Title to your completeUrl like this: completeUrl + "?fields=Title". to check if a value exists, just parse the json response and loop through the records array to find it.

Had this exact problem last year! You’re mixing headers with query parameters. The fields parameter goes in the URL, not the headers. Your headers should just have Authorization and Content-Type. Change your URL construction to: let completeUrl = baseUrl + databaseId + sheetName + "?fields=Title". Airtable wraps everything in its own structure, so you’ll need to parse the JSON and grab your data through response.records[index].fields.Title. To check if a value exists, parse the response first, then use find() on the records array to search the Title field values. This works great across different bases.