# List Records — Airtable

> Retrieve records from a table, optionally sorting and filtering results. Use List Tables to look up a table's field IDs. See the documentation

- Key: `airtable_oauth-list-records`
- Type: Action (Read-only)
- Version: 0.0.15
- App: Airtable (`airtable_oauth`) — https://pipedream.com/apps/airtable-oauth.md
- This page (HTML): https://pipedream.com/apps/airtable-oauth/actions/list-records
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/airtable_oauth/actions/list-records/list-records.mjs

## Description

Retrieve records from a table, optionally sorting and filtering results. Use **List Tables** to look up a table's field IDs. [See the documentation](https://airtable.com/developers/web/api/list-records)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `baseId` | `string` | Yes | The ID of the base to use, e.g. appXXXXXXXXXXXXXX. Use List Bases to look one up. |
| `tableId` | `string` | Yes | The ID of the table to use, e.g. tblXXXXXXXXXXXXXX. Use List Tables to look one up. |
| `sortFieldId` | `string` | No | Optionally provide a field ID to sort results by, e.g. fldXXXXXXXXXXXXXX. Use List Tables to look up a table's field IDs. To sort by multiple fields, use Filter by Formula instead. |
| `sortDirection` | `string` | No | If sorting by a field, which direction to sort by. |
| `maxRecords` | `integer` | No | The maximum number of records to return. Leave blank to retrieve all records. |
| `filterByFormula` | `string` | No | Optionally provide a formula (see info on the documentation) used to filter records. The formula will be evaluated for each record, and if the result is not 0, false, "", NaN, [], or #Error! the record will be included in the response. For example, to only include records where Name isn't empty, use NOT({Name} = ''). |
| `returnFieldsByFieldId` | `boolean` | No | If set to true, the returned field objects will have the field ID as the key, instead of the field name. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "airtable_oauth",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "airtable_oauth-list-records",
  arguments: {
    baseId: "Base",
    tableId: "Table",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "airtable_oauth-list-records",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    airtable_oauth: { authProvisionId: "apn_xxxxxxx" },
    baseId: "Base",
    tableId: "Table",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "airtable_oauth-list-records",
    "configured_props": {
      "airtable_oauth": { "authProvisionId": "apn_xxxxxxx" },
      "baseId": "Base",
      "tableId": "Table"
    }
  }'
```

---

- App: https://pipedream.com/apps/airtable-oauth.md · All apps: https://pipedream.com/apps
