List States and Counties
Federal Reserve Economic Data(FRED), maintained by the Federal Reserve Bank of St. Louis, is a vast database with over 816,000 economic time series covering banking, business, consumer price indexes, employment, GDP, interest rates, and more. These data are compiled from various sources including government agencies like the U.S. Census Bureau and the Bureau of Labor Statistics, offering a comprehensive resource for economic analysis and policymaking.
List states
Using Requests:
import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/fred/states?c={api_key}'
data = requests.get(url).json()
print(data)
Or using our package:
import tradingeconomics as te
te.login('your_api_key')
te.getFedRStates()
Using Requests:
const axios = require('axios');
(async () => {
const api_key = 'YOUR_API_KEY'
const response = await axios.get(`https://api.tradingeconomics.com/fred/states?c=${api_key}`)
console.log(response.data)
})()
Or using our package:
const te = require('tradingeconomics');
te.login('your_api_key');
data = te.getFred().then(function(data){
console.log(data)
});
Using Requests:
using (var httpClient = new HttpClient())
{
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/fred/states?c=your_api_key"))
{
request.Headers.TryAddWithoutValidation("Upgrade-Insecure-Requests", "1");
var response = await httpClient.SendAsync(request);
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
}
The response data format can be configured by appending the &f= parameter to the URL request.
name |
---|
Arkansas |
Illinois |
Indiana |
[{"name":"Arkansas"},{"name":"Illinois"},{"name":"Indiana"}]
name
Arkansas
Illinois
Indiana
<ArrayOfFredState xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/API.Models">
<FredState>
<name>Arkansas</name>
</FredState>
<FredState>
<name>Illinois</name>
</FredState>
<FredState>
<name>Indiana</name>
</FredState>
</ArrayOfFredState>
List counties
Using Requests:
import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/fred/counties/arkansas?c={api_key}'
data = requests.get(url).json()
print(data)
Or using our package:
te.getFedRStates(county = 'arkansas')
Using Requests:
const axios = require('axios');
(async () => {
const api_key = 'YOUR_API_KEY'
const response = await axios.get(`https://api.tradingeconomics.com/fred/counties/arkansas?c=${api_key}`)
console.log(response.data)
})()
Or using our package:
data = te.getFred(counties = 'arkansas').then(function(data){
console.log(data)
});
Using Requests:
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/fred/counties/arkansas?c=your_api_key"))
county |
---|
“Randolph County, AR” |
“Chicot County, AR” |
“Pine Bluff, AR” |
[{"county":"Randolph County, AR"},{"county":"Chicot County, AR"},{"county":"Pine Bluff, AR"}]
county
"Randolph County, AR"
"Chicot County, AR"
"Pine Bluff, AR"
<ArrayOfFredCounty xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/API.Models">
<FredCounty>
<county>Little River County, AR</county>
</FredCounty>
<FredCounty>
<county>Craighead County, AR</county>
</FredCounty>
<FredCounty>
<county>St. Francis County, AR</county>
</FredCounty>
</ArrayOfFredCounty>
Response fields
Field ‘List states’
Field | Type | Description | Example |
---|---|---|---|
Name | string | State name | “Arkansas” |
Field ‘List counties’
Field | Type | Description | Example |
---|---|---|---|
County | string | County name | “Little River County, AR” |