Skip to main content

image Downloads image

pip install datapungi_fed

datapungi_fed

datapungi_fed is a Python interface to the FRED and GeoFRED APIs. It fetches Federal Reserve economic data and returns clean pandas DataFrames, together with the raw request and a reproducible code snippet upon demand.

Key features

  • One-line access to any FRED time series: dpf.ts('GDP')
  • Full access to all FRED and GeoFRED endpoints through quick entry points tracking FRED's structure (eg. "dpf.series.tags('GDP')")
  • Optional verbose output: DataFrame + raw requests.Response + reproducible code
  • API keys handled through environment variables, or passed strings.

Quick start

The FRED API is built around a dataset called "series" of hundreds of thousands of time-series. This package provides a quick access to it:

import datapungi_fed as dpf

# Can request one or more variables at once
series = dpf.ts('GDP')
print(series.tail())

series = dpf.ts(['GDP','GNP'])
print(series.tail())

# some metadata is already provided 
print(series.attrs['meta'])  # response metadata

Output:

                GDP
2024-01-01  27939.0
2024-04-01  28202.8
2024-07-01  28488.5
2024-10-01  28949.2

NOTE: dpf.ts will parallelize data fetching from FRED, whereas dpf.series will not.

Setting up the API key

You need a free FRED API key from https://research.stlouisfed.org/docs/api/api_key.html.

Recommended: environment variable

export API_KEY_FED=your_key_here

Pass directly

import datapungi_fed as dpf

client = dpf.Client(api_key='your_key_here')

Use an environment variable

import datapungi_fed as dpf

client = dpf.Client()  # reads API_KEY_FED from the environment

Store in a file

import json

import datapungi_fed as dpf

with open('/path/to/key.json') as f:
    client = dpf.Client(api_key=json.load(f)['API_KEY_FED'])

Module-level shortcuts like dpf.ts('GDP') still work as long as API_KEY_FED is set in the environment.

Working with data

Available database groups:

FRED database group description
categories Categories of datasets - 8 top categories (eg, National Accounts, Prices) that break down into subgroups
releases Release groups of data - about 300 (eg, Western Hemisphere Regional Economic Outlook, Penn World Table)
series About 600,000 time series provided by various sources
sources List of data sources - about 90 data providers (eg, IMF and Bank of Mexico)
tags Tags applied to time series (eg, location, data source, frequency) - about 5,000 tags
geo Harvest data and shape files found in GeoFRED
datasetlist list of all (FRED and GeoFRED) databases

The above "dpf.ts('GDP')" calls are quick taps to the "dpf.series" data.

series

The series datasets provides data and metadata information on a specific time-series, besides searching tools.

Available databases in the series group:

database Description
series metadata of a series
search search for a series
observations actual series data
categories FED categories associated to the series
release The release table of the series
tags Tags associated to the series
updates List of series updated (at given parameters)
vintagedates Dates when a series were updated

For example:

# the following are the same, they all call dpf.series.observations:
dpf.ts('gdp')
dpf.series('gdp')
dpf.series.observations('gdp')

# metadata
dpf.series.series('gdp')

# search
dpf.series.search('GDP deflator for the US')
dpf.series.search(search_text='monetary+service+index')
dpf.series.search.tags(series_search_text='monetary+service+index')
dpf.series.search.related_tags(series_search_text='mortgage+rate', tag_names='30-year;frb')

See what is available

import datapungi_fed as dpf

dpf.datasetlist()

Explore categories, releases, sources, and tags

There are hundreds of thousands of time-series available at the FRED API, navigating them is non-trivial. Navigate via internal FED classification scheme

import datapungi_fed as dpf

# This is a graph, with starting point "0" which you can navigate with:
#  - use the children function to find the category of interest
#  - once there, use the series function to get the list of series of that category
dpf.category.children(0) #get the children categories of the starting point, 
dpf.category.series(32442)
dpf.category(32442) # get info on the 32442 category

Navigate via information on the release information

import datapungi_fed as dpf

dpf.release() # all 337 or so release sources (eg, id=1132, name = Dallas Fed Energy Survey)

Explore also via tags and sources with "dpf.tag" and "dpf.source"

dpf.tags.tags(tag_names='monetary+aggregates;weekly')
dpf.tags.related_tags(tag_names='monetary+aggregates;weekly')
dpf.tags.tags.series(tag_names='slovenia;food;oecd')

Releases

Another way to navigate the data is through releases - a bundled release of series around a theme. For these use the

# There is about 300 release groups of data
dpf.release()

# get a release of interest (say Z.1 - Fininancial Accounts data, release_id = 52), 
# there are the series included on that release:
dpf.release.series(52) #52 is the id of Z.1 release table, read from the above.

# get the dates the data set was released:
# Note: set "include_release_dates_with_no_data" to true if you want future 
#       release dates.
dpf.release.dates(52,realtime_start='2026-01-01',include_release_dates_with_no_data='true')

# Calendar of US economic data releases for 2027 year:
#  NOTE: use the offset option to get the entire dataset, with increments of 
#        multiples of 1000
dpf.release.releases.dates(realtime_start="2027-01-01",realtime_end="2027-12-31",include_release_dates_with_no_data='true')

Get GeoFRED data

import datapungi_fed as dpf

dpf.geo(series_id='WIPCPI')
dpf.geo.shapes('bea')
dpf.geo.meta(series_id='SMU56000000500000001')
dpf.geo(series_id='WIPCPI', start_date='2012-01-01')
dpf.geo.data(series_group='882', date='2013-01-01', region_type='state', units='Dollars', frequency='a', season='NSA')

Code snippets

Use verbose=True to get the raw request and a standalone code snippet:

import datapungi_fed as dpf

result = dpf.series('GNP', verbose=True)

result['dataFrame']  # pandas DataFrame
result['request']    # requests.Response
result['code']       # string of code that reproduces the query

Running tests

The tests are recorded with pytest-recording/vcrpy. Cassettes are committed, so the suite runs without a real API key by default.

# Run the full test suite (no API key needed)
pytest datapungi_fed/tests

# CI-friendly subset
pytest -q datapungi_fed/tests/test_driversCI.py

# Full suite
pytest datapungi_fed/tests/test_drivers.py

# Re-record cassettes (requires a real key)
API_KEY_FED=your_key pytest datapungi_fed/tests

Or from Python:

import datapungi_fed as dpf

dpf.tests.runTests()  # opens HTML report in a browser

Requirements

  • Python >= 3.13
  • requests, pandas, pyyaml

License

MIT

Metadata

Release files for datapungi-fed 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datapungi-fed 0.6.0
File Size Uploaded Provenance Actions
datapungi_fed-0.6.0.tar.gz 1.2 MB Without provenance Details for datapungi_fed-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for datapungi-fed 0.6.0
File Interpreter ABI Platform Actions
datapungi_fed-0.6.0-py3-none-any.whl Python 3 none any Details for datapungi_fed-0.6.0-py3-none-any.whl

Total release size: 2.6 MB

Release files / datapungi_fed-0.6.0.tar.gz

Download URL datapungi_fed-0.6.0.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
bcea594c40151cede2f9be574c10228426e599e2ffed7f7069f7d28afb9bf48f
BLAKE2b-256 checksum
How to use checksums
2388ce9b521edb51c5ab140db5a099e285f00875c783c2b9ae4d6a586931844a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / datapungi_fed-0.6.0-py3-none-any.whl

Download URL datapungi_fed-0.6.0-py3-none-any.whl
Size 1.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
820c82586f9d2a228acc04aade71eb55c63738d5c6e1f5d814888f4e0945162c
BLAKE2b-256 checksum
How to use checksums
335d687a071c409e0e4a3ce685ce99f951b923384c53901aa1c23f0f4de12b05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for datapungi-fed 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page