Publishing - npolar/api.npolar.no GitHub Wiki

A guide to publishing a dataset into a new API endpoint

Our new API is a intended as a JSONP backend for autocomplete searches of GCMD Concepts (Keywords).

Step 0

Create API user

Step 1

Setup a new API (storage and authorization)

Step 2

Create data collection

$ ./bin/gcmd_concepts_to_json > ~/.gcmd/concepts/7.0/gcmd-concepts.json # takes a few seconds

(Case you wonder, this binary is bundled into the API bin folder via the Ruby GCMD library)

Step 3

Publish collection using the APIs support for multi-document POSTing:

$ curl -nkX POST https://api.example.com/gcmd/concept/.json -d @/home/api/.gcmd/concepts/7.0/gcmd-concepts.json -H "Content-Type: application/json"
POSTed 10292 documents

Warning: All sorts of bad things will happen if you omit the Content-Type: application/json header.

Step 4

Enjoy :)

JSON

JSONP