NAV
code

Introduction

Welcome to the Glassbox API!

Glassbox provides limited, structured access to transactional and historical data collected from sites via a targeted restful API

Site / Site Group Codes

Most API calls target data from a site or a site group. Sites and site groups are identified in the Glassbox HOS by a 4 character code. If the code represents a site group then the response will be an array of records, one for each site. If the code represents a single site then the response will be an array of records containing only one record.

Data Types

The following data types / formats are used throughout the API.

Data Type JSON Type SQL Type Description
Integer number Int Integer Value
Quantity number Decimal(13,3) Represents a volume or quantity
Money number Decimal(16,3) Represents a monetary value to 3dp
Name string VARCHAR(40) String maximum length of 40 characters
Description string VARCHAR(128) String maximum length 128 characters
Code4 string CHAR(4) String exact length 4 characters
Code2 string CHAR(2) String exact length 2 characters
DateTime string DateTime Date time. Must be a string in the format yyyy-MM-ddTHH:mm:ss
Array Array List of Objects

Authentication

To authorize, use this code:

# With code, you can just pass the correct header with each request
curl "api_endpoint_here" \
  -H "Authorization: gbxext Eq13456789gfaedgrtessdetKtprqFN7dd9NUqyenXdj2r/C"

Make sure to replace Eq13456789gfaedgrtessdetKtprqFN7dd9NUqyenXdj2r/C with your API key.

Glassbox uses API Kets to authenticate access to the API. You can request these by emailing us at support@glassbox.co.nz.

Glassbox expects the API ket to be included in all API Requests to the server in a head that looks like the following:

Authorization: gbxext Eq13456789gfaedgrtessdetKtprqFN7dd9NUqyenXdj2r/C

Configuration Information

Get Tenders


GET /1.0/enterprise/sites HTTP/1.1
Authorization: gbxext Eq13456789gfaedgrtessdetKtprqFN7dd9NUqyenXdj2r/C
Host: hos.glassbox.co.nz

The above command returns JSON structured like this:

[
  {
    "code": "0001",
    "name": "Cash"
  },
  {
    "code": "0002",
    "name": "Cheque"
  },
  {
    "code": "0003",
    "name": "EFT"
  },
  {
    "code": "0005",
    "name": "Local Accounts"
  },
  {
    "code": "0015",
    "name": "EFTPOS"
  },
  {
    "code": "0023",
    "name": "Amex"
  },
  {
    "code": "0024",
    "name": "Diners"
  },
  {
    "code": "0025",
    "name": "Fleetcard"
  },
  {
    "code": "0026",
    "name": "Farmers Trading Card"
  },
  {
    "code": "0027",
    "name": "Card Link"
  },
  {
    "code": "0028",
    "name": "Visa"
  }
]

This endpoint retrieves all Tenders

HTTP Request

GET http://localhost:3141/1.0/enterprise/sites

Query Parameters

Parameter Type Description
code Code4 4 character unique code for the tender. Tender codes are numeric but may contain leading zeros so are not numbers
name Name The name of the Tender

Get Site List

GET /1.0/enterprise/sites HTTP/1.1
Authorization: gbxext Eq13456789gfaedgrtessdetKtprqFN7dd9NUqyenXdj2r/C
Host: hos.glassbox.co.nz

The above command returns JSON structured like this:

[
  {
    "code": "1000",
    "name": "Glassbox Truckstop Ashhurst",
    "external": "",
    "usage": "Unmanned"
  },
  {
    "code": "1001",
    "name": " Glassbox Truckstop Feilding",
    "external": "",
    "usage": "Unmanned"
  },
  {
    "code": "1002",
    "name": " Glassbox Truckstop Dannevirke",
    "external": "",
    "usage": "Unmanned"
  }
]

Returns a list of the sites that can be accessed with the API Key

HTTP Request

GET https://hos.glassbox.co.nz/1.0/enterprise/sites<ID>

URL Parameters

Parameter Type Description
code Code4 Unique site code generated by the HOS. Contains numeric characters only but may contain leading zeros so is NOT a numeric value. This is the primary value passed to subsequent api calls to target sites for data retrieval
name Name The name of the site
external Name This is an external code for the site provided by the customer. If a value is not provided this will contain and empty string
usage Name The usage code type is a customer defined descriptor for how the site is uses. This is optional and if the customer has not set this value it will default to Unknown

Get Current Grade Prices

GET /1.0/enterprise/sites HTTP/1.1
Authorization: gbxext Eq13456789gfaedgrtessdetKtprqFN7dd9NUqyenXdj2r/C
Host: hos.glassbox.co.nz

The above command returns JSON structured like this:

[
  {
    "siteCode": "1000",
    "siteName": "Glassbox Truckstop Feilding",
    "grades": [
      {
        "grade": "DIESEL",
        "price": 1.389
      },
      {
        "grade": "ADBLUE",
        "price": 1.5
      },
      {
        "grade": "91",
        "price": 2.069
      },
      {
        "grade": "96",
        "price": 2.199
      }
    ]
  }
]

Returns a list of the current grade prices for the site group specified.

HTTP Request

GET /1.0/wetstock/grade/prices/{sitecode}<ID>

URL Parameters

Parameter Type Description
code Code4 4 character unique for the site.
siteName Name The name of the site
grades Array List of grades

Errors

The API uses the following error codes:

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your API key is wrong.
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable -- You requested a format that isn't json.
500 Internal Server Error -- We had a problem with our server. Try again later.
503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.