Skip to content

Latest commit

 

History

History
150 lines (105 loc) · 6.45 KB

API.md

File metadata and controls

150 lines (105 loc) · 6.45 KB

Classes

Client

Typedefs

PushBlobResult : Object

The result of push blob method

Client

Kind: global class

new Client(apiKey, organizationId, datasetId, api)

Param Type
apiKey string
organizationId string
datasetId string
api string

client.action(actionName, payload, useHttpGet)

action gives you direct access to the [CKAN Action API][ckan-api]. Note: it uses the CKAN dataset and resource formats rather than [Frictionless][f11s]. If you want to have frictionless data you have to use [CKAN<=>Frictionless Mapper][c2f]. [ckan-api]: https://docs.ckan.org/en/2.8/api/

Kind: instance method of Client

Param Type Default Description
actionName string The action name, e.g. site_read, package_show ...
payload object The payload being sent to CKAN
useHttpGet object false Optional, if true will make GET request, otherwise POST. Note that if the payload is provided during the GET, then it will be converted to params, where each property will be snake case converted from camel case

Example

const response = await client.action('package_update', {
  id: '03de2e7a-6e52-4410-b6b1-49491f0f4d5a',
  title: 'New title',
})
console.log(response.result)

client.create(datasetNameOrMetadata) ⇒ Promise.<Object>

Creates a new dataset

Kind: instance method of Client
Returns: Promise.<Object> - The frictionless dataset

Param Type Description
datasetNameOrMetadata string | Object It is either a string being a valid dataset name or metadata for the dataset in frictionless format.

Example

const dataset = await client.create({
  name: 'market',
})
console.log(dataset)

client.push(datasetMetadata) ⇒ Promise.<Object>

Updates the dataset

Kind: instance method of Client
Returns: Promise.<Object> - The frictionless dataset

Param Type
datasetMetadata Object

client.retrieve(nameOrId) ⇒ Promise.<Object>

Retrieves the dataset

Kind: instance method of Client
Returns: Promise.<Object> - The frictionless dataset

Param Type Description
nameOrId string Id or name of the dataset

Example

const dataset = await client.retrieve('03de2e7a-6e52-4410-b6b1-49491f0f4d5a')
const dataset = await client.retrieve('market')

client.pushBlob(resource, onProgress) ⇒ Promise.<PushBlobResult>

Kind: instance method of Client
Returns: Promise.<PushBlobResult> - request result

Param Type Description
resource Object This datajs resource. Please check https://github.com/datopian/data.js
onProgress function a callback function to track the progress

PushBlobResult : Object

The result of push blob method

Kind: global typedef
Properties

Name Type Description
oid string oid
size number size of the file
name string resource name
success boolean Indicates whether the request was successful or not
fileExists boolean Indicates whether the resource exists or not