1

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.

1)

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

2)

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?

1 Answer 1

1

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

0

Your Answer

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

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