Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ckan-client

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ckan-client

CKAN Python SDK for CKAN3 instances with CKAN3 cloud storage.

  • 0.1.1
  • PyPI
  • Socket score

Maintainers
1

CKAN Client: Python SDK

contributions welcome ckan-client-py actions The MIT License

CKAN 3 SDK for CKAN instances with CKAN v3 style cloud storage.
This SDK will communicate with ckanext-authz-service (using CKAN to provide authorization tokens for other related systems) and Giftless (a highly customizable and extensible Git LFS server implemented in Python) to upload data to blob storage.

Read more about it's design.

Install

Install it from the Python Package Index:

$ pip install ckan-client

Usage

ckanclient.Client

Arguments:

NameDescription
api_urlCKAN API key
api_keyCKAN instance URL
organizationOrganization
dataset_idDataset id
lfs_urlGit LFS URL

Example:

from ckanclient import Client


client = Client(
    '771a05ad-af90-4a70-beea-cbb050059e14',
    'http://localhost:5000',
    'datopian',
    'dailyprices',
    'http://localhost:9419',
)

These settings matches the standard of ckanext-blob-storage development environment, but you still need to create the user and organization there.

ckanclient.Client.action

Arguments:

NameTypeDefaultDescription
namestr(required)The action name, for example, site_read, package_show
payloaddict(required)The payload being sent to CKAN. If a payload is provided for a GET request, it will be converted to URL parameters and each key will be converted to snake case.
http_getboolFalseOptional, if True will make GET request, otherwise POST.
transform_payloadfunctionNoneFunction to mutate the payload before making the request (useful to convert to and from CKAN and Frictionless formats).
transform_responsefunctionNonefunction to mutate the response data before returning it (useful to convert to and from CKAN and Frictionless formats).

This method is used internally by the following methods.

ckanclient.Client.create

Arguments:

NameTypeDescription
dataset_name_or_metadatastr or dictIt is either a string being a valid dataset name or dictionary with meta-data for the dataset in Frictionless format.

Example:

dataset = client.create('dailyprices')

ckanclient.Client.push

Arguments:

NameTypeDescription
dataset_metadatadictDataset meta-data in Frictionless format.

Example:

dataset_metadata = {
    'id': '16d6e8d7-a848-48b1-91d0-fd393c1c6c01',
    'name': 'dailyprices',
    'owner_org': '57f97769-a982-4ccd-91f0-1d86dee822e3',
    'title': 'dailyprices',
    'type': 'dataset',
    'contributors': [],
    # …
}
dataset = client.push(dataset_metadata)

ckanclient.Client.retrieve

Arguments:

NameTypeDescription
name_or_idstrId or name of the dataset.

Example:

dataset = client.retrieve('dailyprices')

ckanclient.Client.push_blob

Arguments:

NameTypeDescription
resourcedictA Frictionless resource.

Development

All you need is Git, and Python 3.6+ with a PEP 527 compliant tool, such as Poetry.

First, clone this repository:

$ git clone https://github.com/datopian/ckan-client-py.git

Then, move to is directory:

$ cd ckan-client-py

And install the package and its dependencies, for example, with Poetry:

$ poetry install

To run tests:

$ poetry run pytest

License

This project is licensed under the MIT License - see the LICENSE file for details

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc