Create schema extraction job
curl --request POST \
--url https://api.tile.run/v1/extract \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"file_id": "<string>",
"document_schema": {}
}
'import requests
url = "https://api.tile.run/v1/extract"
payload = {
"file_id": "<string>",
"document_schema": {}
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({file_id: '<string>', document_schema: {}})
};
fetch('https://api.tile.run/v1/extract', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tile.run/v1/extract",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'file_id' => '<string>',
'document_schema' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tile.run/v1/extract"
payload := strings.NewReader("{\n \"file_id\": \"<string>\",\n \"document_schema\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.tile.run/v1/extract")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"file_id\": \"<string>\",\n \"document_schema\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tile.run/v1/extract")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"file_id\": \"<string>\",\n \"document_schema\": {}\n}"
response = http.request(request)
puts response.read_body{
"extraction_id": "<string>",
"status": "<string>",
"created_at": "2023-11-07T05:31:56Z"
}Endpoints
Extract data from a file
Create a new schema extraction job for a file based on predefined schema
POST
/
extract
Create schema extraction job
curl --request POST \
--url https://api.tile.run/v1/extract \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"file_id": "<string>",
"document_schema": {}
}
'import requests
url = "https://api.tile.run/v1/extract"
payload = {
"file_id": "<string>",
"document_schema": {}
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({file_id: '<string>', document_schema: {}})
};
fetch('https://api.tile.run/v1/extract', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tile.run/v1/extract",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'file_id' => '<string>',
'document_schema' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tile.run/v1/extract"
payload := strings.NewReader("{\n \"file_id\": \"<string>\",\n \"document_schema\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.tile.run/v1/extract")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"file_id\": \"<string>\",\n \"document_schema\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tile.run/v1/extract")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"file_id\": \"<string>\",\n \"document_schema\": {}\n}"
response = http.request(request)
puts response.read_body{
"extraction_id": "<string>",
"status": "<string>",
"created_at": "2023-11-07T05:31:56Z"
}Document schema structure
Thedocument_schema object should conform to the following structure.
{
"name": "Invoice",
"description": "Schema for extracting invoice details",
"fields": [
{
"name": "invoice_number",
"description": "The unique identifier for the invoice",
"type": "string"
},
{
"name": "issue_date",
"description": "The date when the invoice was issued",
"type": "date"
},
{
"name": "customer",
"description": "Customer information",
"type": "object",
"fields": [
{
"name": "name",
"description": "Customer's full name",
"type": "string"
},
{
"name": "email",
"description": "Customer's email address",
"type": "email"
}
]
},
{
"name": "line_items",
"description": "List of items in the invoice",
"type": "array",
"fields": [
{
"name": "description",
"description": "Item description",
"type": "string"
},
{
"name": "amount",
"description": "Item cost",
"type": "number"
}
]
}
]
}
Primitive fields
string: Generic text datanumber: Numeric valuesemail: Email addressesphone: Phone numbersdate: Date values
Objects and arrays
object: Nested object containing additional fields where each field is a primitive field.array: List of items where each element is an object. As above, fields within each object can be any one of the primitive fields.
Best Practices
Field names
Use clear, descriptive names and avoid special characters. We recommend using snake case.
Descriptions
Descriptions are critical for accuracy. If you want to consistent formatting,
include this in the description.
Nested structures
We support 3 levels of nesting for objects. Where possible, we recommend
avoiding deeply nested objects as this reduces accuracy.
Nested objects within arrays
We do not currently support nested objects within arrays. This is on our roadmap.
Headers
Bearer token for authentication
Body
application/json