> ## Documentation Index
> Fetch the complete documentation index at: https://docs.axionquant.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Economic Data

> Access macroeconomic indicators, datasets, and economic calendars

The Economic Data API provides access to macroeconomic indicators, historical economic datasets, and economic event calendars. Search through thousands of economic series or track upcoming economic releases that can impact markets.

## Methods

### search()

Search for economic data series by keyword or topic.

```typescript theme={null}
const results = await client.econ.search('GDP');
```

<ParamField path="query" type="string" required>
  Search query string (e.g., "GDP", "inflation", "unemployment")
</ParamField>

**Returns:** Array of economic series matching the search query

<CodeGroup>
  ```typescript TypeScript theme={null}
  const client = new Axion(apiKey);

  // Search for GDP-related series
  const gdpSeries = await client.econ.search('GDP');
  console.log(gdpSeries.data);

  // Search for inflation data
  const inflationSeries = await client.econ.search('inflation');
  console.log(inflationSeries.data);
  ```

  ```javascript JavaScript theme={null}
  const { Axion } = require('axion-sdk');
  const client = new Axion(apiKey);

  // Search for unemployment data
  client.econ.search('unemployment')
    .then(results => {
      console.log('Found series:', results.data);
    })
    .catch(error => {
      console.error('Search failed:', error.message);
    });
  ```

  ```python Python theme={null}
  from axion import Axion

  client = Axion(api_key)

  # Search for interest rate data
  results = client.econ.search('interest rate')
  print(results['data'])
  ```
</CodeGroup>

### dataset()

Retrieve historical data for a specific economic series.

```typescript theme={null}
const data = await client.econ.dataset('FRED/GDP');
```

<ParamField path="seriesId" type="string" required>
  The unique identifier for the economic data series (e.g., "FRED/GDP", "BLS/UNEMPLOYMENT")
</ParamField>

**Returns:** Historical time series data for the specified series

<CodeGroup>
  ```typescript TypeScript theme={null}
  const client = new Axion(apiKey);

  // Get GDP dataset
  const gdpData = await client.econ.dataset('FRED/GDP');
  console.log('GDP Data:', gdpData.data);

  // Get unemployment rate
  const unemploymentData = await client.econ.dataset('BLS/UNRATE');
  console.log('Latest unemployment:', unemploymentData.data[0]);
  ```

  ```javascript JavaScript theme={null}
  const { Axion } = require('axion-sdk');
  const client = new Axion(apiKey);

  client.econ.dataset('FRED/CPI')
    .then(response => {
      const data = response.data;
      console.log(`Retrieved ${data.length} data points`);
      console.log('Latest value:', data[0]);
    })
    .catch(error => {
      console.error('Failed to fetch dataset:', error.message);
    });
  ```
</CodeGroup>

### calendar()

Get upcoming economic events and releases with optional filtering.

```typescript theme={null}
const events = await client.econ.calendar({
  from: '2024-01-01',
  to: '2024-01-31',
  country: 'US',
  minImportance: 2
});
```

<ParamField path="params" type="object">
  Optional parameters to filter economic calendar events
</ParamField>

<ParamField path="params.from" type="string">
  Start date in YYYY-MM-DD format
</ParamField>

<ParamField path="params.to" type="string">
  End date in YYYY-MM-DD format
</ParamField>

<ParamField path="params.country" type="string">
  Two-letter country code (e.g., "US", "GB", "JP")
</ParamField>

<ParamField path="params.minImportance" type="number">
  Minimum importance level (1-3, where 3 is highest impact)
</ParamField>

<ParamField path="params.currency" type="string">
  Currency code to filter events (e.g., "USD", "EUR")
</ParamField>

<ParamField path="params.category" type="string">
  Event category (e.g., "GDP", "Employment", "Inflation")
</ParamField>

**Returns:** Array of economic calendar events

<CodeGroup>
  ```typescript TypeScript theme={null}
  const client = new Axion(apiKey);

  // Get high-impact US events for next month
  const events = await client.econ.calendar({
    from: '2024-01-01',
    to: '2024-01-31',
    country: 'US',
    minImportance: 2
  });

  console.log(`Found ${events.data.length} important events`);
  events.data.forEach(event => {
    console.log(`${event.date}: ${event.event}`);
  });
  ```

  ```javascript JavaScript theme={null}
  const { Axion } = require('axion-sdk');
  const client = new Axion(apiKey);

  // Get all EUR currency events
  client.econ.calendar({
    from: '2024-02-01',
    to: '2024-02-29',
    currency: 'EUR'
  })
    .then(response => {
      const events = response.data;
      console.log('Eurozone events:', events.length);
    })
    .catch(error => {
      console.error('Calendar fetch failed:', error.message);
    });
  ```

  ```python Python theme={null}
  from axion import Axion
  from datetime import datetime, timedelta

  client = Axion(api_key)

  # Get next week's events
  today = datetime.now()
  next_week = today + timedelta(days=7)

  events = client.econ.calendar(
    from_date=today.strftime('%Y-%m-%d'),
    to_date=next_week.strftime('%Y-%m-%d'),
    min_importance=1
  )

  for event in events['data']:
    print(f"{event['date']}: {event['event']}")
  ```
</CodeGroup>

## Common Use Cases

### Track Inflation Indicators

```typescript theme={null}
const client = new Axion(apiKey);

// Search for CPI data
const cpiSearch = await client.econ.search('Consumer Price Index');
const seriesId = cpiSearch.data[0].id;

// Get historical CPI data
const cpiData = await client.econ.dataset(seriesId);
console.log('Latest CPI:', cpiData.data[0]);
```

### Monitor Federal Reserve Decisions

```typescript theme={null}
const client = new Axion(apiKey);

// Get Fed-related events
const fedEvents = await client.econ.calendar({
  from: '2024-01-01',
  to: '2024-12-31',
  category: 'Central Bank',
  country: 'US',
  minImportance: 3
});

fedEvents.data.forEach(event => {
  console.log(`${event.date}: ${event.event}`);
});
```

### Compare International GDP Growth

```typescript theme={null}
const client = new Axion(apiKey);

async function compareGDP() {
  const countries = ['US', 'CN', 'JP', 'DE'];
  
  for (const country of countries) {
    const search = await client.econ.search(`${country} GDP`);
    if (search.data.length > 0) {
      const gdp = await client.econ.dataset(search.data[0].id);
      console.log(`${country} GDP:`, gdp.data[0]);
    }
  }
}

compareGDP();
```

## Error Handling

```typescript theme={null}
try {
  const events = await client.econ.calendar({
    from: '2024-01-01',
    to: '2024-01-31',
    country: 'US'
  });
  
  if (events.data.length === 0) {
    console.log('No events found for the specified period');
  } else {
    console.log(`Found ${events.data.length} events`);
  }
} catch (error) {
  if (error.message.includes('401')) {
    console.error('Authentication failed. Check your API key.');
  } else if (error.message.includes('404')) {
    console.error('Endpoint not found. Check the series ID.');
  } else {
    console.error('Request failed:', error.message);
  }
}
```

## Response Format

All economic data endpoints return a consistent response structure:

```typescript theme={null}
interface ApiResponse {
  data: any;  // Response data
  meta?: {    // Optional metadata
    total?: number;
    page?: number;
    limit?: number;
  };
}
```

## Rate Limits

The Economic Data API is subject to the same rate limits as other API endpoints. Check the [FAQ](/faq) for information about rate limits and usage quotas.
