Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Common calls using the BC Data Catalogue API


  Audience  
Catalogue Editors Catalogue Admin Catalogue Developers

Table of Contents


Resources

  • See the full list of value options for drop down fields, see the BCDC Schema
  • See all documented changes in the Change Log

How to get information

How to get your API Key

  1. Log into the Catalogue
  2. Click on the hamburger/pancake in the upper right
  3. Click on Account Settings

image

  1. Bottom left corner is your personal API Key

image

RETURN TO TOP

How to get names and IDs from the UI

  • When navigating pages in the Catalogue, the URL will contain the name
  • When using the Share button on those pages, the ID will be copied to your clipboard. Minus that of resource that uses only the id.

Examples:

  • organization name : ../organization/information-management-cfd
  • organization ID : ../organization/a1a9c5cc-b601-4190-b206-13ba08c54292
  • package (dataset) name : ../dataset/bc-data-catalogue-content
  • package (dataset) id : ../dataset/42f7ca99-e7f3-40f7-93d7-f2500cccc315
  • resource id : …dataset/bc-data-catalogue-content/resource/b67e8cfc-32c1-4fd5-be08-ce30542b2a6c

RETURN TO TOP

How to get your organization name

import ckanapi

ckan = ckanapi.RemoteCKAN('https://catalogue.data.gov.bc.ca', apikey='YOUR-APIKEY-HERE')

org = ckan.action.organization_show(id="information-management-cfd")
print(org['name'], org['id'])

RETURN TO TOP

How to get package names and package IDs within an organization

import ckanapi

ckan = ckanapi.RemoteCKAN('https://catalogue.data.gov.bc.ca', apikey='YOUR-APIKEY-HERE')

pkgs = ckan.action.package_search(fq="owner_org:a1a9c5cc-b601-4190-b206-13ba08c54292",rows=1000)
for pkg in pkgs['results']:
    print(pkg['name'], pkg['id'])

RETURN TO TOP

How to get the resource names and resource IDs withing a package

import ckanapi

ckan = ckanapi.RemoteCKAN('https://catalogue.data.gov.bc.ca', apikey='YOUR-APIKEY-HERE')

pkg_data = ckan.action.package_show(id="b67255a7-8040-43c0-935c-d74f168af215")
for resource in pkg_data['resources']:
    print(resource['name'], resource['id'])

RETURN TO TOP

Common calls

  • Licence list is found here.
  • JSON Schema is found here.

object_name

https://catalogue.data.gov.bc.ca/api/3/action/package_search?q=res_extras_object_name:WHSE_WILDLIFE_MANAGEMENT.WAA_TRAPLINE_AREAS_SP

Depending on what is being used to make the call, changing the : and wrapping the object name in quotes may be needed https://catalogue.data.gov.bc.ca/api/3/action/package_search?q=res_extras_object_name%3A%22WHSE_WILDLIFE_MANAGEMENT.WAA_TRAPLINE_AREAS_SP%22

bcdc_type

https://catalogue.data.gov.bc.ca/api/3/action/package_search?q=res_extras_bcdc_type:geographic

resource_storage_location

https://catalogue.data.gov.bc.ca/api/3/action/package_search?q=res_extras_resource_storage_location:bc%20geographic%20warehouse

format

https://catalogue.data.gov.bc.ca/api/3/action/package_search?q=res_format:csv

licence_id

https://catalogue.data.gov.bc.ca/api/3/action/package_search?q=license_id:2


RETURN TO TOP