DEV Community

carrierone
carrierone

Posted on

FRED and BLS Economic Indicator Data for Developers

FRED and BLS Economic Indicator Data for Developers

As a developer working on a macro trading or analytics app, you often need access to economic indicators such as CPI (Consumer Price Index), NFP (Non-Farm Payroll), GDP (Gross Domestic Product), PCE (Personal Consumption Expenditure), and unemployment rates. These data points are crucial for making informed decisions in your applications.

Problem: Getting Real-Time Data Feeds

To get the most up-to-date CPI, NFP, GDP, and unemployment figures, you need to consume real-time API feeds. One such resource is the FRED (Federal Reserve Economic Data) service, which provides access to various economic data series from a variety of sources.

Solution: Fetching Data with Python

Here's an example of how you can fetch these indicators using Python:


python
import requests

def get_economic_data(indicator_type):
    url = f"https://api.verilexdata.com/api/v1/econ/stats?indicator={indicator_type}"
    response = requests.get(url)
    if response.status_code == 200:
        data = response.json()
        return data['results'][0] if data else None
    else:
        print(f"Failed to fetch data: {response.text}")
        return None

# Example usage for CPI, NFP, GDP, and unemployment rates
Enter fullscreen mode Exit fullscreen mode

Top comments (0)