New API - npolar/api.npolar.no GitHub Wiki

There's an API for that! Use the Service API to create new APIs.

Quickstart

For JSON APIs, powered by CoucDB and Elasticsearch, creating a new endpoint is simply done by a PUT of a service document:

$ curl -niXPUT https://api.npolar.no/service/project-api -H "Content-Type: application/json" -d@seed/service/project-api.json

Notice the -n flag for using .netrc authentication with curl. In production environments, you will also have to restart your ruby application server.

$ sudo su - api
# service api restart

Bootstrapping

When you PUT a service document, the new API is bootstrapped.

Provided you use CouchDB and Elasticsearch, the following happens

Bootstrapping is trigged by the Service.after_lambda, that in turns calls Bootstrap#bootstrap(service)

Service document schema: http://api.npolar.no/schema/api Service document example: https://github.com/npolar/api.npolar.no/blob/master/seed/service/editlog-api.json

The Elasticsearch index document

The mapping ...

See also Validation for how to enable JSON schema validation on POST and PUT.

Reindexing

To remap and/or reindex Elasticsearch, do a new PUT of the service document. This will DELETE the current mapping and index and start

⚠️ **GitHub.com Fallback** ⚠️