bcgov / ckan-ui

CKAN UI - VueJS
GNU Affero General Public License v3.0
14 stars 3 forks source link

Data API Button available on Tabular Resources stored in the Datastore - Missing (DDS-1133) #548

Open annikaLiving opened 3 years ago

annikaLiving commented 3 years ago

There is a green button available to consumers when looking at resources stored in the datastore.

Need to determine the value of this and if it should be re-introduced.

In Cat Classic popup contains

image

CKAN Data API Access resource data via a web API with powerful query support. Further information in the main CKAN Data API and DataStore documentation.

Endpoints

The Data API can be accessed via the following actions of the CKAN action API.

Create https://catalogue.data.gov.bc.ca/api/3/action/datastore_create
Update / Insert https://catalogue.data.gov.bc.ca/api/3/action/datastore_upsert
Query https://catalogue.data.gov.bc.ca/api/3/action/datastore_search
Query (via SQL) https://catalogue.data.gov.bc.ca/api/3/action/datastore_search_sql

Querying

Query example (first 5 results) https://catalogue.data.gov.bc.ca/api/3/action/datastore_search?resource_id=8f341d11-9966-4e1e-bffb-cb0d61fb10fd&limit=5

Query example (results containing 'jones') https://catalogue.data.gov.bc.ca/api/3/action/datastore_search?resource_id=8f341d11-9966-4e1e-bffb-cb0d61fb10fd&q=jones

Query example (via SQL statement) https://catalogue.data.gov.bc.ca/api/3/action/datastore_search_sql?sql=SELECT * from "8f341d11-9966-4e1e-bffb-cb0d61fb10fd" WHERE title LIKE 'jones'

Example Java Script:

A simple ajax (JSONP) request to the data API using jQuery.

var data = { resource_id: '8f341d11-9966-4e1e-bffb-cb0d61fb10fd', // the resource id limit: 5, // get 5 results q: 'jones' // query for 'jones' }; $.ajax({ url: 'https://catalogue.data.gov.bc.ca/api/3/action/datastore_search', data: data, dataType: 'jsonp', success: function(data) { alert('Total results found: ' + data.result.total) } });

Example Python

import urllib url = 'https://catalogue.data.gov.bc.ca/api/3/action/datastore_search?resource_id=8f341d11-9966-4e1e-bffb-cb0d61fb10fd&limit=5&q=title:jones'
fileobj = urllib.urlopen(url) print fileobj.read()


Feds' catalogue is a bit different

Example of one of our records they have scraped: https://open.canada.ca/data/en/dataset/f8e27889-fb07-4f9d-b2ba-591578274b7c

They also show the link to the package API etc on their package page

Metadata: Link to JSON format DCAT (JSON-LD) DCAT (XML)

ghost commented 2 years ago

https://dpdd.atlassian.net/browse/DDS-1133