I keep getting an 'Invalid API key' response when trying to make a call to the data.dol.gov v2 API. Here is what my call looks like, please help!

base_endpoint = 'https://data.dol.gov/get/'
target_endpoint = 'publications_view/format/json/limit/1'
token = 'MY_API_TOKEN'

response = requests.get(base_endpoint + target_endpoint, headers={"X-API-KEY":f"{token}"})
print(json.dumps(json.loads(response.content.decode('utf-8')), indent=2))

I have been following the instructions on the API version 2 for the department of labor here: https://developer.dol.gov/accessing-the-apis-using-http-requests/

I also saw multiple unanswered posts from other users in the forum.

P.S. If I try v1 api it works, but I cannot get to the data I need using V1.

response = requests.get("http://api.dol.gov/V1/DOLAgency/Agencies/?KEY=MY_API_TOKEN")


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.