API Documentation

The nSight API is currently hosted at: https://nsight-dev.ikanow.com/nsight/

nContext API Overview

This page houses the documentation for the nContext API calls.  This initial page talks about how to interact w/ the API and then each specific API page details what the api call does and the necessary parameters.

Authorization to use the API

Interacting with the nContext API requires a user to login via the auth/login call.  This call will return a cookie and the response will have a token (as well as the "inf_token" header being set.  Either can be used to make subsequent calls against this API.   If you wish to use the token, return it in the header "inf_token" or "Authorization".  The header always overrides any cookies found.

Interaction with the API

All API calls are RESTful and the available HTTP methods for each call are detailed in the table to the right.  Once you've logged in in the previous step you should be able to access any of the API calls.  Many of the calls allow for multiple ways to interact where you can provide and id field in the url or in the JSON payload.  Both ways will result in returning the same data.  If an ID field is not provided the API will attempt to return all matching objects when possible.  For example the Channel call can be used to get a specific channel when you pass an ID with the call, or you can get all channels by not providing an ID field.

Calls that modify collections of a previous call require the ID to be provided in the url (for example channel/{channel_id}/events).

Examples of interacting with the API:

Here are some provided examples in cURL on how to access the API:

//STEP 1: Login to Infinit.e and store cookie
curl -c cookies.txt http://nsight-api-1.rr.ikanow.com/nsight/api/auth/login/user@ikanow.com/encoded_password

//STEP 2: Make any nContext API calls you want, while passing the stored cookies
//For example we can create a channel, then add a liked event to it
curl -b cookies.txt -X POST -d '{"name":"channel 1 news"}'  "http://nsight-api-1.rr.ikanow.com/nsight/channel" > response.txt
curl -b cookies.txt -X POST -d '{ "event_id":"53146705e4b056d7c3c22ed8", "liked":true}' "http://nsight-api-1.rr.ikanow.com/nsight/channel/531733e8b8e08e9d2197b0b0/events" > response.txt

//We can make changes by using PUT requests w/ the fields we want to change
curl -b cookies.txt -X PUT -d '{"name":"world news one"}'  "http://nsight-api-1.rr.ikanow.com/nsight/channel/531733e8b8e08e9d2197b0b0" > response.txt

//STEP 3: Logout from Infinit.e when you are done (this is optional, session will end in 30m of last activity)
curl -b cookies.txt http://nsight-api-1.rr.ikanow.com/nsight/api/auth/logout


//HEADER EXAMPLE replacement for STEP 2
curl -H "inf_token=53146705e4b056d7c3c22ed8" -X POST -d '{"name":"channel 1 news"}'  "http://nsight-api-1.rr.ikanow.com/nsight/channel" > response.txt