Lets say I have a five digit fips code: '13245'. I have a dictionary to handle know that the 2-digit state part of the code(ex: {'GA':'13', etc...}). But I want to also get the full county name (EX: 13 - GA, 245 - Richmond County). Is there a library, mod, or API that will help me achieve this?


The FCC provides an API that will return attributes of a FIPS unit. https://www.broadbandmap.gov/developer/api/census-api-by-fips-code

Note however, the page says that it is no longer being updated since 2014 and I cannot find a similar tool anywhere on the new site that is linked there.

import requests
import urllib

#FIPS code
fipsCD = 13245

#Construct URL
url = 'https://www.broadbandmap.gov/broadbandmap/census/county/fips/' + str(fipsCD) + '?format=json'

#Retreive information and parse
response = requests.get(url)
data = response.json()

#Extract county name
countyNM = data['Results']['county'][0]['name']

  • This looks good. Quick questions; when I try countyNM = data['Results']['county'][0]['name'] it throws an error: TypeError: 'method' object is not subscriptable. Is there something I am leaving out here?
    – gwydion93
    Sep 12 '18 at 19:25
  • 1
    You get that error from directly pasting the code from my answer in? What is the result if you enter print(response.text) ?
    – Jacob F
    Sep 12 '18 at 19:36
  • Ah, I figured it out. I left the () off of the data = response.json. Its working now.
    – gwydion93
    Sep 12 '18 at 19:37

Note that the URL constructor may choke when fed a fips code lower than 10000.

Try code 1001 (Autauga County)

Hence my suggestion for the URLS constructor, using '{0:05d}'.format(fipsCD):

import requests
import urllib

fipsCD =  1001
url = 'https://www.broadbandmap.gov/broadbandmap/census/county/fips/' + '{0:05d}'.format(fipsCD) + '?format=json'
data = requests.get(url).json()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.