Skip to content

BEA

Discover BEA datasets, parameters and parameter values, then retrieve national, regional, industry and international economic accounts

Connector software
Free and open source
Service credentials
Required
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/bea/index.md to help me query BEA with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Read annual US economic accounts

Uses your connected account. Set up the connector and credentials to run it with your data.

SELECT time_period, line_number, value, unit
FROM bea.main.data('NIPA', '{"TableName":"T10101","Frequency":"A","Year":"2024"}')
ORDER BY time_period, line_number

Quick start

Choose where to run BEA, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'bea' AS bea (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-bea-worker'
);

3. Add service credentials

After attaching, create the secret for the service you want to query in the same SQL session. Replace the placeholders with your service settings.

bea_api credentials

BEA API user key; obtain one from https://apps.bea.gov/api/signup/.

Get these credentials →
secret.sql
CREATE SECRET bea_api (
    TYPE bea_api,
    api_key '<BEA_API_API_KEY>'  -- secret
);
Credential fields and requirements →

4. Run a query

query.sql
SELECT time_period, line_number, value, unit
FROM bea.main.data('NIPA', '{"TableName":"T10101","Frequency":"A","Year":"2024"}')
ORDER BY time_period, line_number
More example queries →
Technical details
Verified connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'bea' AS bea (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-bea-worker'
);

Overview

US Bureau of Economic Analysis national, regional, industry and international economic accounts, such as GDP and personal income, as SQL tables with dataset and parameter discovery. Needs a free BEA API key.

Catalog

Everything bea exposes once attached — read straight from the worker's released build.

bea 1 schema
main 5 functions

BEA economic accounts as table functions: dataset, parameter and value discovery plus data retrieval.

Schema examples (7)
Examples (7)

Discover BEA datasets

SELECT dataset_name, description
FROM bea.main.datasets()
ORDER BY dataset_name;

Discover dataset parameters

SELECT parameter_name, is_required, description
FROM bea.main.parameters('NIPA')
ORDER BY parameter_name;

Discover parameter values

SELECT key, description
FROM bea.main.parameter_values('Regional', 'LineCode', filters_json := '{"TableName":"SAINC1"}')
ORDER BY key;

Retrieve economic accounts

SELECT time_period, line_number, value, unit
FROM bea.main.data('NIPA', '{"TableName":"T10101","Frequency":"A","Year":"2024"}')
ORDER BY time_period, line_number;
3 more examples

Attach source footnote text to each 2024 real GDP growth line by joining data rows to notes on the note references they cite

SELECT TRY_CAST(d.line_number AS INTEGER) AS line_no, d.line_description,
  d.value, d.unit, n.note_text
FROM bea.main.data('NIPA', '{"TableName":"T10101","Frequency":"A","Year":"2024"}') AS d
LEFT JOIN bea.main.notes('NIPA', '{"TableName":"T10101","Frequency":"A","Year":"2024"}') AS n ON list_contains(string_split(d.note_ref, ','), n.note_ref)
ORDER BY line_no, n.note_ref, n.note_text;

Compare each state's 2023 share of the 50-state-plus-DC personal income total (SAINC1 line 1) with its share of population (line 2) and the gap between them, largest income share first

WITH income AS (SELECT geo_fips, geo_name, round(100 * value / sum(value) OVER (), 2) AS income_share_pct FROM bea.main.data('Regional', '{"TableName":"SAINC1","LineCode":"1","GeoFips":"STATE","Year":"2023"}') WHERE geo_fips BETWEEN '01000' AND '56000'), population AS (SELECT geo_fips, round(100 * value / sum(value) OVER (), 2) AS population_share_pct FROM bea.main.data('Regional', '{"TableName":"SAINC1","LineCode":"2","GeoFips":"STATE","Year":"2023"}') WHERE geo_fips BETWEEN '01000' AND '56000') SELECT i.geo_fips, i.geo_name, i.income_share_pct, p.population_share_pct, round(i.income_share_pct - p.population_share_pct, 2) AS share_gap_pct
FROM income AS i
JOIN population AS p ON p.geo_fips = i.geo_fips
ORDER BY i.income_share_pct DESC NULLS LAST, i.geo_fips;

Read source notes

SELECT note_ref, note_text
FROM bea.main.notes('NIPA', '{"TableName":"T10101","Frequency":"A","Year":"2024"}')
ORDER BY note_ref, note_text;
Table functions
data (dataset VARCHAR, parameters_json VARCHAR, max_rows := BIGINT) 3 examples

Retrieve economic observations for a dataset. Common dimensions are typed; attributes_json preserves every dataset-specific dimension. Units and multipliers are retained without rescaling.

Positional arguments
dataset VARCHAR
Dataset identifier from datasets, such as NIPA or Regional.
parameters_json VARCHAR
JSON object of dataset parameters, e.g. TableName, Frequency and Year. Use comma-separated strings for multiple values.
Named arguments
max_rows := BIGINT
Explicit cap on emitted rows; does not reduce BEA's response size. · default 100000
Returns columns
dataset_name VARCHAR
Requested BEA dataset.
time_period VARCHAR
Source period, such as 2024, 2024Q1 or 2024M01; not a publication date.
value DOUBLE
Numeric value in published units; suppression and missing markers become NULL.
value_text VARCHAR
Unmodified published value text, preserving precision and suppression codes.
unit VARCHAR
Published CL_UNIT or UnitOfMeasure, if supplied.
unit_multiplier BIGINT
Base-10 exponent UNIT_MULT; value is not automatically rescaled.
table_name VARCHAR
TableName or TableID, if supplied.
line_number VARCHAR
LineNumber or LineCode, if supplied.
line_description VARCHAR
LineDescription or Description, if supplied.
geo_fips VARCHAR
Geography code kept as text to preserve leading zeroes.
geo_name VARCHAR
Geography name, if supplied.
note_ref VARCHAR
Source note references for this row.
attributes_json VARCHAR
Complete data row, including industry, country and other dimensions.
notes_json VARCHAR
Source result notes qualifying these observations.
metadata_json VARCHAR
Result-level units, dimensions and production metadata; excludes Request.
Examples (3)

Retrieve economic accounts

SELECT time_period, line_number, value, unit
FROM bea.main.data('NIPA', '{"TableName":"T10101","Frequency":"A","Year":"2024"}')
ORDER BY time_period, line_number;

Attach source footnote text to each 2024 real GDP growth line by joining data rows to notes on the note references they cite

SELECT TRY_CAST(d.line_number AS INTEGER) AS line_no, d.line_description,
  d.value, d.unit, n.note_text
FROM bea.main.data('NIPA', '{"TableName":"T10101","Frequency":"A","Year":"2024"}') AS d
LEFT JOIN bea.main.notes('NIPA', '{"TableName":"T10101","Frequency":"A","Year":"2024"}') AS n ON list_contains(string_split(d.note_ref, ','), n.note_ref)
ORDER BY line_no, n.note_ref, n.note_text;

Compare each state's 2023 share of the 50-state-plus-DC personal income total (SAINC1 line 1) with its share of population (line 2) and the gap between them, largest income share first

WITH income AS (SELECT geo_fips, geo_name, round(100 * value / sum(value) OVER (), 2) AS income_share_pct FROM bea.main.data('Regional', '{"TableName":"SAINC1","LineCode":"1","GeoFips":"STATE","Year":"2023"}') WHERE geo_fips BETWEEN '01000' AND '56000'), population AS (SELECT geo_fips, round(100 * value / sum(value) OVER (), 2) AS population_share_pct FROM bea.main.data('Regional', '{"TableName":"SAINC1","LineCode":"2","GeoFips":"STATE","Year":"2023"}') WHERE geo_fips BETWEEN '01000' AND '56000') SELECT i.geo_fips, i.geo_name, i.income_share_pct, p.population_share_pct, round(i.income_share_pct - p.population_share_pct, 2) AS share_gap_pct
FROM income AS i
JOIN population AS p ON p.geo_fips = i.geo_fips
ORDER BY i.income_share_pct DESC NULLS LAST, i.geo_fips;
Link
datasets (max_rows := BIGINT) 1 example

List current dataset identifiers and descriptions before choosing an economic account.

Named arguments
max_rows := BIGINT
Explicit cap on emitted rows; does not reduce BEA's response size. · default 100000
Returns columns
dataset_name VARCHAR
BEA dataset identifier used in subsequent calls.
description VARCHAR
BEA's description of this dataset.
Example

Discover BEA datasets

SELECT dataset_name, description
FROM bea.main.datasets()
ORDER BY dataset_name;
Link
notes (dataset VARCHAR, parameters_json VARCHAR, max_rows := BIGINT) 1 example

Retrieve source footnotes separately, including result-level notes when no observations are returned. Uses the same parameters_json as data.

Positional arguments
dataset VARCHAR
Dataset identifier from datasets, such as NIPA or Regional.
parameters_json VARCHAR
JSON object of dataset parameters, e.g. TableName, Frequency and Year. Use comma-separated strings for multiple values.
Named arguments
max_rows := BIGINT
Explicit cap on emitted rows; does not reduce BEA's response size. · default 100000
Returns columns
dataset_name VARCHAR
Requested BEA dataset.
note_ref VARCHAR
Note identifier referenced by observations or result metadata.
note_text VARCHAR
Source note text, including suppression definitions.
Example

Read source notes

SELECT note_ref, note_text
FROM bea.main.notes('NIPA', '{"TableName":"T10101","Frequency":"A","Year":"2024"}')
ORDER BY note_ref, note_text;
Link
parameter_values (dataset VARCHAR, parameter VARCHAR, filters_json := VARCHAR, max_rows := BIGINT) 1 example

Retrieve allowed values. Nonempty filters_json selects GetParameterValuesFiltered; BEA supports this for selected datasets only.

Positional arguments
dataset VARCHAR
Dataset identifier from datasets, such as NIPA or Regional.
parameter VARCHAR
Parameter name from parameters, such as TableName.
Named arguments
filters_json := VARCHAR
JSON object of other dataset parameters. Nonempty filters use GetParameterValuesFiltered, supported by selected datasets. · default "{}"
max_rows := BIGINT
Explicit cap on emitted rows; does not reduce BEA's response size. · default 100000
Returns columns
dataset_name VARCHAR
Requested BEA dataset.
parameter_name VARCHAR
Requested parameter.
key VARCHAR
Parameter value to pass to data.
description VARCHAR
Source description of the value.
attributes_json VARCHAR
All source attributes, preserving dataset-specific metadata.
Example

Discover parameter values

SELECT key, description
FROM bea.main.parameter_values('Regional', 'LineCode', filters_json := '{"TableName":"SAINC1"}')
ORDER BY key;
Link
parameters (dataset VARCHAR, max_rows := BIGINT) 1 example

Inspect required parameters, defaults and multiple-value support for a dataset.

Positional arguments
dataset VARCHAR
Dataset identifier from datasets, such as NIPA or Regional.
Named arguments
max_rows := BIGINT
Explicit cap on emitted rows; does not reduce BEA's response size. · default 100000
Returns columns
dataset_name VARCHAR
Requested BEA dataset.
parameter_name VARCHAR
Name to use in parameters_json.
data_type VARCHAR
Upstream parameter type.
description VARCHAR
Meaning of the parameter.
is_required BOOLEAN
Whether BEA requires this parameter.
default_value VARCHAR
BEA's default value, when declared.
multiple_accepted BOOLEAN
Whether comma-separated values are accepted.
all_value VARCHAR
Special value requesting all entries, when supported.
attributes_json VARCHAR
Complete source parameter metadata as JSON.
Example

Discover dataset parameters

SELECT parameter_name, is_required, description
FROM bea.main.parameters('NIPA')
ORDER BY parameter_name;
Link

Credentials

The secret type bea declares, as reported by the worker itself.

bea_api

How to get these credentials

BEA API user key; obtain one from https://apps.bea.gov/api/signup/.

secret.sql
CREATE SECRET bea_api (
    TYPE bea_api,
    api_key '<BEA_API_API_KEY>'  -- secret
);
Key Type Required Description
api_key secret VARCHAR — Your BEA API user key.

The worker doesn't mark which keys are required.

Create the secret in the same session, after attaching bea — the worker registers its secret types at ATTACH. Keys marked secret are masked in duckdb_secrets(); angle-bracket values are placeholders. Read credentials from your environment or secret store in your application and pass them through your SQL client’s parameter bindings. Keep real values out of saved SQL and history. Native DuckDB and Haybarn do not provide a SQL getenv() function.

Try these queries

datasets_columns — Show the columns datasets() returns without an API key: binding the function with LIMIT 0 resolves its schema and makes no BEA API request

SELECT * FROM bea.main.datasets() LIMIT 0;

Uses datasets

Discover BEA datasets

SELECT dataset_name, description
FROM bea.main.datasets()
ORDER BY dataset_name

Uses datasets

Discover dataset parameters

SELECT parameter_name, is_required, description
FROM bea.main.parameters('NIPA')
ORDER BY parameter_name

Uses parameters

Discover parameter values

SELECT key, description
FROM bea.main.parameter_values('Regional', 'LineCode', filters_json := '{"TableName":"SAINC1"}')
ORDER BY key

Uses parameter_values

Attach source footnote text to each 2024 real GDP growth line by joining data rows to notes on the note references they cite

SELECT TRY_CAST(d.line_number AS INTEGER) AS line_no, d.line_description,
  d.value, d.unit, n.note_text
FROM bea.main.data('NIPA', '{"TableName":"T10101","Frequency":"A","Year":"2024"}') AS d
LEFT JOIN bea.main.notes('NIPA', '{"TableName":"T10101","Frequency":"A","Year":"2024"}') AS n ON list_contains(string_split(d.note_ref, ','), n.note_ref)
ORDER BY line_no, n.note_ref, n.note_text

Uses datanotes

Read source notes

SELECT note_ref, note_text
FROM bea.main.notes('NIPA', '{"TableName":"T10101","Frequency":"A","Year":"2024"}')
ORDER BY note_ref, note_text

Uses notes

1 more example in the Catalog, each listed under the table or function it uses.

BEA is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.