Skip to content

BLS

Retrieve labor, employment, price and productivity series with period codes, footnotes, calculations and survey metadata

Connector software
Free and open source
Service credentials
Optional
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/bls/index.md to help me query BLS 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.

Discover BLS surveys

Example output · captured
Connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
SELECT survey_abbreviation, survey_name
FROM bls.main.surveys()
ORDER BY survey_abbreviation
Result · first 5 rows
survey_abbreviation survey_name
AP Consumer Price Index - Average Price Data
BD Business Employment Dynamics
BG Collective Bargaining Agreements-State and Local Government
BP Collective Bargaining Agreements-Private Sector
CA Biennial Nonfatal Case and Demographic numbers and rates: selected characterist…

Quick start

Choose where to run BLS, 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 'bls' AS bls (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-bls-worker'
);

3. Add service credentials (optional)

Works without a key; a free registration key raises limits and adds catalog features. Replace the placeholders with your service settings.

bls_api credentials

Optional BLS API registration key for higher limits and catalog/calculation features.

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

4. Run a query

query.sql
SELECT survey_abbreviation, survey_name
FROM bls.main.surveys()
ORDER BY survey_abbreviation
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 'bls' AS bls (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-bls-worker'
);

Overview

US Bureau of Labor Statistics time series for employment, unemployment, prices, pay and productivity as SQL tables, keeping BLS period codes, footnotes and survey metadata. Works without a key; a free BLS registration key raises the limits.

Catalog

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

bls 1 schema
main 5 functions

BLS time series as table functions: observations, latest values, popular series and survey metadata.

Schema examples (8)
Examples (8)

Discover BLS surveys

SELECT survey_abbreviation, survey_name
FROM bls.main.surveys()
ORDER BY survey_abbreviation;
Result · first 5 rows
survey_abbreviation survey_name
AP Consumer Price Index - Average Price Data
BD Business Employment Dynamics
BG Collective Bargaining Agreements-State and Local Government
BP Collective Bargaining Agreements-Private Sector
CA Biennial Nonfatal Case and Demographic numbers and rates: selected characterist…

Discover popular series

SELECT series_id
FROM bls.main.popular_series(survey := 'CU')
ORDER BY series_id;

Label popular series with the name of the survey they belong to; a BLS series identifier starts with its two-letter survey abbreviation

SELECT p.series_id, s.survey_abbreviation, s.survey_name
FROM bls.main.popular_series() AS p
JOIN bls.main.surveys() AS s ON s.survey_abbreviation = left(p.series_id, 2)
ORDER BY p.series_id;

Retrieve labor statistics

SELECT year, period, value
FROM bls.main.observations(['LNS14000000'], 2024, 2024)
ORDER BY year, period;
4 more examples

Label 2024 annual averages (period M13) with each series' published title and seasonality; BLS publishes annual averages for not seasonally adjusted series such as LNU04000000 and CUUR0000SA0, and they require a BLS registration key

SELECT o.series_id, m.series_title, m.seasonality, o.value AS annual_average
FROM bls.main.observations(['LNU04000000', 'CUUR0000SA0'], 2024, 2024, annual_average := true) AS o
JOIN bls.main.series(['LNU04000000', 'CUUR0000SA0'], 2024, 2024) AS m USING (series_id)
WHERE o.period = 'M13'
ORDER BY o.series_id;

Inspect series metadata

SELECT series_id, series_title, seasonality
FROM bls.main.series(['LNS14000000'], 2024, 2024)
ORDER BY series_id;

Read latest observation

SELECT series_id, year, period, value
FROM bls.main.latest('LNS14000000')
ORDER BY year, period;

Compare the latest unemployment rate with the same period one year earlier and the change; the observations window (2023-2026) must include the year before the latest period, so move it forward as new years are published

SELECT l.year, l.period, l.value AS latest_value,
  p.value AS year_earlier_value, l.value - p.value AS change
FROM bls.main.latest('LNS14000000') AS l
JOIN bls.main.observations(['LNS14000000'], 2023, 2026) AS p ON p.series_id = l.series_id AND p.period = l.period AND p.year = l.year - 1
ORDER BY l.year, l.period;
Table functions
latest (series_id VARCHAR, max_rows := BIGINT) 2 examples

Retrieve BLS's latest observation for a single series. Latest refers to observation period, not a real-time publication timestamp; use observations for reproducible year windows.

Positional arguments
series_id VARCHAR
BLS series identifier, such as LNS14000000.
Named arguments
max_rows := BIGINT
Explicit cap on emitted rows; select series and years to reduce upstream work. · default 100000
Returns columns
series_id VARCHAR
BLS series identifier.
year BIGINT
Year of the observation.
period VARCHAR
Native period code; M13 denotes an annual average, not a thirteenth month.
period_name VARCHAR
Source period label.
value DOUBLE
Published numeric value; recognized unavailable/suppressed markers become NULL.
value_text VARCHAR
Original value text, preserving numeric precision and missing markers.
latest BOOLEAN
Source latest flag; NULL when BLS does not supply it.
footnotes_json VARCHAR
Source footnotes including preliminary/revised flags.
calculations_json VARCHAR
Net/percent changes when requested and available.
aspects_json VARCHAR
Survey-specific aspects, such as relative standard errors.
catalog_json VARCHAR
Source series catalog when include_catalog is enabled.
Examples (2)

Read latest observation

SELECT series_id, year, period, value
FROM bls.main.latest('LNS14000000')
ORDER BY year, period;

Compare the latest unemployment rate with the same period one year earlier and the change; the observations window (2023-2026) must include the year before the latest period, so move it forward as new years are published

SELECT l.year, l.period, l.value AS latest_value,
  p.value AS year_earlier_value, l.value - p.value AS change
FROM bls.main.latest('LNS14000000') AS l
JOIN bls.main.observations(['LNS14000000'], 2023, 2026) AS p ON p.series_id = l.series_id AND p.period = l.period AND p.year = l.year - 1
ORDER BY l.year, l.period;
Link
observations (series_ids VARCHAR[], start_year BIGINT, end_year BIGINT, annual_average := BOOLEAN, aspects := BOOLEAN, calculations := BOOLEAN, include_catalog := BOOLEAN, max_rows := BIGINT) 2 examples

Retrieve observations for a batch of unique series IDs and inclusive start/end years. Registered access supports 50 series and 20 years; unregistered access supports 25 and 10. Optional annual averages, catalog, calculations and aspects require registration. BLS warnings fail the query to prevent partial results.

Positional arguments
series_ids VARCHAR[]
Nonempty unique BLS series identifiers; up to 50 registered or 25 unregistered.
start_year BIGINT
First observation year, inclusive.
end_year BIGINT
Last observation year, inclusive; at most 20 registered or 10 unregistered years.
Named arguments
annual_average := BOOLEAN
Include annual averages where supported; requires a registration key. · default false
aspects := BOOLEAN
Request survey-specific aspects; requires a registration key. · default false
calculations := BOOLEAN
Request source net/percent changes; requires a registration key. · default false
include_catalog := BOOLEAN
Include source series catalog metadata; requires a registration key. · default false
max_rows := BIGINT
Explicit cap on emitted rows; select series and years to reduce upstream work. · default 100000
Returns columns
series_id VARCHAR
BLS series identifier.
year BIGINT
Year of the observation.
period VARCHAR
Native period code; M13 denotes an annual average, not a thirteenth month.
period_name VARCHAR
Source period label.
value DOUBLE
Published numeric value; recognized unavailable/suppressed markers become NULL.
value_text VARCHAR
Original value text, preserving numeric precision and missing markers.
latest BOOLEAN
Source latest flag; NULL when BLS does not supply it.
footnotes_json VARCHAR
Source footnotes including preliminary/revised flags.
calculations_json VARCHAR
Net/percent changes when requested and available.
aspects_json VARCHAR
Survey-specific aspects, such as relative standard errors.
catalog_json VARCHAR
Source series catalog when include_catalog is enabled.
Examples (2)

Retrieve labor statistics

SELECT year, period, value
FROM bls.main.observations(['LNS14000000'], 2024, 2024)
ORDER BY year, period;

Label 2024 annual averages (period M13) with each series' published title and seasonality; BLS publishes annual averages for not seasonally adjusted series such as LNU04000000 and CUUR0000SA0, and they require a BLS registration key

SELECT o.series_id, m.series_title, m.seasonality, o.value AS annual_average
FROM bls.main.observations(['LNU04000000', 'CUUR0000SA0'], 2024, 2024, annual_average := true) AS o
JOIN bls.main.series(['LNU04000000', 'CUUR0000SA0'], 2024, 2024) AS m USING (series_id)
WHERE o.period = 'M13'
ORDER BY o.series_id;
Link
series (series_ids VARCHAR[], start_year BIGINT, end_year BIGINT, max_rows := BIGINT) 1 example

Retrieve source catalog metadata for series IDs and an explicit year window. Requires BLS registration. The BLS API returns catalog metadata alongside observations; this function emits only the catalog.

Positional arguments
series_ids VARCHAR[]
Nonempty unique BLS series identifiers; up to 50 registered or 25 unregistered.
start_year BIGINT
First observation year, inclusive.
end_year BIGINT
Last observation year, inclusive; at most 20 registered or 10 unregistered years.
Named arguments
max_rows := BIGINT
Explicit cap on emitted rows; select series and years to reduce upstream work. · default 100000
Returns columns
series_id VARCHAR
BLS series identifier.
series_title VARCHAR
Full published description.
survey_name VARCHAR
Survey name.
survey_abbreviation VARCHAR
Survey abbreviation.
seasonality VARCHAR
Seasonal adjustment description.
measure_data_type VARCHAR
Published measurement type.
area VARCHAR
Published geography.
catalog_json VARCHAR
Complete source catalog, including survey-specific dimensions.
Example

Inspect series metadata

SELECT series_id, series_title, seasonality
FROM bls.main.series(['LNS14000000'], 2024, 2024)
ORDER BY series_id;
Link
surveys (max_rows := BIGINT, survey := VARCHAR) 1 example

List BLS surveys or request capability flags for a specific survey using the optional survey argument.

Named arguments
max_rows := BIGINT
Explicit cap on emitted rows; select series and years to reduce upstream work. · default 100000
survey := VARCHAR
Optional two-letter survey abbreviation; empty requests all surveys or overall popular series. · default ""
Returns columns
survey_abbreviation VARCHAR
BLS survey abbreviation.
survey_name VARCHAR
Published survey name.
allows_net_change BOOLEAN
Whether the survey supports net-change calculations; NULL if not supplied.
allows_percent_change BOOLEAN
Whether percent changes are supported; NULL if not supplied.
has_annual_averages BOOLEAN
Whether optional annual averages are supported; NULL if not supplied.
Example

Discover BLS surveys

SELECT survey_abbreviation, survey_name
FROM bls.main.surveys()
ORDER BY survey_abbreviation;
Result · first 5 rows
survey_abbreviation survey_name
AP Consumer Price Index - Average Price Data
BD Business Employment Dynamics
BG Collective Bargaining Agreements-State and Local Government
BP Collective Bargaining Agreements-Private Sector
CA Biennial Nonfatal Case and Demographic numbers and rates: selected characterist…
Link

Credentials

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

bls_api

How to get these credentials

Optional BLS API registration key for higher limits and catalog/calculation features.

secret.sql
CREATE SECRET bls_api (
    TYPE bls_api,
    api_key '<BLS_API_API_KEY>'  -- secret
);
Key Type Required Description
api_key secret VARCHAR — Your BLS registration key.

The worker doesn't mark which keys are required.

Create the secret in the same session, after attaching bls — 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

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

SELECT * FROM bls.main.surveys() LIMIT 0;

Uses surveys

Discover popular series

SELECT series_id
FROM bls.main.popular_series(survey := 'CU')
ORDER BY series_id

Uses popular_series

Label popular series with the name of the survey they belong to; a BLS series identifier starts with its two-letter survey abbreviation

SELECT p.series_id, s.survey_abbreviation, s.survey_name
FROM bls.main.popular_series() AS p
JOIN bls.main.surveys() AS s ON s.survey_abbreviation = left(p.series_id, 2)
ORDER BY p.series_id

Uses popular_seriessurveys

Retrieve labor statistics

SELECT year, period, value
FROM bls.main.observations(['LNS14000000'], 2024, 2024)
ORDER BY year, period

Uses observations

Inspect series metadata

SELECT series_id, series_title, seasonality
FROM bls.main.series(['LNS14000000'], 2024, 2024)
ORDER BY series_id

Uses series

Read latest observation

SELECT series_id, year, period, value
FROM bls.main.latest('LNS14000000')
ORDER BY year, period

Uses latest

2 more examples in the Catalog, each listed under the table or function it uses.

BLS 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.