Capture an invoice or receipt in real time

A typical REST API POST of a PDF or image that is less than 1MB or 3 pages takes about 4-7 seconds to return a structured JSON response. Snippets of API calls in various languages, such as python, PHP, JAVA, C#, etc., are available upon request.

The following section explains how to pass your credentials to authenticate API requests and receive your JSON response.

You can submit local files or files at a url. This first example will submit a file by its url, but we have examples to submit local files with code at the end this page.

curl --location --request POST 'https://api.photoncommerce.com/api/v4?url=https://photon-api-demo.s3.us-west-1.amazonaws.com/demo_docs/02-02-2021_-_TuneGO_2.0.pdf' \
--header 'PASSWORD: Passit123@' \
--header 'SECRET-KEY: KNYh8XJX3xXEFftfoAd5' \
--header 'AUTHORIZATION: apikey pran.81gmail.com:e-hmk5s3qeSaWhc368pd' \
--header 'CLIENT-ID: iyeHs0oJRAooRw'

Specify Document Type: Our API intelligently and accurately classifies the documents into the following document types:

  1. Invoice (Photon doctype value: invoice)

  2. Receipt (Photon doctype value: receipt)

  3. Check (Photon doctype value: check)

  4. Remittance (Photon doctype value: remittance)

  5. Statement (Photon doctype value: statement)

  6. Purchase Order (Photon doctype value: purchaseorder)

You can pre-specify the document type by using the doctype parameter.

***Note: The value of this parameter should be in lowercase and must not contain any spaces. If any arbitrary document type is specified, Photon will re-classify the document using its own logic. Here is an example python script.

Validations - If you wish to retrieve validation scores in the form of the following keys, set 'Validations' to 'true' in the Authentication Header:

  • FraudScore: Value from 0-100 which indicates the similarity of the document with any previously uploaded documents. If the same document has been uploaded before, the Fraud_Score will be '100'

  • Subtotal_Line_Items: Binary value ('0' or '1') based on whether the subtotal is equal to the sum of all the amounts in Line_Items.

  • Total_Subtotal: Binary value ('0' or '1') based on whether Total = Subtotal + Shipping + Tax -Discount

Header - Only: If you wish to prioritise speed over line item extraction accuracy, you can get faster results by setting the parameter 'Header-Only' to 'true' in the Authentication Header

If you contacted Photon Commerce to receive an API Key, skip the following POST request section and read on. If you registered for credentials using your email address and password, the authentication parameters in your API requests will slightly differ. The following block explains how to pass your credentials to authenticate API requests.

Invoice and receipt capture

POST https://api.photoncommerce.com/api/v4

Capture invoices and receipts using your Client ID, Client Secret, API Key and Username

Headers

Name
Type
Description

PASSWORD

string

The password you used for your email registration

SECRET-KEY

string

Your secret key as a string

AUTHORIZATION

string

Pass your username and unique API key in the form 'apikey <your_username>:<your_api_key>'

CLIENT-ID

string

Unique Client_ID for every user. Incorrect value will lead to an authorization error.

Request Body

Name
Type
Description

doctype

string

One can specify the type of document. E.g invoice, receipt, check, etc.

coordinates

integer

To retrieve bounding box coordinates for the values, set this parameter to 1

confidence

integer

To retrieve confidence scores for the values, set this parameter to 1

pdf

string

The path to the pdf, document, or image needing to be captured. Any image or Word document are also acceptable.

The following are key fields that the API returns, including the type and description. A complete list is below this table.

Field

Type

Description

Invoice_Number

string

Invoice number

PO_Number

string

Purchase Order number

Date

string <yyyy-MM-dd>

Document date as it appears in the document

Payment_Terms

string

Terms of payment, e.g., Net-30

Due_Date

string <yyyy-MM-dd>

Invoice due date

Currency_Code

string

Currency code, e.g., USD, EUR, CNY, etc.

Discount

decimal

Discount provided on the invoice or receipt

Vat_Number

string

The Value Added Tax number, e.g., 12-3456789

Total

decimal

Total of the invoice or receipt

The following describes the complete fields and value types. Empty and null values for all fields will appear as with 0 or empty quotations "", depending on if the field type is numeric or text. For an example response, please see the above "Response" tab.

Last updated

Was this helpful?