Search code examples
ckan

How can I see the id (and "name") of a CKAN entity (to be used in API update calls)?


When looking at the API for updating Packages, Groups, Organizations, or Users, I see that one of the input args is

id (string) – the name or id of the user to update

(https://docs.ckan.org/en/2.9/api/index.html#ckan.logic.action.update.package_update). What are the different ways that I can see the "id" of a CKAN user/org/package? The "name"?

Are the IDs just the URL component of the CKAN object that I see when I am, say, updating an Organization? Eg... enter image description here

Just from looking at the API docs here (https://docs.ckan.org/en/2.9/api/index.html#ckan.logic.action.update.resource_update) and older examples here (https://docs.ckan.org/en/ckan-1.7.2/api-tutorial.html), the IDs appear to be UUIDs, but I don't know how I would know these values from the CKAN web UI. And is the "name" the name as shown when I, say, view the dataset/Package in the web UI or is it as shown in the URL when looking at the Package (as in the image shown above)?

Could anyone provide more clarity on this? Is this explained somewhere in the docs?


Solution

  • It depends on what Id/Name you looking, you can query or list them I use rest api like this on ckan 2.8+:

    organizations:
    ckan-server:5000/api/action/organization_list
    
    groups:
    ckan-server:5000/api/action/group_list
    
    packge: 
    ckan-server:5000/api/action/package_search
    

    you need to set header with api_key (will be deprecated soon).

    also some api calls supports name instead of id, so if you willing to update any it will address by name if pressent on request.

    the best is first search by name or partial name, then extract id from response.