Endpoints

All the requests should be sent to this particular endpoint. You will always make calls to jager.brainter.xyz/api. You can configure the expected result from this call by providing GET parameters. Only the url parameter is required, others are optional.

Parameters

Parameter Required / Optional Type Description
img required string (url) This parameters should hold the url to the image that this API should examine and come up with result whether it is a valid receipt, whether is may be valid receipt (witohout 100% confidentality) or whether it is not a receipt for sure. An example usage would be ?img=https://careers.brainster.co/images/first.png
iwantstatus optional 0, 1 or 2 If this parameter is not provided then the API will return a random response. 0 means that the images is not a valid receipt, 1 that the image is certainly a valid receipt and status 2 means that the provided image may or may not be a valid receipt (the API is not 100% sure). If you want the API call to always return certain status then include this parameter in the request with the status you want returned. See an example usage below.

Response

The response will always contain a JSON string, with two or three elements. Each of them is explained in the table below.
Element Always / Sometimes Type Description
code always integer (200 or 400) Code will indicate whether the request is successful or not. Code 200 means the request is successful and code 400 means the request is not successful (for example, you didn't provide the url parameter which is required).
img_status always 0, 1 or 2 This element indicates the status of the provided image.
Status 0 means the image is certainly not a valid images.
Status 1 means the provided image certainly contains a receipt.
Status 2 means the provided image may or may not be a receipt, the algorithm can not conclude with certainty.
text sometimes string This element will be included in the response only if the status of the image is 1 or 2. It represents that text that is automatically extracted from the image.

Examples

Here are all the possible combinations in which you can use the api and all the responses it can return
Request Response Comment
https://jager.brainster.xyz/api {
code: 400,
img_status: null,
text: "Required parameter `img` not found."
}
Since the url parameter is required and was not provied, the API returns code 400 and the reason for the code in the text field
https://jager.brainster.xyz/api?img=http://localhost/images/receipt.jpg {
code: 200,
img_status: 0
}
Url is provided, so the API returns valid info. Note that call like this will randomly return either image status 0, 1 or 2. If it returns 1 or 2 then the text element will be included in the response too.
https://jager.brainster.xyz/api?img=http://localhost/images/receipt.jpg&iwantstatus=3 {
code: 400,
img_status: null,
text: "Invalid type of `iwantstatus`. Allowed: 0, 1 and 2"
}
Since the value of the iwantstatus parameter is not in the list of the accepted values an invalid response like this is returned.
https://jager.brainster.xyz/api?img=http://localhost/images/receipt.jpg&iwantstatus=0 {
code: 200,
img_status: 0
}
We explicitely ask for status 0 and that is what will be always returned for a request like this.
https://jager.brainster.xyz/api?img=http://localhost/images/receipt.jpg&iwantstatus=1 {
code: 200,
img_status: 1,
text: "Some long random text here..."
}
We explicitely ask for status 1 and that is what will be always returned for a request like this.
https://jager.brainster.xyz/api?img=http://localhost/images/receipt.jpg&iwantstatus=2 {
code: 200,
img_status: 2,
text: "Some long random text here..."
}
We explicitely ask for status 2 and that is what will be always returned for a request like this.