ckan / ckanapi

A command line interface and Python module for accessing the CKAN Action API
Other
178 stars 74 forks source link

how to download resources via search #197

Closed aborruso closed 2 years ago

aborruso commented 2 years ago

Hi, in ckanapi search datasets there is not the -D option to download resources and output as datapackages.

I would like to use the cli to download all the resources of some dataset, not all (not via dump datasets --all).

Is there a way for a single dataset id? Is there a way via search?

Thank you

wardi commented 2 years ago

sure, you can ckanapi dump datasets <id1> <id2> ... Search doesn't have the dowload option but that sounds like a useful feature if you're interested in working on it

aborruso commented 2 years ago

sure, you can ckanapi dump datasets <id1> <id2> ... Search doesn't have the dowload option but that sounds like a useful feature if you're interested in working on it

I'm not able to write this code, but this could be a recipe for a recipes page, to download via search:

URL="https://mysample.url"
ckanapi -r "$URL" search datasets fq='(title:"taxes")' | \
jq -r '.id' | \
xargs -I _ ckanapi -r "$URL" dump datasets _ --datapackages=./out

Thank you very much