Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Data BC Catalog API #25

Closed
smnorris opened this issue Jan 3, 2017 · 2 comments
Closed

Use Data BC Catalog API #25

smnorris opened this issue Jan 3, 2017 · 2 comments

Comments

@smnorris
Copy link
Owner

smnorris commented Jan 3, 2017

Use the catalog API to find the DWDS path rather than scraping the catalog page. Path to download should be an item in the 'Resources' list. For example: https://catalogue.data.gov.bc.ca/api/3/action/package_show?id=conservation-lands

As there are multiple resources in the list I'm not quite sure how to pick the right one (in case the best download source isn't DWDS). Some examples would have to be checked out.

@smnorris
Copy link
Owner Author

smnorris commented Jan 22, 2018

Re-thinking above comment - this tool is just a wrapper to automate dwds. We don't care too much about other resources - if there are better ones, use/download them directly with some other tool.

So, - looking at the API more closely:

>>>import requests

>>>r = requests.get('https://catalogue.data.gov.bc.ca/api/3/action/package_show?id=bc-airports')
>>>dwds_url = [res['url'] for res in r.json()['result']['resources'] if 'dwds' in res['url']]
[u'https://apps.gov.bc.ca/pub/dwds/addProductsFromExternalApplication.do?productTypeId=0&productId=17006']

This gives just one result for this dataset - and should be 1 or 0 for most or all (3043) datasets.

@smnorris
Copy link
Owner Author

fixed with 2046eb8 but consider adding more interfaces to the API.

  • package list command
  • expand on bcdata info to include more results from package_show request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant