I came across a .csv file recently that had some data I wanted to see on a map but the .csv only had county names (formatted as 'some county (state)'). To get it on a map, I'd need to get FIPS codes for each county alongside this data.
It'd been a while since I'd done something like this. I grabbed some shapefiles from the Census but got about half-way through before I decided I wanted to see if there was a Census API I could hit for FIPS codes. Luckily, it wasn't too hard to find what I needed. Here's the URL to get FIPS codes for every county in the US:
Note that there are no state names in that response, but there are FIPS codes for states. There's probably a way to get state name in the response, but I found it easier to go get state names and FIPS codes for each state then combine that with the counties info. Here's the URL to get info about all US states:
Once I had a lookup, I wrote a node script to transform my .csv to a new .csv that includes FIPS code for each row. I mapped that file over on Datawrapper.