Some websites provide a link to a dataset (in Excel sheets format) which allows the dataset to be downloaded. But some others additionally provide API documentation, like this site. Can you please refer tutorials that explains about this concept, as well as how one may use it?


1 Answer 1


The API you've linked to is the HTTP API documentation, so you would need to able to perform HTTP requests to send get and post requests to the endpoint. Depending on your programming language of choice there are a ton of tutorials available, for example in python: https://www.datacamp.com/tutorial/making-http-requests-in-python or https://www.geeksforgeeks.org/get-post-requests-using-python/

I don't know of tutorials for downloading from that specific provider, but the mechanics of http requests using the python requests library are roughly equivalent. For https://data.medicaid.gov/datasets, click on a specific dataset, then scroll to dataset API. From here you can get a single dataset, and if you click on the down arrow to the right of the text box you can try it out - button on the right. Then hit the Execute button and it will show you the curl commands and actually execute them as well as the request URL. So for example NADAC 2023, it will show https://data.medicaid.gov/api/1/metastore/schemas/dataset/items/4a00010a-132b-4e4d-a611-543c9521280f?show-reference-ids=false

This can be (roughly) translated into python using the requests library as

response = requests.get('https://data.medicaid.gov/api/1/metastore/schemas/dataset/items/a217613c-12bc-5137-8b3a-ada0e4dad1ff/')

Of course, you then need to parse the response to find the actual location of the dataset ("downloadURL": "https://download.medicaid.gov/data/nadac-national-average-drug-acquisition-cost-09-06-2023.csv",) resend another request to download the actual data, and so on.

  • $\begingroup$ thanks for the answer, I have accepted your answer; but I noticed my question was not detailed enough. I am looking for tutorials that teach me how to download a dataset, for example by python code using the following information provided to download GET a Single dataset: /api/1/metastore/schemas/dataset/items/{identifier} $\endgroup$
    – IwillLearn
    Sep 5 at 16:59

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.

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