Skip to main content

Getting an API Key

An API Key is required to access the API. To get this API Key, you just need to send a request to the Lineberty API using the route GET /api_key and generate a valid token for the header.

Get a valid API Key in the Booking API
Get a valid API Key in the Validation API
Get a valid API Key in the Display API

Process to get the API Key

Getting an API Key is a 4-step process.

  1. Your application requests your server for an API Key to access the resources of the Lineberty API.
  2. Your server requests the Lineberty API for an API Key by putting a JWT Token in the request header.
  3. The Lineberty API returns an API Key to your server. We highly recommend caching this key for a few hours. Lineberty undertakes the rotation/turnover of the keys, each expired API key reminding valuable for 24 hours for your users.
  4. Your server returns the API Key to your application.

Get an API Key

Process to Generate the Token

Generating the header requires your private key, the Go to the Display API Library JWT to generate the bearer and your email account.

The first step in the process consists of generating the token, then generating the header and finally sending a GET request.

Generate the Token

To generate the Token, adapt this sample code.

static generateToken () {
const privateKey = getFile('secretFile.json').private_key
const now = Math.floor(Date.now() / 1000) // Current timestamp in seconds

const payload = {
'iat': now, // Current timestamp in seconds
'exp': now + 3600, // Current timestamp in seconds + 1H
'aud': 'https://api-booking.lineberty.net',
// or 'https://api-validation.lineberty.net' in the case of the Validation API
// or 'https://api-display.lineberty.net' in the case of the Display API
'iss': 'YOUR_EMAIL_ACCOUNT', // Service account email
'sub': 'YOUR_COMPANY_NAME', // Company name
'email': 'YOUR_EMAIL_ACCOUNT' // Service account email
}

return jwt.sign(payload, privateKey, {algorithm: 'RS256'})
}

Generate the Header

To generate the header, simply put the token into the header.

const token = generateToken()
const headers = {'Authorization': 'Bearer ' + token}

Get the API Key

Send your GET request and the header either to:

APIRoute
Booking APIhttps://api-booking-new2.lineberty.net/v2/api_key Go to the Display API
Validation APIhttps://api-validation.lineberty.net/v1/api_key Go to the Display API
Display APIhttps://api-display.lineberty.net/v1/api_key Go to the Display API

The Lineberty server will return you a JSON object containing the API Key, like the one below.

{
"apiKey": "abcedfghijklmn123456789ABCDEFGHIJKLMN"
}

tip

We recommend using API Key caching to optimize the number of requests per day and resend the request once a day.