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
- (Optional) When the app starts and after the settings are saved, the price checker fetches a token from the token URL.
- 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 headerAuthorization: Bearer <token>. - 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.
| Field | What to enter | Example |
|---|---|---|
| Url to token | The address that returns the token. | https://api.example.com/auth |
| GET / POST | Method of the token request. | POST |
| Body request | The JSON body sent with POST (the field is visible only for POST). | {"user":"pricechecker","password":"…"} |
| Path to token | Where the token is in the JSON response. | token or $.data.token |
Product data
| Field | What to enter | Example |
|---|---|---|
| Url to data | The product request address; {code} is replaced with the scanned code. | https://api.example.com/price?code={code} |
| GET / POST | Method of the product request. | GET |
| Body request | The JSON body for POST; you can use {code} here too. | {"ean":"{code}"} |
| Path to name | Path to the product name in the response. | product.name |
| Path to price | Path 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.