Question

In the CKAN to add data there are three options 'Link to a file', 'Link to an API', 'Upload a file'. What is the difference of these two option 'Link to a file' and 'Link to an API'?

Was it helpful?

Solution 2

This is metadata, it helps the consumer of the data to understand how this link can be interpreted. A file usually is a finite set of data, that you can download. Where an API provides data upon request, the format and syntax can be very different for each API.

For CKAN itself, it doesn't really matter of it's a link to a file or an API. As you can see in the example below, the download link is different for APIs and files. The result of the CKAN API shows a different resource_type (api vs. file.upload):

API: API Endpoint

API (Vici.org Search API):

{
    resource_group_id: "904ef692-6172-4173-92ec-3363aefcd599",
    cache_last_updated: null,
    revision_timestamp: "2012-09-25T14:38:05.040756",
    webstore_last_updated: null,
    id: "9060cf57-a1b1-4d32-8411-6ebfe6f8923b",
    size: null,
    state: "active",
    hash: "",
    description: "If called without any parameter, the API returns all markers in Geo-JSON format. This call can be demanding on the server so try not to do this call more than once. If you want to build your own services on the Vici.org data, please use the following call: http://vici.org/points.php?bounds=38.0,-7.0,40.0,-5.0&zoom=11 This call only return the markers for the area defined by two corners of 'bounds' (latitude, longitude of south-west point, latitude, longitude of north-east point). The higher the value of 'zoom', the more 'detail' markers are returned.",
    format: "JSON",
    tracking_summary: {
        total: 0,
        recent: 0
    },
    mimetype_inner: "",
    mimetype: "application/json",
    cache_url: "",
    name: "Search API",
    created: "2012-09-25T09:35:54.519845",
    url: "http://vici.org/points.php",
    webstore_url: "",
    last_modified: "2012-09-25T09:35:56.933638",
    position: 0,
    revision_id: "92cc4b1c-bc1f-4fc4-8d45-54f342b7d617",
    resource_type: "api"
}

File: Download and preview file

File (Wikipedia new user registration):

{
    resource_group_id: "59423860-c694-413f-bd8c-53e4aba75d38",
    cache_last_updated: null,
    revision_timestamp: "2012-05-09T21:56:11.096290",
    webstore_last_updated: null,
    owner: "c349ab48-4ac5-482d-bd5c-d3c7501e65aa",
    id: "0064af74-6877-4105-9098-5ccbddf68d33",
    size: "312354",
    cache_url_updated: "2012-05-09T21:51:12",
    state: "active",
    hash: "bb462573a0f0ef328dd989b9c0ee0c9072b18f87",
    description: "Hourly new user registrations to the English Wikipedia (2008-2011), timestamps are aligned to 2011 for easy year-to-year comparison.",
    format: "CSV",
    tracking_summary: {
        total: 0,
        recent: 0
    },
    mimetype_inner: "",
    mimetype: "text/csv",
    cache_url: "",
    name: "enwiki-hourly-registrations-2008-2011.csv",
    created: "2012-05-09T21:53:23.820579",
    url: "https://commondatastorage.googleapis.com/ckannet-storage/2012-05-09T215108/enwiki-hourly-registrations-2008-2011.csv",
    webstore_url: "https://commondatastorage.googleapis.com/ckannet-storage/2012-05-09T215108/enwiki-hourly-registrations-2008-2011.csv",
    last_modified: "2012-05-09T21:53:24.900960",
    position: 0,
    revision_id: "f777dc04-a041-436d-83dd-2f03df4c8e15",
    resource_type: "file.upload"
}

OTHER TIPS

'Link to a file' is meant to be used to link to the URL of an actual data file, e.g. a CSV file. 'Link to an API' is meant to be used to link to a web page where people can read about some data API that's available to them.

If you provide a link to an actual file, e.g. a CSV file, then CKAN's datastorer or datapusher can pull the data from that file into CKAN's DataStore, and then the DataStore's Data API will be available for the file, and data previews will work, just as if you had uploaded the file directly to CKAN. Even if you don't have the DataStore or datastorer/datapusher, CKAN might still be able to show a preview of the file using its DataProxy.

If you link to an API on the other hand, all users can do is follow the link.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top