datagovsg.ckan¶
Client for interacting with the CKAN APIs.
Example usage:
# list all available packages
from datagovsg import Ckan
ckan = Ckan()
packages = ckan.package_list()
Methods¶
-
class
datagovsg.ckan.client.
Client
¶ Bases:
datagovsg.client.__Client
Interact with CKAN software to access its catalogue of datasets.
-
datastore_search
(resource_id, limit=100, offset=0, fields=None, filters=None, q=None, sort=None, records_format='objects')¶ Search data in a resource.
- Parameters
resource_id (str) – ID or alias of the resource to be searched against.
limit (int) – (optional) Maximum number of rows to return. Default: 100.
offset (int) – (optional) Offset this number of rows. Default: 0.
fields (str) – (optional) Fields to return.
filters (dict) – (optional) Dictionary of matching conditions, e.g {“key1”: “a”, “key2”: “b”}.
q (str or dict) – (optional) Full text query. If it’s a string, it’ll search on all fields on each row. If it’s a dictionary as {“key1”: “a”, “key2”: “b”}, it’ll search on each specific field.
sort (str) – (optional) Comma-separated field names with ordering, e.g. “fieldname1, fieldname2 desc”.
records_format (str) – (optional) The format for the records return value. “objects”: list of {fieldname1: value1, …} dicts “lists”: list of [value1, value2, …] lists “csv”: comma-separated values with no header “tsv”: tab-separated values with no header Default: “objects”.
- Returns
(dict) Resources that match the search criteria. All of the records are concatenated together, so there is no need for further pagination.
References
-
package_list
(limit=None, offset=None)¶ Return a list of datasets on data.gov.sg.
- Parameters
- Returns
(dict) Metadata and list of packages.
References
-
package_show
(package_id)¶ Return the metadata of a dataset (package) and its resources.
- Parameters
package_id (str) – ID or name of the dataset.
- Returns
(dict) Metadata and resources of the requested package.
References
-