Getting Started

You will first need our team to provision your account and give you an API token. API tokens are used for authentication against our system.

API URL

The Kronor API is available at the following URL

https://kronor.io/v1/graphql

The sandbox API is avaible under a subdomain

https://staging.kronor.io/v1/graphql

Authentication

To authenticate with the Kronor API, you use the provided API token and the HTTP Authorization header. The structure of the header should be as follows:

Authorization: Bearer [your-api-token]

For example, if your api token is eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWI, then every request you make to our API needs this header:

Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWI

It is possible to have several API tokens associated with the same Merchant.

GraphQL Requests

GraphQL is a query language for APIs that allows you to pick and choose exactly what you want to pull from an API. Here’s the first GraphQL query you can make to our API:

Loading GraphiQL...

This is equivalent to constructing the following JSON query document and sending it using curl:

{
   "query": "query GetVersion { version }",
   "operationName": "GetVersion",
   "variables": null
}

Save the document in a file as query.json and then execute the curl command:

curl \
   --header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWI' \
   --request POST \
   --data @query.json \
   https://staging.kronor.io/v1/graphql

We recommend using a GraphQL client for the programming language of your choice. Here we present an example for two popular programming languages.

PHP

Using the php-graphql-client library:

<?php
$client = new Client(
    'https://staging.kronor.io/v1/graphql',
    [],
    [
      'headers' => [
         'Authorization' => 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWI'
      ]
    ]
);

$gql = (new Query('GetVersion'))->setSelectionSet(['version']);
$results = $client->runQuery($gql);

echo $results->getData()->version;

Javascript

Using the apollo-client library:

const client = new ApolloClient({
  uri: 'https://localhost/v1/graphql',
  cache: new InMemoryCache(),
  headers: {
   authorization: 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWI'
  }
});

client
  .query({
    query: gql`
      query GetVersion {
          version
      }
    `
  })
  .then(result => console.log(result));

HTTP Verbs and Status Codes

Queries can be sent to our API only using the POST HTTP verb. The body of the HTTP request should always be a JSON document containing a query as described above.

The HTTP status code returned by the API will always be 200 OK, regardless of the contents of the response, unless there is an actual error at the level of the HTTP transport protocol.

For instance, both a query result and a validation error will be sent with the 200 OK status. However, when a problem in the server makes it impossible to render either of those, the response will have the 500 status code.