Authentication
Kili API
Kili provides an API interface to better integrate with your data science workflow. It is a very flexible tool, which allow to query and mutate data quicly and painlessly.
It is possible thanks to GraphQL, that is a query language developed by Facebook. It proposes an alternative to REST APIs whose storage may be distributed. It proposes to the client to formulate the data structure in the request, while the same structure is returned by the server. Strongly typed, this language avoids problems of return from insufficient data (under-fetching) or supernumerary data (over-fetching).
The API can be accessed indifferently on Windows, Mac OS or Linux :
- through Python on Kili Playground
- through NodeJS on Kili Playground Node
- and also directly from the Graphql Playground.
How to use Kili Playground to query data on Python:
Prerequisites
Install Kili Playground:
git clone https://github.com/kili-technology/kili-playground.git
cd kili-playground
pip install .
Or just simply
pip install kili
Authentication
The Kili API secures all requests and mutations with X-API Keys.
To use the wrapper around GraphQL, you must:
- Pass your API key to the client so it is added to every requests made in Kili :
from kili.client import Kili
kili = Kili(api_key = "MY_API_KEY")
- Initiate the desired transfer/requests. For example, to print all the names of the projects you are in :
kili.projects(fields=['title'])
An extensive doc is at your disposal here, but also ready to use recipes on the playground to help you get started.
How to use Kili Playground to query data on NodeJS:
Prerequisites
Install Kili Playground Node in your project :
npm i --save @kili-technology/playground
Authentication
The Kili API secures all requests and mutations with X-API Keys.
To use the wrapper around GraphQL, you must:
- Pass your API key to the client so it is added to every requests made in Kili :
import KiliClient from "@kili-technology/playground";
const authKey = process.env.MY_KILI_API_KEY;
const { me, kiliPlayground } = await new KiliClient(authKey).init();
- Initiate the desired transfer/requests. For example, to print all the projects you are in :
const {
data: { projects },
} = await kiliPlayground.projects({
where: {},
skip: 0,
first: 100,
});
An extensive doc is at your disposal here, but also ready to use recipes on the playground to help you get started.
The recipes are now for the most part in Python but arguments and returns are very similar.
How to use GraphQL Playground to query data
If you prefer, you can directly query GraphQL API without using any SDK.
Generate an API key in Kili interface in My account, under the tab API KEY. Store it in some place secured.
In the bottom left corner of the screen, click on
HTTP headers
and write the retrieved token in the authorization headers:
{
"Authorization": "X-API-Key: YOUR_API_KEY"
}
- Launch any query/mutation:
query {
users(where: { email: "YOUR_EMAIL" }, first: 10, skip: 0) {
id
activated
email
}
}
An extensive doc is at your disposal here, but also directly on the playground while typing (arguments for the functions, fields possible to query)