I am trying to filter my search on the DOL API to capture only observations meeting a particular criteria. In addition, I will need to skip some observations.

This is the code I am using below. Number 1 works, but when I try to introduce a filter, as in number 2, I get an error. Ultimately, I would like to include both a filter and skip.


msha_api <- GET("http://api.dol.gov/V1/Mining/FullMineInfo/MSHA_mines/?Key=xxx&$skip=100", accept("application/json"))


msha_api <- GET("http://api.dol.gov/V1/Mining/FullMineInfo/MSHA_mines/?Key=xxx&$filter=PRIMARY_CANVASS eq 'Coal'", accept("application/json"))

Any advice/help on how to go about including both a filer and a skip in the DOL API call?


I think this is a URL encoding issue with R... try this: (note the + instead of [space])

msha_api <- GET("http://api.dol.gov/V1/Mining/FullMineInfo/MSHA_mines/?Key=xxxx&$filter=PRIMARY_CANVASS+eq+'Coal'", accept("application/json"))

See https://stat.ethz.ch/R-manual/R-devel/library/utils/html/URLencode.html for how to do this programmatically

Screenshot of results below:

working results


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.