Getting started

Utilizing Tidsbanken API is the preferred way of integrating your systems with Tidsbanken.

In order to start using the API, you need an API Key . (Contact support@tidsbanken.no for your key and for information about pricing.)

You can try out the API with a demo database by using the following key.

f8ccaf8a-2d8e-4771-824f-38d57d65eaf4

PS! This key is meant for testing purposes only, and we can therefore not guarantee the availability of your data.


Making your first request

All requests to the API must contain the API-key in a request header called "tb-key". Below is an example on how you would set up a request in JavaScript (using axios in this case):

const axios = require('axios').default;
const httpClient = axios.create({
    headers: {
        'tb-key':'<your API key here>'
    },
    baseURL: 'https://api.tidsbanken.net/v2/'
})

Now, let's say we want to list of all the currently clocked in employees - we could do something like this:

const getClockedInEmployees = async () => {
    return await httpClient.get('ansatte/innstemplede');
}

//Get a list of employees from the API
const response = await getClockedInEmployees();
const employees = response.data;

//Loop through the list and print the full name
employees.map((employee) => console.log(emp.fornavn + ' ' + emp.etternavn));


Query filtering

You can use OData query options in your request URL in order to perform filtering, sorting etc.

The following filtering options are available on all collections returned from the API:

$top Allows you to select the first n results, e.g. /prosjekter?$top=10

$filter Allows you to filter the results. Check OData.org for more information on available filter operations.

Examples:

Projects that have a project id that starts with 'NOR'.

/prosjekter?$filter=startswith(prosjektId, 'NOR')

Filter on dates

/prosjekter?$filter=startDato gt 2017-01-01T09:59:59Z

Find project by name

/prosjekter?$filter=oppgavenavn eq 'My project name'

$orderby Allows you to order the results.

Get a list of the 20 newest employees

/ansatte?$top=20&$orderby=ansattId desc