Skip to content

Latest commit

 

History

History
952 lines (762 loc) · 21.9 KB

api.md

File metadata and controls

952 lines (762 loc) · 21.9 KB
title language_tabs language_clients toc_footers includes search highlight_theme headingLevel
bartender v1.0.0
'javascript
Javascript'
'javascript
true
atom-one-dark
2

bartender v1.0.0

Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.

API that keeps track of products

Base URLs:

Email: Thomas van de Weerd License: GNU General Public License v3.0 or later

Authentication

  • HTTP Authentication, scheme: bearer

Health

API Health

Get API Health

Code samples

GET /health

Get whether or not the API is currently healthy

Example responses

OK

{
  "healthy": true,
  "checks": {
    "memory": {
      "status": "up",
      "used": 300,
      "max": 512
    },
    "response-time": {
      "50": 7,
      "90": 12,
      "95": 14,
      "average": 8
    }
  },
  "dependencies": {
    "database": {
      "name": "Postgre",
      "healthy": true,
      "latency": 3
    },
    "external-api": {
      "name": "Some API",
      "healthy": true,
      "latency": 20
    }
  }
}

Service Unavailable

{
  "healthy": true,
  "checks": {
    "memory": {
      "status": "up",
      "used": 300,
      "max": 512
    },
    "response-time": {
      "50": 7,
      "90": 12,
      "95": 14,
      "average": 8
    }
  },
  "dependencies": {
    "database": {
      "name": "Postgre",
      "healthy": true,
      "latency": 3
    },
    "external-api": {
      "name": "Some API",
      "healthy": true,
      "latency": 20
    }
  }
}

Responses

Status Meaning Description Schema
200 OK OK Health
503 Service Unavailable Service Unavailable Health
To perform this operation, you must be authenticated by means of one of the following methods: BearerToken

Get API readiness

Code samples

GET /health/ready

A basic ping-pong to check if the server is able to receive requests and respond to them

Responses

Status Meaning Description Schema
200 OK OK None
To perform this operation, you must be authenticated by means of one of the following methods: BearerToken

Product

Handles products

Find product by GTIN

Code samples

GET /product/{gtin}

Checks if the GTIN exists in the database, returns the matching product if it does, otherwise returns a 404 Not Found

Parameters

Name In Type Required Description
gtin path string true GTIN of the product we want to request

Example responses

Found product by GTIN

{
  "gtin": "8716700027200",
  "name": "Grolsch Pilsener krat",
  "description": "Grolsch Premium pilsner is vol van smaak met een aangename bitterheid en een rijke afdronk. Het wordt gebrouwen met twee soorten hop. Dit geeft Grolsch Premium pilsner haar unieke karakter.",
  "category": "beer",
  "images": [
    {
      "height": 800,
      "width": 800,
      "url": "https://static.ah.nl/dam/product/AHI_43545239383734363237?revLabel=1&rendition=800x800_JPG_Q90&fileType=binary"
    }
  ],
  "brand": "Grolsch",
  "quantity": {
    "value": 300,
    "unit": "ml",
    "amount": 24,
    "total": 7200
  },
  "attributes": {
    "alcohol_percentage": 5,
    "contains_alcohol": true,
    "": "string"
  }
}

Could not find product by GTIN

{
  "code": 404,
  "message": "Was not able to find product for GTIN 8716700027200"
}

Unexpected error

{
  "code": 500,
  "message": "Something went wrong"
}

Responses

Status Meaning Description Schema
200 OK Found product by GTIN Product
404 Not Found Could not find product by GTIN Error
default Default Unexpected error Error
To perform this operation, you must be authenticated by means of one of the following methods: BearerToken

Update product

Code samples

PATCH /product/{gtin}

Change some data about a product

Body parameter

{
  "gtin": "8716700027200",
  "name": "Grolsch Pilsener krat",
  "description": "Grolsch Premium pilsner is vol van smaak met een aangename bitterheid en een rijke afdronk. Het wordt gebrouwen met twee soorten hop. Dit geeft Grolsch Premium pilsner haar unieke karakter.",
  "category": "beer",
  "images": [
    {
      "height": 800,
      "width": 800,
      "url": "https://static.ah.nl/dam/product/AHI_43545239383734363237?revLabel=1&rendition=800x800_JPG_Q90&fileType=binary"
    }
  ],
  "brand": "Grolsch",
  "quantity": {
    "value": 300,
    "unit": "ml",
    "amount": 24,
    "total": 7200
  },
  "attributes": {
    "alcohol_percentage": 5,
    "contains_alcohol": true,
    "": "string"
  }
}

Parameters

Name In Type Required Description
gtin path string true GTIN of the product we want to request
body body ProductProperties false none

Example responses

OK

{
  "gtin": "8716700027200",
  "name": "Grolsch Pilsener krat",
  "description": "Grolsch Premium pilsner is vol van smaak met een aangename bitterheid en een rijke afdronk. Het wordt gebrouwen met twee soorten hop. Dit geeft Grolsch Premium pilsner haar unieke karakter.",
  "category": "beer",
  "images": [
    {
      "height": 800,
      "width": 800,
      "url": "https://static.ah.nl/dam/product/AHI_43545239383734363237?revLabel=1&rendition=800x800_JPG_Q90&fileType=binary"
    }
  ],
  "brand": "Grolsch",
  "quantity": {
    "value": 300,
    "unit": "ml",
    "amount": 24,
    "total": 7200
  },
  "attributes": {
    "alcohol_percentage": 5,
    "contains_alcohol": true,
    "": "string"
  }
}

Not Found

{
  "code": 404,
  "message": "Could not find product with GTIN 8716700027200"
}

Responses

Status Meaning Description Schema
200 OK OK Product
404 Not Found Not Found Error
To perform this operation, you must be authenticated by means of one of the following methods: BearerToken

Delete product

Code samples

DELETE /product/{gtin}

Remove a product from the database

Parameters

Name In Type Required Description
gtin path string true GTIN of the product we want to request

Responses

Status Meaning Description Schema
204 No Content No Content None
To perform this operation, you must be authenticated by means of one of the following methods: BearerToken

Search for product

Code samples

POST /product/search

Tries to find the product matching all the data you give. Will start by checking GTIN, then validating the rest of the data that should not change like quantity. In case it can not find it by GTIN, it will try to find a very close match by using the name and quantity. This match needs to be above a certain treshold for it to be returned.

Body parameter

{
  "gtin": "8716700027200",
  "name": "Grolsch Pilsener krat",
  "description": "Grolsch Premium pilsner is vol van smaak met een aangename bitterheid en een rijke afdronk. Het wordt gebrouwen met twee soorten hop. Dit geeft Grolsch Premium pilsner haar unieke karakter.",
  "category": "beer",
  "images": [
    {
      "height": 800,
      "width": 800,
      "url": "https://static.ah.nl/dam/product/AHI_43545239383734363237?revLabel=1&rendition=800x800_JPG_Q90&fileType=binary"
    }
  ],
  "brand": "Grolsch",
  "quantity": {
    "value": 300,
    "unit": "ml",
    "amount": 24,
    "total": 7200
  },
  "attributes": {
    "alcohol_percentage": 5,
    "contains_alcohol": true,
    "": "string"
  }
}

Parameters

Name In Type Required Description
body body ProductProperties false The partial data you have about the item you want to find.

Example responses

Not Found

{
  "code": 404,
  "message": "Was not able to find a matching product"
}

Responses

Status Meaning Description Schema
200 OK OK Inline
404 Not Found Not Found Error

Response Schema

Status Code 200

Name Type Required Restrictions Description
anonymous [allOf] false none none

allOf

Name Type Required Restrictions Description
» anonymous ProductProperties false none none
»» gtin string false none none
»» name string false none none
»» description string false none none
»» category string false none none
»» brand string false none none
»» images [Image] false none none
»»» height integer(int32) true none none
»»» width integer(int32) true none none
»»» url string true none none
»» quantity ProductQuantity false none none
»»» value integer(int64) true none none
»»» unit string true none none
»»» amount integer(int64) true none none
»»» total integer(int64) true none none
»» attributes ProductAttributes false none none
»»» anonymous string false none none

and

Name Type Required Restrictions Description
» anonymous ProductRequiredProperties false none none
To perform this operation, you must be authenticated by means of one of the following methods: BearerToken

Get all products

Code samples

GET /product

Get all products stored in the database

Example responses

OK

[
  {
    "gtin": "8716700027200",
    "name": "Grolsch Pilsener krat",
    "description": "Grolsch Premium pilsner is vol van smaak met een aangename bitterheid en een rijke afdronk. Het wordt gebrouwen met twee soorten hop. Dit geeft Grolsch Premium pilsner haar unieke karakter.",
    "category": "beer",
    "images": [
      {
        "height": 800,
        "width": 800,
        "url": "https://static.ah.nl/dam/product/AHI_43545239383734363237?revLabel=1&rendition=800x800_JPG_Q90&fileType=binary"
      }
    ],
    "brand": "Grolsch",
    "quantity": {
      "value": 300,
      "unit": "ml",
      "amount": 24,
      "total": 7200
    },
    "attributes": {
      "alcohol_percentage": 5,
      "contains_alcohol": true,
      "": "string"
    }
  }
]

Responses

Status Meaning Description Schema
200 OK OK Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
anonymous [allOf] false none none

allOf

Name Type Required Restrictions Description
» anonymous ProductProperties false none none
»» gtin string false none none
»» name string false none none
»» description string false none none
»» category string false none none
»» brand string false none none
»» images [Image] false none none
»»» height integer(int32) true none none
»»» width integer(int32) true none none
»»» url string true none none
»» quantity ProductQuantity false none none
»»» value integer(int64) true none none
»»» unit string true none none
»»» amount integer(int64) true none none
»»» total integer(int64) true none none
»» attributes ProductAttributes false none none
»»» anonymous string false none none

and

Name Type Required Restrictions Description
» anonymous ProductRequiredProperties false none none
To perform this operation, you must be authenticated by means of one of the following methods: BearerToken

Create product

Code samples

POST /product

Add a product to the database

Body parameter

{
  "gtin": "8716700027200",
  "name": "Grolsch Pilsener krat",
  "description": "Grolsch Premium pilsner is vol van smaak met een aangename bitterheid en een rijke afdronk. Het wordt gebrouwen met twee soorten hop. Dit geeft Grolsch Premium pilsner haar unieke karakter.",
  "category": "beer",
  "images": [
    {
      "height": 800,
      "width": 800,
      "url": "https://static.ah.nl/dam/product/AHI_43545239383734363237?revLabel=1&rendition=800x800_JPG_Q90&fileType=binary"
    }
  ],
  "brand": "Grolsch",
  "quantity": {
    "value": 300,
    "unit": "ml",
    "amount": 24,
    "total": 7200
  },
  "attributes": {
    "alcohol_percentage": 5,
    "contains_alcohol": true,
    "": "string"
  }
}

Parameters

Name In Type Required Description
body body Product false none

Example responses

OK

{
  "gtin": "8716700027200",
  "name": "Grolsch Pilsener krat",
  "description": "Grolsch Premium pilsner is vol van smaak met een aangename bitterheid en een rijke afdronk. Het wordt gebrouwen met twee soorten hop. Dit geeft Grolsch Premium pilsner haar unieke karakter.",
  "category": "beer",
  "images": [
    {
      "height": 800,
      "width": 800,
      "url": "https://static.ah.nl/dam/product/AHI_43545239383734363237?revLabel=1&rendition=800x800_JPG_Q90&fileType=binary"
    }
  ],
  "brand": "Grolsch",
  "quantity": {
    "value": 300,
    "unit": "ml",
    "amount": 24,
    "total": 7200
  },
  "attributes": {
    "alcohol_percentage": 5,
    "contains_alcohol": true,
    "": "string"
  }
}

Already exists

{
  "code": 409,
  "message": "Resource already exists"
}

Responses

Status Meaning Description Schema
200 OK OK Product
409 Conflict Already exists Error
To perform this operation, you must be authenticated by means of one of the following methods: BearerToken

Schemas

Product

{
  "gtin": "8716700027200",
  "name": "Grolsch Pilsener krat",
  "description": "Grolsch Premium pilsner is vol van smaak met een aangename bitterheid en een rijke afdronk. Het wordt gebrouwen met twee soorten hop. Dit geeft Grolsch Premium pilsner haar unieke karakter.",
  "category": "beer",
  "images": [
    {
      "height": 800,
      "width": 800,
      "url": "https://static.ah.nl/dam/product/AHI_43545239383734363237?revLabel=1&rendition=800x800_JPG_Q90&fileType=binary"
    }
  ],
  "brand": "Grolsch",
  "quantity": {
    "value": 300,
    "unit": "ml",
    "amount": 24,
    "total": 7200
  },
  "attributes": {
    "alcohol_percentage": 5,
    "contains_alcohol": true,
    "": "string"
  }
}

Properties

allOf

Name Type Required Restrictions Description
anonymous ProductProperties false none none

and

Name Type Required Restrictions Description
anonymous ProductRequiredProperties false none none

ProductProperties

{
  "gtin": "8716700027200",
  "name": "Grolsch Pilsener krat",
  "description": "Grolsch Premium pilsner is vol van smaak met een aangename bitterheid en een rijke afdronk. Het wordt gebrouwen met twee soorten hop. Dit geeft Grolsch Premium pilsner haar unieke karakter.",
  "category": "beer",
  "images": [
    {
      "height": 800,
      "width": 800,
      "url": "https://static.ah.nl/dam/product/AHI_43545239383734363237?revLabel=1&rendition=800x800_JPG_Q90&fileType=binary"
    }
  ],
  "brand": "Grolsch",
  "quantity": {
    "value": 300,
    "unit": "ml",
    "amount": 24,
    "total": 7200
  },
  "attributes": {
    "alcohol_percentage": 5,
    "contains_alcohol": true,
    "": "string"
  }
}

Properties

Name Type Required Restrictions Description
gtin string false none none
name string false none none
description string false none none
category string false none none
brand string false none none
images [Image] false none none
quantity ProductQuantity false none none
attributes ProductAttributes false none none

ProductRequiredProperties

{}

Properties

None

ProductAttributes

{
  "alcohol_percentage": 5,
  "contains_alcohol": true,
  "": "string"
}

Properties

Name Type Required Restrictions Description
anonymous string false none none

ProductQuantity

{
  "value": 300,
  "unit": "ml",
  "amount": 24,
  "total": 7200
}

Properties

Name Type Required Restrictions Description
value integer(int64) true none none
unit string true none none
amount integer(int64) true none none
total integer(int64) true none none

Image

{
  "height": 300,
  "width": 200,
  "url": "https://picsum.photos/200/300"
}

Properties

Name Type Required Restrictions Description
height integer(int32) true none none
width integer(int32) true none none
url string true none none

Error

{
  "code": 500,
  "message": "Something went wrong"
}

Properties

Name Type Required Restrictions Description
code integer(int32) true none none
message string true none none

Health

{
  "healthy": true,
  "checks": {
    "memory": {
      "status": "up",
      "used": 300,
      "max": 512
    },
    "response-time": {
      "50": 7,
      "90": 12,
      "95": 14,
      "average": 8
    }
  },
  "dependencies": {
    "database": {
      "name": "Postgre",
      "healthy": true,
      "latency": 3
    }
  }
}

The current health of the api

Properties

Name Type Required Restrictions Description
healthy boolean false none none
checks object false none none
» memory object false none none
»» status string false none none
»» used integer false none none
»» max integer false none none
» response-time object false none none
»» 50 integer false none none
»» 90 integer false none none
»» 95 integer false none none
»» average integer false none none
dependencies object false none none
» anonymous HealthDependency false none none

Enumerated Values

Property Value
status up
status partial
status down

HealthDependency

{
  "name": "string",
  "latency": 0,
  "healthy": true
}

HealthDependency

Properties

Name Type Required Restrictions Description
name string true none none
latency integer true none none
healthy boolean true none none