Access Control Integration

Authentication

A token must be specified with each request via the HTTP header. token: ${token}

Please note: The issued token can only be used to authenticate against the below /accessusers endpoints. They cannot be used against other endpoints of the vivenu API.

Formats

Datetime format: ISO Timestamp

Example:

new Date().toISOString(); // 2020-04-29T15:03:03.726Z

Code Example

The following code is written in javascript and for demo purposes only. You can find a detailed list of all endpoints just after the example.

const ax = require('axios');

const baseUrl = "https://vivenu.com/api/accessusers";
const token = "YOUR-TOKEN-HERE";
const eventId = "EventId to get ticket batches.";
const batchSize = 50;
let skip = 0;
let total = 0;

const getTickets = async (from = undefined, until = undefined) => {

    const axios = ax.create({
        headers: {
            "token": token,
        }
    });

    const service = async (eventId, batchSize, skip = undefined, from = undefined, until = undefined) => {
        try {
            let queryParams = {
                top: batchSize,
            };
            if(skip) {
                queryParams.skip = skip;
            }
            if(from) {
                queryParams.from = from;
            }
            if(until) {
                queryParams.until = until;
            }

            const queryString = Object.entries(queryParams).map(a => a.join("=")).join("&");
            const response = await axios.get(baseUrl + "/tickets/v2/" + eventId + "?" + queryString);
            return response.data;
        } catch (error) {
            console.error(error);
        }
    };

    const initialResponse  = await service(eventId, batchSize, skip, from, until);
    if(initialResponse) {
        total = initialResponse.total;
    }

    for(let i = 0; i <= total; i += batchSize) {
        const response = await service(eventId, batchSize, skip, from, until);
        if(response) {
            total = response.total;
        }
    }
};

(async () => {
    const startingDate = new Date().toISOString();
    await getTickets(undefined, undefined);

    let from = startingDate;

    setInterval(async () => {
        let until = new Date().toISOString();
        await getTickets(from, until);
        from = until;
    }, 10000);
})();

GETPUBLIC/api/accessusers/events

Get all accessible Events

Get all accessible Events

Returns a list of all events accessible for the device. This endpoint is often used when a user wants to select the event to do the checkin for.

Query parameters

Optional query parameters

  • Name
    includeRootEvents
    Type
    boolean
    Description

Request

GET
/api/accessusers/events
const response = await fetch('https://vivenu.com/api/accessusers/events?includeRootEvents=true', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer {token}',
  },
})

const data = await response.json()

Response (200)

[
  {
    "_id": "507f191e810c19729de860ea",
    "name": "Example Name"
  }
]

GETPUBLIC/api/accessusers/tickets/v2/:eventId

Get Tickets for an Event v2

Get Tickets for an Event v2

Returns a paged response of all tickets for a given event. Devices usually fetch and page through this endpoint and persist the results on disk to provide an offline capability.

Query parameters

Optional query parameters

  • Name
    top
    Type
    number
    Description
  • Name
    skip
    Type
    number
    Description
  • Name
    from
    Type
    string
    Description
  • Name
    until
    Type
    string
    Description

Request

GET
/api/accessusers/tickets/v2/:eventId
const response = await fetch('https://vivenu.com/api/accessusers/tickets/v2/507f191e810c19729de860ea?top=10.5&skip=10.5&from=value&until=value', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer {token}',
  },
})

const data = await response.json()

Response (200)

{
  "docs": [
    {
      "_id": "507f191e810c19729de860ea",
      "barcode": "string",
      "ticketTypeId": "507f191e810c19729de860ea",
      "ticketName": "string",
      "eventId": "507f191e810c19729de860ea",
      "sellerId": "507f191e810c19729de860ea",
      "createdAt": "2030-01-23T23:00:00.123Z",
      "updatedAt": "2030-01-23T23:00:00.123Z",
      "name": "Example Name",
      "priceCategoryId": "507f191e810c19729de860ea",
      "categoryRef": "string",
      "priceCategory": {
        "categoryId": "507f191e810c19729de860ea",
        "description": "string"
      },
      "status": "VALID",
      "area": "string",
      "row": "string",
      "seat": "string",
      "discountId": "507f191e810c19729de860ea",
      "discount": "string",
      "entry": [
        "string"
      ]
    }
  ],
  "total": 1
}

GETPUBLIC/api/accessusers/tickets/:barcode

Get Ticket with barcode

Get Ticket with barcode

Returns the ticket for a given barcode if existent. This endpoint is typically invoked when a device needs to validate a given barcode in realtime.

Query parameters

Optional query parameters

  • Name
    eventId
    Type
    string
    Description

Request

GET
/api/accessusers/tickets/:barcode
const response = await fetch('https://vivenu.com/api/accessusers/tickets/barcode?eventId=507f191e810c19729de860ea', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer {token}',
  },
})

const data = await response.json()

Response (200)

{
  "_id": "507f191e810c19729de860ea",
  "barcode": "string",
  "ticketTypeId": "507f191e810c19729de860ea",
  "ticketName": "string",
  "eventId": "507f191e810c19729de860ea",
  "sellerId": "507f191e810c19729de860ea",
  "createdAt": "2030-01-23T23:00:00.123Z",
  "updatedAt": "2030-01-23T23:00:00.123Z",
  "name": "Example Name",
  "categoryRef": "string",
  "priceCategoryId": "507f191e810c19729de860ea",
  "priceCategory": {
    "categoryId": "507f191e810c19729de860ea",
    "description": "string"
  },
  "status": "VALID"
}

POSTPUBLIC/api/accessusers/tickets/:barcode/scan

Scan Ticket with barcode

Scan Ticket with barcode

Scans a ticket with a given barcode. This endpoint is typically invoked when a device needs to validate and scan a given barcode in realtime.

Request

POST
/api/accessusers/tickets/:barcode/scan
const response = await fetch('https://vivenu.com/api/accessusers/tickets/barcode/scan', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer {token}',
  },
})

const data = await response.json()

Response (200)

{
  "access": "GRANTED",
  "ticket": {
    "_id": "507f191e810c19729de860ea",
    "barcode": "string",
    "status": "VALID",
    "ticketTypeId": "507f191e810c19729de860ea",
    "ticketName": "string",
    "eventId": "507f191e810c19729de860ea",
    "sellerId": "507f191e810c19729de860ea",
    "createdAt": "2030-01-23T23:00:00.123Z",
    "updatedAt": "2030-01-23T23:00:00.123Z",
    "name": "Example Name",
    "categoryRef": "string"
  }
}

POSTPUBLIC/api/accessusers/scans/:eventId

Create scans

Create scans

Request

POST
/api/accessusers/scans/:eventId
const response = await fetch('https://vivenu.com/api/accessusers/scans/507f191e810c19729de860ea', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer {token}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(  [
    {
      "barcode": "string",
      "scanned_at": "2030-01-23T23:00:00.123Z",
      "type": "OK",
      "direction": "IN",
      "ticketId": "507f191e810c19729de860ea"
    }
  ]),
})

const data = await response.json()

Response (200)

{
  "status": "OK"
}

Was this page helpful?