API

The Open Data API of Ponferrada 3.0 allows to access both the metadata and the data of the sets published in the system in a structured way, making easier the development of applications and visualizations using data of the Initiative.

This API is based on the one offered by the CKAN system. Any user can perform a series of operations, such as obtaining the published datasets or the distributions (files) associated with them.

The API queries are made through HTTP, with JSON being the data exchange format.

Examples

Obtaining datasets

To obtain the datasets published in the system, you can make a call to the package_list method (URL /api/3/action/package_list),  with the following result:

{
  "help": "http://***/api/3/action/help_show?name=package_list",
  "success": true,
  "result": [
    "annakarenina",
    "warandpeace"
  ]
}

In this example, we would see that there are 2 datasets, with identifiers "annakarenina" and "warandpeace".

Obtaining the metadata of a dataset

If we want to obtain the metadata of a dataset, we would use package_show, passing as an argument "id" the identifier of the set (URL /api/3/action/package_show?id=annakarenina), obtaining a result similar to this:

{
  "help": "http://***/api/3/action/help_show?name=package_show",
  "success": true,
  "result": {
    "license_title": "Otra (Abierta)",
    "maintainer": null,
    "relationships_as_object": [],
    "private": false,
    "maintainer_email": null,
    "num_tags": 3,
    "id": "e1cce9ef-ee66-419e-ab5f-5314045d9d32",
    "metadata_created": "2019-02-28T09:24:16.934913",
    "metadata_modified": "2019-02-28T09:24:16.934918",
    "author": null,
    "author_email": null,
    "state": "active",
    "version": "0.7a",
    "creator_user_id": null,
    "type": "dataset",
    "resources": [
      {
        "mimetype": null,
        "cache_url": null,
        "state": "active",
        "hash": "abc123",
        "description": "Full text. Needs escaping: \" Umlaut: ü",
        "last_modified": null,
        "format": "plain text",
        "url": "http://datahub.io/download/x=1&y=2",
        "name": null,
        "cache_last_updated": null,
        "package_id": "e1cce9ef-ee66-419e-ab5f-5314045d9d32",
        "created": "2019-02-28T09:24:16.962841",
        "size_extra": "123",
        "mimetype_inner": null,
        "url_type": null,
        "position": 0,
        "revision_id": "f9de3949-6ffb-4a6a-9fbd-d51108e14317",
        "datastore_active": false,
        "id": "d37a0f13-d524-4790-9b96-a5b73d83b3c4",
        "resource_type": null,
        "size": null
      },
      {
        "mimetype": null,
        "cache_url": null,
        "state": "active",
        "hash": "def456",
        "description": "Index of the novel",
        "last_modified": null,
        "format": "JSON",
        "url": "http://datahub.io/index.json",
        "name": null,
        "cache_last_updated": null,
        "package_id": "e1cce9ef-ee66-419e-ab5f-5314045d9d32",
        "created": "2019-02-28T09:24:16.962846",
        "size_extra": "345",
        "mimetype_inner": null,
        "url_type": null,
        "position": 1,
        "revision_id": "f9de3949-6ffb-4a6a-9fbd-d51108e14317",
        "datastore_active": false,
        "id": "eaf363a4-3c38-4c43-bfed-e4bae460a5e7",
        "resource_type": null,
        "size": null
      }
    ],
    "num_resources": 2,
    "tags": [
      {
        "vocabulary_id": null,
        "state": "active",
        "display_name": "Flexible ァ",
        "id": "f0950203-3fe8-4167-b8d9-df137ac727fc",
        "name": "Flexible ァ"
      },
      {
        "vocabulary_id": null,
        "state": "active",
        "display_name": "russian",
        "id": "bbec005b-7606-4543-b381-072063d5634a",
        "name": "russian"
      },
      {
        "vocabulary_id": null,
        "state": "active",
        "display_name": "tolstoy",
        "id": "7f7de2f3-3fbf-4156-9c91-dfaef27656a8",
        "name": "tolstoy"
      }
    ],
    "groups": [],
    "license_id": "other-open",
    "relationships_as_subject": [],
    "organization": null,
    "name": "annakarenina",
    "isopen": true,
    "url": "http://datahub.io",
    "notes": "Some test notes\n\n### A 3rd level heading\n\n**Some bolded text.**\n\n*Some italicized text.*\n\nForeign characters:\nu with umlaut ü\n66-style quote “\nforeign word: thümb\n\nNeeds escaping:\nleft arrow <\n\n<http://ckan.net/>\n\n",
    "owner_org": null,
    "extras": [
      {
        "key": "genre",
        "value": "romantic novel"
      },
      {
        "key": "original media",
        "value": "book"
      }
    ],
    "title": "A Novel By Tolstoy",
    "revision_id": "f9de3949-6ffb-4a6a-9fbd-d51108e14317"
  }
}

In this answer you can see how various metadata are listed, including the title, the license or the labels of the data set, as well as a list of the available distributions.