How to retrieve specific column data from Airtable API

I’m just starting with APIs and I can pull data from my Airtable base successfully. The issue is that my request returns all the data from every column in 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 values from my “Username” column.

  2. How do I verify if a particular username already exists in that column?

Here’s my current code:

let baseUrl = "https://api.airtable.com/v0/"
let authToken = "Bearer abcdef123456"
let baseId = "appABC123DEF456"
let tableId = "/Users%20Table"
let apiEndpoint = baseUrl + baseId + tableId
console.log(baseUrl + baseId + tableId)

let request = new Request(apiEndpoint)

request.method = "GET"

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

let apiResponse = await request.loadString()
console.log(apiResponse)

Any guidance would be much appreciated!

quick tip - you can combine both parameters in one URL like ?fields=Username&filterByFormula={Username}='targetuser' to filter and select columns at the same time. saves you from making separate requests when checking usernames.

You’re putting the fields parameter in headers when it should be in the query string. That’s your problem.

Change your apiEndpoint to:

let apiEndpoint = baseUrl + baseId + tableId + "?fields=Username"

Then delete the “fields”:“Username” line from your headers - it doesn’t belong there.

For checking if a username exists, use filterByFormula in your query string: ?filterByFormula={Username}='the_username_you_want_to_check'. If you get records back, the username exists. No records means it doesn’t exist.

I made this exact mistake when I started with Airtable’s API. Their docs aren’t great at explaining what goes in headers vs URL parameters.

Headers won’t work here - Airtable needs query parameters for filtering, not header fields. Your Request setup looks good otherwise. I’d skip the filter method for checking if users exist. Instead, use ?fields=Username to grab just that column, then parse the JSON and loop through the records to find your username. This way you control the matching - maybe you want case-insensitive or partial matches. Watch out for pagination though. Airtable caps responses at 100 records by default, so you might miss usernames from later pages. Use maxRecords to limit scope or handle the offset parameter for bigger datasets.

Just tested this last month. The headers approach is definitely the problem.

Here’s what everyone else missed - build your request object properly:

let params = new URLSearchParams({
  fields: 'Username'
})

let apiEndpoint = baseUrl + baseId + tableId + '?' + params.toString()

Handles URL encoding automatically and makes adding parameters dead simple.

For username checking, I’d do it differently. Don’t filter on the API side - grab all usernames once and stick them in a Set:

let usernames = new Set()
data.records.forEach(record => {
  if (record.fields.Username) {
    usernames.add(record.fields.Username.toLowerCase())
  }
})

// Check like this:
let userExists = usernames.has('targetuser'.toLowerCase())

Faster for multiple lookups, handles empty cells better, and you won’t hit rate limits checking tons of usernames.