import json
import requests
url = 'https://api.ade.landing.ai/v1/ade/classify'
headers = {'Authorization': 'Bearer YOUR_API_KEY'}
files = {'document': open('document.pdf', 'rb')}
data = {'classes': json.dumps([{"class": "invoice", "description": "A commercial bill with line items, totals, and payment terms"}, {"class": "bank_statement", "description": "A monthly summary of account transactions"}])}
response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())curl -X POST 'https://api.ade.landing.ai/v1/ade/classify' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-F 'document=@document.pdf' \
-F 'classes=[{"class":"invoice","description":"A commercial bill with line items, totals, and payment terms"},{"class":"bank_statement","description":"A monthly summary of account transactions"}]'const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const form = new FormData();
form.append('document', fs.createReadStream('document.pdf'));
form.append('classes', JSON.stringify([{"class": "invoice", "description": "A commercial bill with line items, totals, and payment terms"}, {"class": "bank_statement", "description": "A monthly summary of account transactions"}]));
axios.post('https://api.ade.landing.ai/v1/ade/classify', form, {
headers: { 'Authorization': 'Bearer YOUR_API_KEY', ...form.getHeaders() }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));{
"classification": [
{
"class": "<string>",
"reason": "<string>",
"page": 123,
"suggested_class": "<string>"
}
],
"metadata": {
"page_count": 123,
"duration_ms": 123,
"filename": "",
"org_id": "<string>",
"credit_usage": 0,
"job_id": "",
"version": "<string>"
}
}{
"code": "<string>",
"message": "<string>"
}ADE Classify
Classify each page of a document into classes you define. Accepts a PDF, an image, or an Office document, plus the list of candidate classes; returns one predicted class per page. Runs synchronously and returns the result inline.
import json
import requests
url = 'https://api.ade.landing.ai/v1/ade/classify'
headers = {'Authorization': 'Bearer YOUR_API_KEY'}
files = {'document': open('document.pdf', 'rb')}
data = {'classes': json.dumps([{"class": "invoice", "description": "A commercial bill with line items, totals, and payment terms"}, {"class": "bank_statement", "description": "A monthly summary of account transactions"}])}
response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())curl -X POST 'https://api.ade.landing.ai/v1/ade/classify' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-F 'document=@document.pdf' \
-F 'classes=[{"class":"invoice","description":"A commercial bill with line items, totals, and payment terms"},{"class":"bank_statement","description":"A monthly summary of account transactions"}]'const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const form = new FormData();
form.append('document', fs.createReadStream('document.pdf'));
form.append('classes', JSON.stringify([{"class": "invoice", "description": "A commercial bill with line items, totals, and payment terms"}, {"class": "bank_statement", "description": "A monthly summary of account transactions"}]));
axios.post('https://api.ade.landing.ai/v1/ade/classify', form, {
headers: { 'Authorization': 'Bearer YOUR_API_KEY', ...form.getHeaders() }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));{
"classification": [
{
"class": "<string>",
"reason": "<string>",
"page": 123,
"suggested_class": "<string>"
}
],
"metadata": {
"page_count": 123,
"duration_ms": 123,
"filename": "",
"org_id": "<string>",
"credit_usage": 0,
"job_id": "",
"version": "<string>"
}
}{
"code": "<string>",
"message": "<string>"
}Body
The classes to assign to pages, as a JSON-encoded array of objects with class (required) and description keys. Each page receives one class, or unknown when no class fits.
The file to process. Provide either document or document_url, not both.
A publicly accessible URL to the file to process. Provide either document or document_url, not both.
Optional. Defaults to the document's own file name.
Optional. Defaults to the document's own detected media type.
The classify model version to use. Accepts classify-latest or a dated snapshot. Defaults to the latest version.
Was this page helpful?