Skip to main content

REST API

The Rest API source lets you connect the price checker to any system that returns a product's name and price in JSON for a given code — e.g. an online store, a POS system or your own middleware service.

How it works​

  1. (Optional) When the app starts and after the settings are saved, the price checker fetches a token from the token URL.
  2. After every scan it sends a request to the data URL, in which {code} is replaced with the scanned code. If it has a token, it adds the header Authorization: Bearer <token>.
  3. It reads the name, the price and optionally the EAN from the JSON response — using the paths you specify.

Both http:// and https:// work. The app waits about 10 seconds for a response.

Fields​

Token (optional) — leave Url to token empty if the API does not require authentication.

FieldWhat to enterExample
Url to tokenThe address that returns the token.https://api.example.com/auth
GET / POSTMethod of the token request.POST
Body requestThe JSON body sent with POST (the field is visible only for POST).{"user":"pricechecker","password":"…"}
Path to tokenWhere the token is in the JSON response.token or $.data.token

Product data

FieldWhat to enterExample
Url to dataThe product request address; {code} is replaced with the scanned code.https://api.example.com/price?code={code}
GET / POSTMethod of the product request.GET
Body requestThe JSON body for POST; you can use {code} here too.{"ean":"{code}"}
Path to namePath to the product name in the response.product.name
Path to pricePath to the price; the value must be a number.product.price
Path to EAN (optional)Path to the EAN code shown below the price. Empty = the scanned code is shown below the price.product.ean

Paths use JsonPath syntax: product.name and $.product.name mean the same, an array element is e.g. $.items[0].price. POST requests are sent with the header Content-Type: application/json; charset=utf-8.

Example​

The request after scanning the code 5901234567890:

GET https://api.example.com/price?code=5901234567890
Authorization: Bearer eyJhbGciOi...

A response the price checker understands:

{
"product": {
"name": "Coffee beans 1 kg",
"price": 59.99,
"ean": "5901234567890"
}
}

Settings: Path to name product.name, Path to price product.price, Path to EAN product.ean. Return the price as a number with a decimal point — the price checker formats it according to the Price format field.

API requirements​

  • For a found product, the API answers with a 2xx status and JSON that contains the name and the price.
  • Any other response (e.g. 404 for an unknown code, 401 for an invalid token, a missing field in the JSON) shows Data download error on the screen. With REST API the app does not show “Product not found” — if you want customers to tell these cases apart, return e.g. the name “Product not available” with price 0.
  • The code is inserted into the URL without encoding. EAN codes and typical symbols cause no trouble; if your symbols contain spaces or special characters, use a POST request with the code in the body.
  • The token is fetched only when the app starts and after the settings are saved — the app does not renew it by itself. Use a long-lived token or a key that does not expire; after the token expires, restarting the app helps.

The Connection test in the settings checks only the token request. When the token URL is empty, the test always succeeds — the real check is scanning a few products after saving the settings.

REST API — FAQ

How do I connect the HDWR price checker to my own system?
Choose the Rest API source and enter the product request address with the {code} placeholder where the code goes, e.g. https://api.example.com/price?code={code}, plus the paths to the name and the price in the JSON response. Optionally enter an address from which the app fetches a Bearer token.
Why does the price checker show Data download error instead of Product not found with REST API?
With REST API every response other than 2xx, or a response without the name or price field, is treated as an error. If the API returns 404 for an unknown code, the screen shows Data download error.
Does the app renew the REST API token?
No. The token is fetched when the app starts and after the settings are saved. Use a long-lived token; after it expires, restart the app.
Does the price checker support plain HTTP?
Yes, it supports http and https. In the store's local network you can use http; for an API on the internet use https.