Python
import requests
url = "https://api.parser.expert/v1/upload"
headers = {
'X-API-Key': 'sk-xxxx'
}
files = {
'file': open('/path/to/your/file.pdf', 'rb'),
'bucket_id': (None, '100202')
}
response = requests.post(url, headers=headers, files=files)
print(response.text)package main
import (
"bytes"
"fmt"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.parser.expert/v1/upload"
apiKey := "sk-xxxxxxxx"
filePath := "/path/to/your/file.pdf"
file, err := os.Open(filePath)
if err != nil {
panic(err)
}
defer file.Close()
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, err := writer.CreateFormFile("file", "file.pdf")
if err != nil {
panic(err)
}
_, err = io.Copy(part, file)
if err != nil {
panic(err)
}
_ = writer.WriteField("bucket_id", "100202")
writer.Close()
req, err := http.NewRequest("POST", url, body)
if err != nil {
panic(err)
}
req.Header.Add("X-API-Key", apiKey)
req.Header.Set("Content-Type", writer.FormDataContentType())
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}curl --location --request POST 'https://api.parser.expert/v1/upload' \
--header 'X-API-Key: sk-xxxxxxxx' \
--form 'file=@"/path/to/your/file.pdf"' \
--form 'bucket_id="100202"'import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class UploadFile {
public static void main(String[] args) throws IOException {
String url = "https://api.parser.expert/v1/upload";
String apiKey = "sk-xxxxxxxx";
String boundary = "Boundary-" + System.currentTimeMillis();
String lineEnd = "\r\n";
String twoHyphens = "--";
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("X-API-Key", apiKey);
connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
OutputStream outputStream = connection.getOutputStream();
// File part
outputStream.write((twoHyphens + boundary + lineEnd).getBytes());
outputStream.write("Content-Disposition: form-data; name=\"file\"; filename=\"file.pdf\"".getBytes());
outputStream.write(lineEnd.getBytes());
outputStream.write("Content-Type: application/pdf".getBytes());
outputStream.write(lineEnd.getBytes());
outputStream.write(lineEnd.getBytes());
FileInputStream fileInputStream = new FileInputStream(new File("/path/to/your/file.pdf"));
int bytesRead;
byte[] buffer = new byte[4096];
while ((bytesRead = fileInputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.write(lineEnd.getBytes());
// bucket_id part
outputStream.write((twoHyphens + boundary + lineEnd).getBytes());
outputStream.write("Content-Disposition: form-data; name=\"bucket_id\"".getBytes());
outputStream.write(lineEnd.getBytes());
outputStream.write(lineEnd.getBytes());
outputStream.write("100202".getBytes());
outputStream.write(lineEnd.getBytes());
// End part
outputStream.write((twoHyphens + boundary + twoHyphens + lineEnd).getBytes());
outputStream.flush();
outputStream.close();
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
}
}const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const url = 'https://api.parser.expert/v1/upload';
const apiKey = 'sk-xxxxxxxx';
const filePath = '/path/to/your/file.pdf';
const form = new FormData();
form.append('file', fs.createReadStream(filePath));
form.append('bucket_id', '100202');
axios.post(url, form, {
headers: {
'X-API-Key': apiKey,
...form.getHeaders()
}
}).then(response => {
console.log(response.data);
}).catch(error => {
console.error(error);
});<?php
$apiKey = 'sk-xxxxxxxx';
$filePath = '/path/to/your/file.pdf';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.parser.expert/v1/upload');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$post = array(
'file' => new CURLFile($filePath),
'bucket_id' => '100202'
);
$headers = array(
'X-API-Key: ' . $apiKey
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
echo $response;
?>require 'uri'
require 'net/http'
url = URI("https://api.parser.expert/v1/upload")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"bucket_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webpage_url\"\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"data": {
"parser_id": "f555c13a-846f-4505-95fe-8f72b39edef9"
},
"message": "Extract upserted successfully"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}API Endpoints
/v1/upload
Upload data to the Parser Expert API. You can upload either a file or provide a webpage URL.
POST
/
v1
/
upload
Python
import requests
url = "https://api.parser.expert/v1/upload"
headers = {
'X-API-Key': 'sk-xxxx'
}
files = {
'file': open('/path/to/your/file.pdf', 'rb'),
'bucket_id': (None, '100202')
}
response = requests.post(url, headers=headers, files=files)
print(response.text)package main
import (
"bytes"
"fmt"
"mime/multipart"
"net/http"
"os"
)
func main() {
url := "https://api.parser.expert/v1/upload"
apiKey := "sk-xxxxxxxx"
filePath := "/path/to/your/file.pdf"
file, err := os.Open(filePath)
if err != nil {
panic(err)
}
defer file.Close()
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, err := writer.CreateFormFile("file", "file.pdf")
if err != nil {
panic(err)
}
_, err = io.Copy(part, file)
if err != nil {
panic(err)
}
_ = writer.WriteField("bucket_id", "100202")
writer.Close()
req, err := http.NewRequest("POST", url, body)
if err != nil {
panic(err)
}
req.Header.Add("X-API-Key", apiKey)
req.Header.Set("Content-Type", writer.FormDataContentType())
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}curl --location --request POST 'https://api.parser.expert/v1/upload' \
--header 'X-API-Key: sk-xxxxxxxx' \
--form 'file=@"/path/to/your/file.pdf"' \
--form 'bucket_id="100202"'import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class UploadFile {
public static void main(String[] args) throws IOException {
String url = "https://api.parser.expert/v1/upload";
String apiKey = "sk-xxxxxxxx";
String boundary = "Boundary-" + System.currentTimeMillis();
String lineEnd = "\r\n";
String twoHyphens = "--";
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("X-API-Key", apiKey);
connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
OutputStream outputStream = connection.getOutputStream();
// File part
outputStream.write((twoHyphens + boundary + lineEnd).getBytes());
outputStream.write("Content-Disposition: form-data; name=\"file\"; filename=\"file.pdf\"".getBytes());
outputStream.write(lineEnd.getBytes());
outputStream.write("Content-Type: application/pdf".getBytes());
outputStream.write(lineEnd.getBytes());
outputStream.write(lineEnd.getBytes());
FileInputStream fileInputStream = new FileInputStream(new File("/path/to/your/file.pdf"));
int bytesRead;
byte[] buffer = new byte[4096];
while ((bytesRead = fileInputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.write(lineEnd.getBytes());
// bucket_id part
outputStream.write((twoHyphens + boundary + lineEnd).getBytes());
outputStream.write("Content-Disposition: form-data; name=\"bucket_id\"".getBytes());
outputStream.write(lineEnd.getBytes());
outputStream.write(lineEnd.getBytes());
outputStream.write("100202".getBytes());
outputStream.write(lineEnd.getBytes());
// End part
outputStream.write((twoHyphens + boundary + twoHyphens + lineEnd).getBytes());
outputStream.flush();
outputStream.close();
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
}
}const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const url = 'https://api.parser.expert/v1/upload';
const apiKey = 'sk-xxxxxxxx';
const filePath = '/path/to/your/file.pdf';
const form = new FormData();
form.append('file', fs.createReadStream(filePath));
form.append('bucket_id', '100202');
axios.post(url, form, {
headers: {
'X-API-Key': apiKey,
...form.getHeaders()
}
}).then(response => {
console.log(response.data);
}).catch(error => {
console.error(error);
});<?php
$apiKey = 'sk-xxxxxxxx';
$filePath = '/path/to/your/file.pdf';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.parser.expert/v1/upload');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$post = array(
'file' => new CURLFile($filePath),
'bucket_id' => '100202'
);
$headers = array(
'X-API-Key: ' . $apiKey
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
echo $response;
?>require 'uri'
require 'net/http'
url = URI("https://api.parser.expert/v1/upload")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"bucket_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"webpage_url\"\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"data": {
"parser_id": "f555c13a-846f-4505-95fe-8f72b39edef9"
},
"message": "Extract upserted successfully"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}Authorizations
Body
multipart/form-data
The ID of the bucket where the data will be stored.Refer to Quickstart for set extraction fields
The file to upload. Supported formats are PDF, DOCX, Image, Txt File (maximum of 10 pages per document).
The URL of the webpage to extract content from. This will be ignored if file is provided.
⌘I
