ferewelove.blogg.se

How to use apis
How to use apis













Site maintainers can use API Token Settings to configure the token generation. The expire_api_token core plugin allows to define the expiration timestamp for a token. A user can create as many tokens as neededįor different uses, and revoke one or multiple tokens at any time.

how to use apis

These areĮncrypted keys that can be generated manually from the UI (User Profile > Manage > API tokens) Starting from CKAN 2.9 the recommended mechanism to use are API tokens. When calling an API function that requires authorization, you mustĪuthenticate yourself by providing an authentication key with your The API uses the same authorizationįunctions and configuration as the web interface, so if a user is authorized toĭo something in the web interface they’ll be authorized to do it via the API as Some API functions require authorization. The old legacy API keys will still work but they will be removed in future versions so it is Starting from CKAN 2.9, API tokens are the preferred way of authenticating API calls. read ()) assert response_dict is True # package_create returns the created package as its result. code = 200 # Use the json module to load CKAN's response into a dictionary. urlopen ( request, data_string ) assert response. add_header ( 'Authorization', '***' ) # Make the HTTP request. # Replace *** with your API key, from your user account on the CKAN site # that you're creating the dataset on.

how to use apis

Request ( '' ) # Creating a dataset requires an authorization header. dumps ( dataset_dict )) # We'll use the package_create function to create a new dataset.

how to use apis

dataset_dict = # Use the json module to dump the dictionary to a string for posting. #!/usr/bin/env python import urllib2 import urllib import json import pprint # Put the details of the dataset we're going to create into a dict. Get an activity stream of recently changed datasets on a site: Search for packages or resources matching a query:Ĭreate, update and delete datasets, resources and other objects Get a full JSON representation of a dataset, resource or other object: Get JSON-formatted lists of a site’s datasets, groups or other CKAN objects: For example, using the CKAN API your app can:

how to use apis

(everything you can do with the web interface and more) can be used by externalĬode that calls the CKAN API. All of a CKAN website’s core functionality Interacts with CKAN sites and their data.ĬKAN’s Action API is a powerful, RPC-style API that exposes all of CKAN’sĬore features to API clients. This section documents CKAN’s API, for developers who want to write code that















How to use apis