Documentation > Workflows & Code > Access Supplemental Data > NHGIS

Access NHGIS Supplemental Data

Below we provide examples in R, Python and curl showing how to work with our API to access NHGIS supplemental data.

The Python and R examples are currently implemented using HTTP and JSON libraries to make and parse RESTful HTTP calls. As support for using the IPUMS API to interact with the NHGIS data collection is added to the client SDKs, this documentation will be deprecated and users will be advised to utilize those libraries instead.

Get your key from https://account.ipums.org/api_keys. Make sure to replace 'MY_KEY' (all caps) in the snippet below with your key.

Load Libraries and Set Key

import requests
import os

my_key = MY_KEY
my_key <- MY_KEY
export KEY=MY_KEY # set the MY_KEY environment variable using bash shell

Download supplemental data

## Specify a URL for a supplemental data file
url = "https://api.ipums.org/supplemental-data/nhgis/blocks-1980/AL_block_1980.zip"

## Get the file from the URL and write out to a local file
r = requests.get(url, headers={"Authorization": my_key})
open("AL_block_1980.zip", "wb").write(r.content)
## Specify a URL for a supplemental data file
url <- "https://api.ipums.org/supplemental-data/nhgis/blocks-1980/AL_block_1980.zip"

## Get the file from the URL and write out to a local file
download.file(url, "AL_block_1980.zip", headers = c(Authorization = my_key))
curl -X GET "https://api.ipums.org/supplemental-data/nhgis/blocks-1980/AL_block_1980.zip" -H "Authorization: $MY_KEY" --output nhgis_supplemental_data.zip