Looking for web service to get State, County, and Place FIPS codes from an address
It may be a two step process. Geocode the address, get the xy from the geocode result and then send the xy to a county web service with FIPS. You will want to intersect the point.
http://tigerweb.geo.census.gov/ArcGIS/rest/services/Census2010/State_County/MapServer/1/query?text=&geometry={"x":-122,"y": 41,"spatialReference":{"wkid":4326}}&geometryType=esriGeometryPoint&spatialRel=esriSpatialRelIntersects&returnGeometry=false&outFields=STATE,COUNTY&f=json
Returns:
{"displayFieldName":"BASENAME","fieldAliases":{"STATE":"STATE","COUNTY":"COUNTY"},"fields":[{"name":"STATE","type":"esriFieldTypeString","alias":"STATE","length":2},{"name":"COUNTY","type":"esriFieldTypeString","alias":"COUNTY","length":3}],"features":[{"attributes":{"STATE":"06","COUNTY":"089"}}]}
You can use this one here: https://www.ffiec.gov/geocode/
The page hits a couple different endpoints when a search is made. If all you need are the FIPS codes, you just need this one: https://geomap.ffiec.gov/FFIECGeocMap/GeocodeMap1.aspx/GetGeocodeData
You will need to make a post request with a body like this: {sSingleLine: "123 Main St, Watertown, MA", iCensusYear: "2018"}
Example in Python:
import requests
import json
address = "123 Main St, Watertown, MA"
geocode_url = 'https://geomap.ffiec.gov/FFIECGeocMap/GeocodeMap1.aspx/GetGeocodeData'
headers = {'content-type':'application/json'}
data = {'sSingleLine': address, 'iCensusYear': "2018"}
r = requests.post(geocode_url, data = json.dumps(data), headers=headers)
d = r.json()['d']
state_code = d['sStateCode']
county_code = d['sCountyCode']
msa_code = d['sMSACode']
tract_code = d['sTractCode']
Unfortunately, it doesn't look like it gives codes for city or place.