Photon Commerce API
  • Getting Started with the Photon Commerce API
    • Register a new account
    • Capture an invoice or receipt in real time
    • Confidence Scores & Coordinates
  • Update Document
    • Update Fields
    • Update Line Items
    • Add Line Item
    • Delete Line Item
  • Retrieve Data
  • Async API
  • Async API Webhook
  • Bank Transaction Categorization
  • Invoice Approvals
  • Status Codes
Powered by GitBook
On this page
  • Asynchronous API for batches and queues of documents
  • Invoice and receipt capture
  • Async API Webhook

Was this helpful?

Async API

For async processing of your documents

Asynchronous API for batches and queues of documents

A typical REST API which accepts your documents and returns the photon key needed to access the result in less than a second. Be sure to save that photon key in order to be able to fetch the results later.

No need to wait for the results. You will be notified via email when the document has been processed and the result is ready to be fetched. This ASYNC API allows us to upload multiple documents, one after another with a minimal waiting time. Store the photon_key we send in the response and access it once you receive an email from Photon.

Invoice and receipt capture

POST https://api.photoncommerce.com/api/v4?type=async

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

Path Parameters

Name
Type
Description

type

string

Type of processing needed- sync or async Please pass type as 'async'

Headers

Name
Type
Description

PASSWORD

string

The password of the account

SECRET-KEY

string

The secret key of the account

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

pdf

string

The path to the pdf, document, or image needing to be captured.

{'photon_key': 'data/<your_username>/<filename>.json', 'message': 'success', 'status': 'success'}
import requests

headers = {
    'CLIENT-ID': '<client-id>',
    'AUTHORIZATION': 'apikey <username>:<api-key>',
    'PASSWORD':'<Your-valid-password>',
    'SECRET-KEY':'<your-client-secret>'
}
files = {'pdf': open('<path-to-file>', 'rb')}

response = requests.post('https://api.photoncommerce.com/api/v4?type=async', headers=headers, files=files)
curl  -X POST -H "CLIENT-ID:<client-id>" -H "AUTHORIZATION:apikey <username>:<api-key>" -H 'PASSWORD:<password>' -H "SECRET-KEY:<secret-key>" -F "pdf=@<path-to-file>" "https://api.photoncommerce.com/api/v4?type=async"
var request = require('request');

var headers = {
    'CLIENT-ID': '<client-id>',
    'AUTHORIZATION': 'apikey <username>:<api-key>',
    'PASSWORD': '<password>',
    'SECRET-KEY': '<secret-key>'
};

var options = {
    url: 'https://api.photoncommerce.com/api/v4?type=async',
    method: 'POST',
    headers: headers
};

function callback(error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body);
    }
}

request(options, callback);
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {
		URL url = new URL("https://api.photoncommerce.com/api/v4?type=async");
		HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
		httpConn.setRequestMethod("POST");

		httpConn.setRequestProperty("CLIENT-ID", "<client-id>");
		httpConn.setRequestProperty("AUTHORIZATION", "apikey <username>:<api-key>");
		httpConn.setRequestProperty("PASSWORD", "<password>");
		httpConn.setRequestProperty("SECRET-KEY", "<secret-key>");

		InputStream responseStream = httpConn.getResponseCode() / 100 == 2
				? httpConn.getInputStream()
				: httpConn.getErrorStream();
		Scanner s = new Scanner(responseStream).useDelimiter("\\A");
		String response = s.hasNext() ? s.next() : "";
		System.out.println(response);
	}
}

Once your document has been processed, you will receive an email from notifications@photoncommerce.com with the subject "Photon API - The document has been processed". Upon receiving this email, you can fetch the result using the photon_key we sent to you when you uploaded the document. In case you missed it, the email we send you will also contain the photon key.

You can use the fetch the json by following the steps mentioned under the section 'Retrieve Data (JSON)" on the "Getting Started with the Photon Commerce API" Page.

Async API Webhook

Please see the Async API Webhook page for instructions to set up a webhook.

PreviousRetrieve DataNextAsync API Webhook

Last updated 3 years ago

Was this helpful?