Please note the URLS contained in the post aren't real - just examples
Is it possible to check what dataset/s a resource sits in via a single api query?
It seems possible to do via a 3 step query such as:
Alternatively I've been able to use: https://demo.ckan.org/api/action/package_search This allows me to get all packages and info contained within then use javascript on a page to process the results, this gives me the dataset/s if any are applicable.
However I'm curious if this can be done in a single API call as opposed to doing multiple or having to rely on something outside of CKAN to process (ie without using Javascript as in second example).
I thought it might have been possible to do something like: https://data.qld.gov.au/api/action/package_search?q=de5707gg-5568-1291-83df-7a6e2a441396 but it does not seem to search ID fields? I'd prefer to search by URL as I wouldn't necessarily know what the ID is to begin with unfortunately and the package search doesn't have this content to search across.
To search for the ID field, you can pass it to package_show in the fq parameter like:
https://data.gov.uk/api/3/action/package_search?q=&fq=id:e3939ef8-30c7-4ca8-9c7c-ad9475cc9b2f
Similarly you can find packages that have a specific resource URL with (note the ")
https://data.qld.gov.au/api/3/action/package_search?fq=res_url:"https://www.dnrm.qld.gov.au/__data/assets/excel_doc/0005/282533/dnrm-gifts-and-benefits-june-2015.xlsx"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With