The US Census Bureau provides various APIs and data sets on demographics and businesses
The US Census Bureau offers APIs and data sets on demographics and businesses.
import requests
api_key = "YOUR_API_KEY"
url = "https://api.census.gov/data/2020/dec/sf1"
params = {
"get": "NAME,P1_001N",
"for": "state:01",
"key": api_key
}
try:
response = requests.get(url, params=params)
response.raise_for_status() # Raise an exception for HTTP errors
data = response.json()
print(data)
except requests.exceptions.RequestException as e:
print(f"Error: {e}")Last 50 checks (10 min intervals)