Skip to content

Instantly share code, notes, and snippets.

@kindly
Created April 26, 2012 09:41
Show Gist options
  • Select an option

  • Save kindly/2498219 to your computer and use it in GitHub Desktop.

Select an option

Save kindly/2498219 to your computer and use it in GitHub Desktop.
* example of how to provide the data according to the new vocabulary version
{
"id": "32d432-42342-42342242", # our id not allowed on create, has to be supplied on update
"name": "dataset-name", # madatory and has restrictions to [a-zA-Z1-9-_]*
"title": "dataset title", # if empty same as name
"alternative_title": "alternative title",
"description": "long description",
"keyword_string": "keyword1, keyword2, keyword2", # comma seperated keywords
"identifier": "identifier",
"url": "suggest use this for rdf:about uri",
"interoperability_level": "http://purl.org/adms/interoperabilitylevel/Political",
"type_of_dataset": ["http://purl.org/adms/assettype/Ontologyignore_missing",], ## a list of types
"resources": [
{ # A documentation example
"type": "http://ec.europa.eu/open-data/kos/documentation-type/MainDocumentation"
"url": "http://urlofdocumentation.com"
"description": "title of documentation" # slightly badly named but it better to be consistant with distribution
},
{ # A distribution example
"url": "http://linktofile.com"
"type": "Download"
"format": "application/json"
"description": "description" # will put dct:descrotion in the title field
"created": "2005-01-01" # dct:issues
"last_modifed": "moo" # dct:modified
}
]
"geographical_coverage": ["http://publications.europa.eu/resource/authority/country/ARE", ..], # list of uris
"published_by": "infso", # not uri in this case the publisher has a meaning in ckan and defines authorization
"contact_address": "address",
"contact_email": "[email protected]",
"contact_name": "test name",
"contact_telephone": "+4443324324242",
"contact_webpage": "http://contact_webpage.com",
"version": "1.2.3",
"version_description": "very nice version",
"license_id": "ec-ol" # either "ec-ol" or "ec-eurostat"
"status": "http://purl.org/adms/status/Completed",
"language": ["http://publications.europa.eu/resource/authority/language/0D0", ] # list of language uri
"accrual_periodicity": "other" # either monthly, never, discontinued, annual, quarterly, other
"accrual_periodicity-other": "twice monthly" # only specify if other
"temporal_coverage_from": "2001-01-01"
"temporal_coverage_to": "2001-01-01"
"state": "active", # set to "deleted" if you want to delete dataset
"capacity": "public" # either "public" or "private"
"rdf": "<?xml version=\"1.0\"?>
<rdf:RDF> .....
" # rest of rdf document
}
json does not allowed comments so the things after the # need to be removed to be valid json.
* how to embed the original RDF data
See example, you may need to escape xml but any json encoder will do that for you.
* folder where to place the uploads
We discussed this.
* How to provide translations
post data to
curl http://ecportal.demo.ckan.org/open-data/data/api/action/term_translation_update_many -d '{"json": "below"}' -H "X-CKAN-API-Key:your-api-key"
[
{'term', 'original_term',
'term_translation': 'translated_term',
'lang_code': 'en'},
...
]
* how to provide vocabulary uris (e.g. publisher or languages or countries).
This is all described above as part of the above json reprisentation. The only exception is publishers where it would be good if you could just give the end part uri.
* how to find a dataset by it's original URI using the api
curl http://ecportal.demo.ckan.org/open-data/data/api/2/search/dataset?q=url:"http://uritofind.com" # make sure you have quotes round the url.
* is there any authentication needed to access the api and what is the URL scheme to upload the json files
These are how to update and crate you need to supply the X-CKAN-api-key header to work.
curl http://ecportal.demo.ckan.org/open-data/data/api/action/dataset_create -d '{"json": "above"}' -H "X-CKAN-API-Key:your-api-key"
curl http://ecportal.demo.ckan.org/open-data/data/api/action/dataset_update -d '{"json": "above with id"}' -H "X-CKAN-API-Key:your-api-key"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment