๐ API Documentation
Everything you need to integrate with Receipt Scan AI.
๐ Getting Started
The Receipt Scan AI API enables developers to extract structured data from receipts and invoices.
Get started by adding your payment information for a free trial for the first month and
generate your API Key from the Dashboard Page.
You will need an Open AI or Gemini API key to use this API.
๐ Authentication
Every request must include your apiKey
(generated in your Receipt Scan AI dashboard)
and a modelKey
from your chosen AI provider (OpenAI or Gemini).
Important: Keep your keys secret. Rotate them immediately if compromised.
๐ How to Get API Keys
- Gemini API (Google AI Studio): Get your Gemini API key
- OpenAI API: Get your OpenAI API key
Use your Receipt Scan AI apiKey
together with either an OpenAI or Gemini modelKey
.
๐งพ Extract Invoice Data
Extract structured data (items, total, tax, date) from a receipt or invoice image.
Example Request:

POST https://extractinvoicedatahttp-loshywauza-uc.a.run.app { "apiKey": "your-api-key", "modelKey": "openai-or-gemini-model-key", "model_type": "openai", // or "gemini" "image": "base64-encoded-image" }
Example Response:
{ "items": [ "VEGETABLE & FRUITS", "WATER BOTTEL 5LTR", "AL MARAI 200ML" ], "invoice_date": "2025-09-07", "total_price": 14, "tax": 1.83, "isImageAReceipt": true }
โก Generate New API Key
You can generate or rotate API keys from the Dashboard Page
๐ฆ Strict Mode
Strict Mode: when enabled, malformed AI responses will be rejected with an error. Disable it for fallback parsing.
For example, if you send an image that is not a receipt image or the API failed to detect any product from that image, the API will respond with a 400 error code if strict mode is enabled.
โ ๏ธ Error Handling
Common error codes:
400
โ Missing required fields / invalid model type403
โ Subscription inactive or expired500
โ Internal server error
Example Error:
{ "error": "Inactive or missing subscription." }
๐ฐ Pricing & Limitations
- After adding your payment information, you get a 1-month Free Trial
- You can extract data from an unlimited number of receipt images
- After the trial, you will be charged 9.99$ per month
๐ป Example Integrations
Use these code snippets to integrate with your Cloud Function.
JavaScript (Node.js)
async function extractInvoice(base64Image, apiKey, modelKey, modelType) { const response = await fetch( "https://extractinvoicedatahttp-loshywauza-uc.a.run.app", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ apiKey, modelKey, model_type: modelType, image: base64Image }) } ); const data = await response.json(); console.log("Extracted:", data); }
๐ Python
import requests import json def extract_invoice(base64_image, api_key, model_key, model_type): url = "https://extractinvoicedatahttp-loshywauza-uc.a.run.app" payload = { "apiKey": api_key, "modelKey": model_key, "model_type": model_type, "image": base64_image } response = requests.post(url, headers={"Content-Type": "application/json"}, data=json.dumps(payload)) print("Extracted:", response.json())
๐น Golang
package main import ( "bytes" "encoding/json" "fmt" "net/http" "io/ioutil" ) func extractInvoice(base64Image, apiKey, modelKey, modelType string) { url := "https://extractinvoicedatahttp-loshywauza-uc.a.run.app" payload := map[string]string{ "apiKey": apiKey, "modelKey": modelKey, "model_type": modelType, "image": base64Image, } body, _ := json.Marshal(payload) resp, _ := http.Post(url, "application/json", bytes.NewBuffer(body)) defer resp.Body.Close() data, _ := ioutil.ReadAll(resp.Body) fmt.Println("Extracted:", string(data)) }
โ๏ธ ReactJS (Frontend)
import { useState } from "react"; export default function InvoiceUploader() { const [output, setOutput] = useState(""); async function handleExtract(base64Image, apiKey, modelKey, modelType) { const res = await fetch( "https://extractinvoicedatahttp-loshywauza-uc.a.run.app", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ apiKey, modelKey, model_type: modelType, image: base64Image, }), } ); const data = await res.json(); setOutput(JSON.stringify(data, null, 2)); } return ( <div> <button onClick={() => handleExtract("BASE64_IMAGE", "YOUR_API_KEY", "MODEL_KEY", "openai")}> Extract Invoice </button> <pre>{output}</pre> </div> ); }
๐ป cURL
To call the API you must pass your apiKey
, the model key (either OpenAI or Gemini),
and the image encoded as a Base64 string.
Convert your image to Base64 first:
-
Mac/Linux:
base64 invoice.png | tr -d '\n' > invoice.b64.txt
(The Base64 string will be written intoinvoice.b64.txt
.) -
Windows PowerShell:
$imgPath = "C:\path\to\invoice.png"
$base64 = [Convert]::ToBase64String((Get-Content $imgPath -Encoding Byte))
$base64 | Out-File "C:\path\to\invoice.b64.txt"
Example request with cURL:
curl -X POST "https://extractinvoicedatahttp-loshywauza-uc.a.run.app" \ -H "Content-Type: application/json" \ -d '{ "apiKey": "YOUR_API_KEY", "modelKey": "OPENAI_OR_GEMINI_MODEL_KEY", "model_type": "openai", "image": "BASE64_ENCODED_IMAGE" }'
๐ป PowerShell (Invoke-RestMethod)
$imgPath = "C:\path\to\invoice.png" $base64 = [Convert]::ToBase64String((Get-Content $imgPath -Encoding Byte)) $body = @{ apiKey = "YOUR_API_KEY" modelKey = "OPENAI_OR_GEMINI_MODEL_KEY" model_type = "openai" image = $base64 } | ConvertTo-Json -Depth 3 $response = Invoke-RestMethod -Uri "https://extractinvoicedatahttp-loshywauza-uc.a.run.app" ` -Method Post ` -Headers @{ "Content-Type" = "application/json" } ` -Body $body $response
This PowerShell example reads the image, encodes it to Base64, and sends it to the API with Invoke-RestMethod
.