[ckan-discuss] CKAN API examples using Python?

Adrià Mercader adria.mercader at okfn.org
Wed Nov 13 11:30:14 UTC 2013


Hi,

For searching datasets you want to use the package_search method of
the action API:

http://docs.ckan.org/en/latest/api.html#ckan.logic.action.get.package_search

You can use the ckanapi client [1] for this or call the API directly
as shown on the healthdata.gov examples

The search params in your case would be something like (not tested):

# WMS + keyword
{"q": "salmon",
 "fq": "res_format:WMS"}

# WMS + temporal
{"q": "metadata_modified:[2013-06-01T00:00:00.000Z TO NOW]",
 "fq": "res_format:WMS"}

# WMS + spatial
{"extras":{"ext_bbox":"-121,45,-120,46"},
 "fq": "res_format:WMS"}

Hope this helps,

Adrià


[1] https://github.com/open-data/ckanapi

On 13 November 2013 04:52, Huang-Wei Chang <chang.huangwei.01 at gmail.com> wrote:
> The examples on healthdata.gov are very helpful. Thanks a lot, Joshua!
>
> On Tue, Nov 12, 2013 at 6:33 AM, Joshua Tauberer
> <tauberer+consulting at govtrack.us> wrote:
>> Hi, Richard.
>>
>> We have some examples here for the datastore API, though it's similar to
>> other APIs:
>>
>> http://healthdata.gov/data-api
>>
>> --
>> - Joshua Tauberer
>> - http://razor.occams.info
>>
>>
>>
>>
>> On 11/12/2013 08:57 AM, Signell, Richard wrote:
>>>
>>> I'd like to use Python to construct queries and decode responses to
>>> the CKAN API.
>>>
>>> Specifically I'd like to conduct a geospatial, temporal and keyword
>>> search of catalog.data.gov, returning only datasets that have specific
>>> format type (e.g. Esri REST, or WMS).
>>>
>>> Does anyone have some examples of Python code that help construct
>>> these type of queries and process the responses?
>>>
>>> (I know about ckanclient (https://github.com/okfn/ckanclient), but I
>>> couldn't figure out how to use it to do this kind of work.)
>>>
>>> Thanks,
>>> Rich
>>>
>>
>>
>> _______________________________________________
>> ckan-discuss mailing list
>> ckan-discuss at lists.okfn.org
>> http://lists.okfn.org/mailman/listinfo/ckan-discuss
>> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-discuss
>
> _______________________________________________
> ckan-discuss mailing list
> ckan-discuss at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-discuss
> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-discuss


More information about the ckan-discuss mailing list