1
Request a presigned URL
Request a presigned URL from the
/upload endpoint.2
Upload the file using the presigned URL
Upload the file using the presigned URL using a PUT request.
3
Parse the file
Parse the file using the
/parse endpoint. Pass the file_id from the response in first step.import requests
upload_form = requests.post("https://platform.reducto.ai/upload",
headers={"Authorization": "Bearer <auth token>"}).json()
requests.put(upload_form["presigned_url"], data=open("./local.pdf", "rb"))
response = requests.post("https://platform.reducto.ai/parse",
json={"input": upload_form["file_id"]},
headers={"Authorization": "Bearer <auth token>"})
const fetch = require("node-fetch");
const fs = require("fs");
const uploadForm = await fetch("https://platform.reducto.ai/upload", {
method: "POST",
headers: {
Authorization: "Bearer <auth token>",
},
}).then((res) => res.json());
await fetch(uploadForm.presigned_url, {
method: "PUT",
body: fs.readFileSync("./local.pdf"),
});
const response = await fetch("https://platform.reducto.ai/parse", {
method: "POST",
headers: {
Authorization:
"Bearer <auth token>",
"Content-Type": "application/json",
},
body: JSON.stringify({ input: uploadForm.file_id }),
}).then((res) => res.json());
#!/bin/bash
# Step 1: Get the presigned URL and file_id for uploading
upload_form=$(curl -s -X POST "https://platform.reducto.ai/upload" -H "Authorization: Bearer $REDUCTO_API_TOKEN")
presigned_url=$(echo $upload_form | jq -r '.presigned_url')
file_id=$(echo $upload_form | jq -r '.file_id')
# Step 2: Upload the file using the presigned URL
curl --request PUT --upload-file local.pdf $presigned_url
echo "File uploaded!"
# Step 3: Send the parse request
response=$(curl -s -X POST "https://platform.api.reducto.ai/parse" \
-H "Authorization: Bearer $REDUCTO_API_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"input\":\"$file_id\"}")
echo $response
import asyncio
import aiohttp
async with aiohttp.ClientSession() as session:
async with session.post(
"https://platform.reducto.ai/upload",
headers={"Authorization": f"Bearer {api_key}"}
) as response:
if response.status != 200:
raise Exception(
f"Reducto upload http request failed - {response.status}"
)
response_data = await response.json()
presigned_url = response_data["presigned_url"]
async with session.put(
presigned_url,
data=power_point_bytes,
headers={'Content-Type': ''}
) as response:
if response.status != 200:
raise Exception(
f"Reducto upload http request failed - {response.status}"
)
async with session.post(
"https://platform.reducto.ai/parse",
json={"input": response_data["file_id"]},
headers={"Authorization": f"Bearer {api_key}"}
) as response:
if response.status != 200:
raise Exception(
f"Reducto parse http request failed - {response.status}"
)
print(await response.json())