Proper API call formatting

Hi there.
I’m using Python to make API calls to NHGIS.
I’m a rudimentary coder and now stumped with what seems to be an API syntax issue.

This works:
my_key = “xxxxxxx”
my_headers = {“Authorization”: my_key}

This one works

url = “
response = requests.get(url, headers=my_headers)

However, any permutation – variable or hard coded – of calling table files gives me a 404.
dataset = “1840_cPop”
table = “NT2”

All of these get 404 error code

url = “{dataset}/data_tables/{table}?version=2
…redacted to get by the blog filter limitation/datasets/{dataset}?version=2”
…redacted to get by the blog filter limitation/datasets/1840_cPop?version=2"
Any guidance on what I am doing wrong will be much appreciated.


Hi Daniel!

Without seeing your actual code I cannot be sure, but I see a couple of potential issues.

dataset = "1840_cPopX"
table = "NT2"
url = f"{dataset}/data_tables/{table}?version=2"

I wrote a test script making those adjustments and verified a 200 response code.

Let me know if you are still having issues!


PS - I’ve edited my previous reply to remove the reference, but in case you’ve already read it, although we do have NHGIS support on our ipumspy roadmap unfortunately we haven’t finished that yet so that’s not an option at the moment.

Thank you. It was another PICNIC.*

  • Problem in chair, not in computer.