Comment on page

Source Files

Source files are files that contain things you want to annotate or run models on. Currently we support PDF and .txt file formats
get
https://api.annolab.ai
/v1/source/{source_id}
Retrieve source information
// Example Response
{
"id": 2,
"projectName": "My Project",
"projectId": 1,
"directoryName": "Uploads",
"directoryId": 1,
"name": "REGISTRATION.pdf",
"sourceName": "REGISTRATION.pdf",
"type": "pdf",
"text": "Example PDF Text",
"url": "https://download-example-url.pdf",
"createdAt": "2023-05-22T20:32:02.633Z",
"tags": [
{
"domainEntityId": 1,
"typeName": "Airframe Inventory",
"attributes": [
{
"name": "Make",
"value": "CESSNA"
},
{
"name": "Model",
"value": "421C"
},
{
"name": "Serial Number",
"value": "421C-5837"
}
],
"createdBy": {
"id": 58473,
"email": "[email protected]",
"username": "testuser"
}
}
]
}
post
https://api.annolab.ai
/v1/source/upload-pdf
Upload a PDF
Python
import os
import json
import requests
ANNO_LAB_API_KEY = 'XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'
url_base = 'https://api.annolab.ai'
input_pdf = '/Users/grantdelozier/devel/ocr-these3/TEST-REGISTRATION.PDF'
headers = {
'Authorization': 'Api-Key '+ANNO_LAB_API_KEY,
}
url = url_base+'/v1/source/create-pdf'
requestBody = {
'groupName': 'AnnoLab',
'projectIdentifier': 'title-demo',
'directoryIdentifier': 'testing',
'sourceIdentifier': 'TEST-REGISTRATION.PDF',
'preprocessor': 'faa',
'processMode': 'OCR',
'ocrProvider': 'textract_plus',
'workflow': 'FAA_CD'
}
fileToUpload = {
'file': ('TEST-REGISTRATION.PDF', open(input_pdf, 'rb'), 'application/pdf')
}
url = url_base+'/v1/source/upload-pdf'
response = requests.post(url, headers=headers, data=requestBody, files=fileToUpload)
print(response.json())
post
https://api.annolab.ai
/v1/source/create-text
Create Source Text
This code shows how to create a new text file source
Python
import requests
ANNO_LAB_API_KEY = 'XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX'
source = {
'projectIdentifier': 'New NER Project',
'directoryIdentifier': 'Wikipedia Subset',
'sourceName': 'athens.txt'
'text': 'Athens (Greek: Αθήνα, Athína), is the capital city of Greece with a metropolitan population of 3.7 million inhabitants.'
}
headers = {
'Authorization': 'Api-Key '+ANNO_LAB_API_KEY,
}
url = 'https://api.annolab.ai/v1/source/create-text'
response = requests.post(url, headers=headers, json=source)
print(response.json())