Documentation

Learn how to integrate Receipt Scan into your apps.

API Documentation Javascript Library Quick Start Guide

Analyze Receipt

POST https://app.receiptscan.co.uk/api/analyze_receipt

Description

This endpoint allows you to analyze a receipt by uploading an image or PDF file. The API will extract relevant information from the receipt and return it in a structured JSON format.

Headers

Name Required Description
AccessToken Yes Your API key for authentication

Body

The request body should be a multipart/form-data with the following parameter:

Name Required Type Description
file Yes File The image or PDF invoice file to be analyzed

Example Request

curl --location 'https://app.receiptscan.co.uk/api/analyze_receipt' \
--header 'AccessToken: YOUR_API_KEY' \
--form 'file=@"/path/to/your/receipt.pdf"'

Response

The API returns a JSON object with the following properties:

Field Type Description
ReceiptDate String The date of the receipt (format: dd/MM/yyyy)
NetValue Decimal The net value of the purchase
TaxValue Decimal The tax amount
Total Decimal The total amount of the purchase
TaxRate String The tax rate applied
ReceiptNumber String The unique identifier for the receipt
Summary String A brief description of the purchase
OrderNumber String The order number (if available)
VATNumber String The VAT number of the retailer
Retailer String The name of the retailer
items Array An array of items purchased, each containing Description, Price, and Qty

Example Response

{
    "ReceiptDate": "01/08/2024",
    "NetValue": 6.12,
    "TaxValue": 1.23,
    "Total": 7.35,
    "TaxRate": "20%",
    "ReceiptNumber": "",
    "Summary": "Isopropanol Alcohol IPA 99.99% 1L\nShipping Charges: £0.00",
    "OrderNumber": "026-1936828-2277101",
    "VATNumber": "GB205462631",
    "Retailer": "Trade Chemicals Limited",
    "items": [
        {
            "Description": "Isopropanol Alcohol IPA 99.99% 1L",
            "Price": 6.12,
            "Qty": 1
        }
    ]
}

Error Handling

In case of errors, the API will return an appropriate HTTP status code along with a JSON object containing an error message. Common error scenarios include:

  • 401 Unauthorized: Invalid or missing API key
  • 400 Bad Request: Missing or invalid file upload
  • 403 Forbidden: Not enough credits to complete this request.
  • 500 Internal Server Error: Server-side processing error

Rate Limiting

Please refer to your API plan for information on rate limits. If you exceed the rate limit, you'll receive a 429 Too Many Requests response.

View Credits

GET https://app.receiptscan.co.uk/api/credits

Description

This endpoint allows you to retrieve the current credit balance and subscription renewal date for your account.

Headers

Name Required Description
AccessToken Yes Your API key for authentication

Example Request

curl --location 'https://app.receiptscan.co.uk/api/credits' \
--header 'AccessToken: YOUR_API_KEY'

Response

The API returns a JSON object with the following properties:

Field Type Description
Credits Integer The current number of credits available in your account
SubscriptionRenewalDate String The date when your subscription will renew (format: dd/MM/yyy HH:mm)
SubscriptionPlan String The name of your subscription plan

Example Response

{
    "Credits": 998,
    "SubscriptionRenewalDate": "20/10/2024 14:09",
    "SubscriptionPlan": "Growth"
}

Error Handling

In case of errors, the API will return an appropriate HTTP status code along with a JSON object containing an error message. Common error scenarios include:

  • 401 Unauthorized: Invalid or missing API key
  • 500 Internal Server Error: Server-side processing error

Support

For any questions or issues regarding the API, please contact our support team at support@receiptscan.co.uk.

Including the Script

To use ReceiptScan in your web application, include the following script tag in your HTML file:

<script async src="https://app.receiptscan.co.uk/receiptscan.js?key=AAAAA11111111222222"></script>

Replace AAAAA11111111222222 with your actual API key.

Using ReceiptScan

The ReceiptScan function can be used in several ways:

1. With a File Object (Callback)

receiptScan(fileObject, fields, function(result, error) {
    if (error) {
        console.error(error);
    } else {
        console.log(result);
    }
});

2. With a URL (Callback)

receiptScan('https://example.com/receipt.jpg', fields, function(result, error) {
    if (error) {
        console.error(error);
    } else {
        console.log(result);
    }
});

Note: Be mindful of CORS

3. With a File Object (Async/Await)

async function scanReceipt(fileObject) {
    try {
        const results = await receiptScan(fileObject);
        console.log(results);
    } catch (error) {
        console.error(error);
    }
}
scanReceipt();

4. With a URL (Async/Await)

async function scanReceipt() {
    try {
        const results = await receiptScan('https://example.com/receipt.pdf');
        console.log(results);
    } catch (error) {
        console.error(error);
    }
}
scanReceipt();

Note: Be mindful of CORS

5. Using the File Input Listener

To add a listener to a file input element:

<input type="file" id="receiptInput">

<script>
receiptScanListener('receiptInput', fields);
</script>

The 'fields' Parameter

The fields parameter is an array of objects that specify which fields from the scanned document should be mapped to which HTML elements. For example:

const fields = [
    { Field: "Total", Element: "totalAmount" },
    { Field: "ReceiptDate", Element: "purchaseDate" },
    { Field: "ReceiptNumber", Element: "reference" }
];

receiptScan(fileObject, fields, function(result, error) {
// Handle result or error
});

In this example, the "Total" field from the scanned document will be placed into an HTML element with the id "totalAmount", and so on.

If you do not want the form to auto populate, provide a blank string '' to the fields parameter.

Response

The API returns a JSON object with the following properties:

Field Type Description
ReceiptDate String The date of the receipt (format: dd/MM/yyyy)
NetValue Decimal The net value of the purchase
TaxValue Decimal The tax amount
Total Decimal The total amount of the purchase
TaxRate String The tax rate applied
ReceiptNumber String The unique identifier for the receipt
Summary String A brief description of the purchase
OrderNumber String The order number (if available)
VATNumber String The VAT number of the retailer
Retailer String The name of the retailer
items Array An array of items purchased, each containing Description, Price, and Qty

Example Response

{
    "ReceiptDate": "01/08/2024",
    "NetValue": 6.12,
    "TaxValue": 1.23,
    "Total": 7.35,
    "TaxRate": "20%",
    "ReceiptNumber": "",
    "Summary": "Isopropanol Alcohol IPA 99.99% 1L\nShipping Charges: £0.00",
    "OrderNumber": "026-1936828-2277101",
    "VATNumber": "GB205462631",
    "Retailer": "Trade Chemicals Limited",
    "items": [
        {
            "Description": "Isopropanol Alcohol IPA 99.99% 1L",
            "Price": 6.12,
            "Qty": 1
        }
    ]
}

Notes

  • ReceiptScan supports both image files and PDF documents.
  • The API key is automatically included in requests, you don't need to handle it manually.
  • Always handle potential errors in your code to ensure a smooth user experience.

Coming soon!

Need help implementing Receipt Scan?

Get in Touch!

Pricing

Starter

£39/month

  • 250 scans/month
  • Javascript Library
  • Product support
  • API access
  • 24 Hours data retention
Get Started

Growth

£119/month

  • 1,000 scans/month
  • Javascript Library
  • Product support
  • API access
  • 30 Days data retention
Choose Growth

Scale

£249/month

  • 2,500 scans/month
  • Javascript Library
  • Priority support
  • API access
  • Custom integrations
  • 60 Days data retention
Choose Scale
Scans outside of a plan are charged at £0.16/scan
1 page = 1 scan. Multi-page documents are charged per page.