生成、合并、拆分、OCR 与加水印 PDF。
1. 概览
https://api.infrai.cc/v1/pdfAuthorization: Bearer $INFRAI_API_KEY# Call any /v1/pdf capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/pdf/... \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json"2. 方法 (19)
2.1pdf.generate
从 HTML、URL 或模板生成 PDF。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
html | string | 可选 | 要渲染的 HTML 源。 |
url | string | 可选 | 用于渲染或操作的源 URL。 |
template_id | string | 可选 | 用于渲染的模板 id(替代正文)。 |
format | "A4" | "Letter" | "Legal" | 可选 | 页面尺寸。 |
orientation | "portrait" | "landscape" | 可选 | 页面方向。default: "portrait" |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
PdfResult { pdf_url, bytes, pages }| 名称 | 类型 | 说明 |
|---|---|---|
pdf_id | string | PDF document的唯一标识符pattern: ^pdf_[A-Za-z0-9]{20,}$ |
url | string | 资源或端点 URL |
size_bytes | integer | 资源大小(字节)≥ 0 |
page_count | integer | pages in the document数量≥ 1 |
sha256 | string | 资源内容的 SHA-256 哈希pattern: ^[a-f0-9]{64}$ |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
retention_days | integer | null | days to retain this resource数量≥ 0 |
source | "html" | "markdown" | "template" | "ocr" | "mutate" | "convert" | "compress" | "encrypt" | "redact" | "form" | PDF 来源(upload、url、html) |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/generate \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/generate",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/generate",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/generate",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/generate", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/generate"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/generate");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/generate");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/generate")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/generate")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.2pdf.merge
将多个 PDF 合并为一个。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
urls | string[] | 必填 | 要合并的 PDF URL 列表。 |
返回
PdfResult| 名称 | 类型 | 说明 |
|---|---|---|
pdf_id | string | PDF document的唯一标识符pattern: ^pdf_[A-Za-z0-9]{20,}$ |
url | string | 资源或端点 URL |
size_bytes | integer | 资源大小(字节)≥ 0 |
page_count | integer | pages in the document数量≥ 1 |
sha256 | string | 资源内容的 SHA-256 哈希pattern: ^[a-f0-9]{64}$ |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
retention_days | integer | null | days to retain this resource数量≥ 0 |
source | "html" | "markdown" | "template" | "ocr" | "mutate" | "convert" | "compress" | "encrypt" | "redact" | "form" | PDF 来源(upload、url、html) |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/merge \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"inputs": ["hello"]}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/merge",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'inputs': ['hello']},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/merge",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"inputs": ["hello"]}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/merge",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"inputs": ["hello"]}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"inputs": ["hello"]}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/merge", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/merge"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"inputs\": [\"hello\"]}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/merge");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"inputs\": [\"hello\"]}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/merge");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"inputs\": [\"hello\"]}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/merge")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"inputs": ["hello"]}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/merge")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"inputs": ["hello"]}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.3pdf.split
按页码区间拆分 PDF。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
url | string | 必填 | 用于渲染或操作的源 URL。 |
ranges | string[] | 必填 | 页码区间,例如 1-3。≥ 1 item |
返回
{ parts: PdfResult[] }| 名称 | 类型 | 说明 |
|---|---|---|
pdf_id | string | PDF document的唯一标识符pattern: ^pdf_[A-Za-z0-9]{20,}$ |
url | string | 资源或端点 URL |
size_bytes | integer | 资源大小(字节)≥ 0 |
page_count | integer | pages in the document数量≥ 1 |
sha256 | string | 资源内容的 SHA-256 哈希pattern: ^[a-f0-9]{64}$ |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
retention_days | integer | null | days to retain this resource数量≥ 0 |
source | "html" | "markdown" | "template" | "ocr" | "mutate" | "convert" | "compress" | "encrypt" | "redact" | "form" | PDF 来源(upload、url、html) |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/split \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample", "ranges": [[1]]}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/split",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample', 'ranges': [[1]]},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/split",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample", "ranges": [[1]]}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/split",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample", "ranges": [[1]]}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"pdf": "sample", "ranges": [[1]]}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/split", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/split"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"pdf\": \"sample\", \"ranges\": [[1]]}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/split");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"pdf\": \"sample\", \"ranges\": [[1]]}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/split");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"pdf\": \"sample\", \"ranges\": [[1]]}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/split")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"pdf": "sample", "ranges": [[1]]}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/split")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"pdf": "sample", "ranges": [[1]]}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.4pdf.ocr
通过 OCR 从 PDF 提取文本。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
url | string | 必填 | 用于渲染或操作的源 URL。 |
language | string | 可选 | 语言提示,例如 en 或 zh。 |
返回
{ text, pages: Array<{ text }> }| 名称 | 类型 | 说明 |
|---|---|---|
pdf_id | string | PDF document的唯一标识符pattern: ^pdf_[A-Za-z0-9]{20,}$ |
text_per_page | string[] | 每页提取的文本内容 |
confidence_avg | number | null | OCR 结果的平均置信度分数0–1 |
lang_detected | string | null | 检测到的文档语言 |
duration_ms | integer | 操作耗时(毫秒)≥ 0 |
engine | "chromium" | "unstructured_io" | "aws_textract" | "google_doc_ai" | "paddle_ocr" | 使用的处理引擎(如 tesseract、google-vision) |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/ocr \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/ocr",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/ocr",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/ocr",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"pdf": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/ocr", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/ocr"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"pdf\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/ocr");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"pdf\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/ocr");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"pdf\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/ocr")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"pdf": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/ocr")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"pdf": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.5pdf.watermark
为 PDF 添加文字或图片水印。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
url | string | 必填 | 用于渲染或操作的源 URL。 |
text | string | 可选 | 水印文字。 |
opacity | number | 可选 | 水印不透明度,0 到 1。0–1default: 0.3 |
返回
PdfResult| 名称 | 类型 | 说明 |
|---|---|---|
pdf_id | string | PDF document的唯一标识符pattern: ^pdf_[A-Za-z0-9]{20,}$ |
url | string | 资源或端点 URL |
size_bytes | integer | 资源大小(字节)≥ 0 |
page_count | integer | pages in the document数量≥ 1 |
sha256 | string | 资源内容的 SHA-256 哈希pattern: ^[a-f0-9]{64}$ |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
retention_days | integer | null | days to retain this resource数量≥ 0 |
source | "html" | "markdown" | "template" | "ocr" | "mutate" | "convert" | "compress" | "encrypt" | "redact" | "form" | PDF 来源(upload、url、html) |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/watermark \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/watermark",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/watermark",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/watermark",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"pdf": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/watermark", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/watermark"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"pdf\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/watermark");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"pdf\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/watermark");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"pdf\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/watermark")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"pdf": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/watermark")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"pdf": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.6pdf.compress
压缩 PDF 以减小体积,mode 复用全局 fast/balanced/quality 处理档位;幂等写入,idempotency_key 用于重试去重。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
mode | "fast" | "balanced" | "quality" | 可选 | 压缩力度与保真的权衡,复用全局处理档位(fast/balanced/quality)。default: "balanced" |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
PdfDocument { pdf_id, url, bytes, page_count, source }| 名称 | 类型 | 说明 |
|---|---|---|
pdf_id | string | PDF document的唯一标识符pattern: ^pdf_[A-Za-z0-9]{20,}$ |
url | string | 资源或端点 URL |
size_bytes | integer | 资源大小(字节)≥ 0 |
page_count | integer | pages in the document数量≥ 1 |
sha256 | string | 资源内容的 SHA-256 哈希pattern: ^[a-f0-9]{64}$ |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
retention_days | integer | null | days to retain this resource数量≥ 0 |
source | "html" | "markdown" | "template" | "ocr" | "mutate" | "convert" | "compress" | "encrypt" | "redact" | "form" | PDF 来源(upload、url、html) |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/compress \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/compress",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/compress",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/compress",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"pdf": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/compress", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/compress"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"pdf\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/compress");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"pdf\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/compress");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"pdf\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/compress")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"pdf": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/compress")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"pdf": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.7pdf.convert
将 PDF 转换为其他格式;不支持的目标返回 PDF_CONVERT_UNSUPPORTED(422);多页图片目标返回 PdfDocumentListResult;幂等写入。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
to | "docx" | "xlsx" | "pptx" | "png" | "jpg" | "html" | 必填 | 目标格式(如 docx、png、jpg 等)。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
PdfDocument (multi-page image targets return PdfDocumentListResult)| 名称 | 类型 | 说明 |
|---|---|---|
pdf_id | string | PDF document的唯一标识符pattern: ^pdf_[A-Za-z0-9]{20,}$ |
url | string | 资源或端点 URL |
size_bytes | integer | 资源大小(字节)≥ 0 |
page_count | integer | pages in the document数量≥ 1 |
sha256 | string | 资源内容的 SHA-256 哈希pattern: ^[a-f0-9]{64}$ |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
retention_days | integer | null | days to retain this resource数量≥ 0 |
source | "html" | "markdown" | "template" | "ocr" | "mutate" | "convert" | "compress" | "encrypt" | "redact" | "form" | PDF 来源(upload、url、html) |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/convert \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample", "to": "docx"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/convert",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample', 'to': 'docx'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/convert",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample", "to": "docx"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/convert",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample", "to": "docx"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"pdf": "sample", "to": "docx"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/convert", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/convert"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"pdf\": \"sample\", \"to\": \"docx\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/convert");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"pdf\": \"sample\", \"to\": \"docx\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/convert");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"pdf\": \"sample\", \"to\": \"docx\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/convert")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"pdf": "sample", "to": "docx"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/convert")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"pdf": "sample", "to": "docx"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.8pdf.parse
提取 PDF 文本、大纲与元数据用于 RAG 入库;只读无副作用;加密且未提供密码时返回 PDF_PARSE_PASSWORD_REQUIRED。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
pages | number[] | 可选 | 限定解析的页码(1 起始);省略则解析全部页面。 |
返回
PdfParseResult { text, pages, outline, metadata }| 名称 | 类型 | 说明 |
|---|---|---|
pdf_id | string | PDF document的唯一标识符pattern: ^pdf_[A-Za-z0-9]{20,}$ |
text_per_page | string[] | 每页提取的文本内容 |
outline | object[] | 文档大纲/目录 |
outline[].title | string | - |
outline[].page | integer | - |
metadata | object | null | 附加在此资源上的任意键值元数据 |
language | string | null | 检测到的文本语言 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/parse \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/parse",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/parse",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/parse",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"pdf": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/parse", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/parse"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"pdf\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/parse");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"pdf\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/parse");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"pdf\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/parse")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"pdf": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/parse")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"pdf": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.9pdf.extract_images
提取 PDF 内嵌 XObject 图片并以 data: URI 形式返回;只读无副作用。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
pages | number[] | 可选 | 限定提取图片的页码(1 起始);省略则提取全部页面。 |
返回
PdfExtractImagesResult { images: ExtractedImage[] }| 名称 | 类型 | 说明 |
|---|---|---|
images | object[] | generated or processed images列表 |
images[].page | integer | 页码(从 1 开始)≥ 1 |
images[].image_url | string | 提取图片的 URL |
images[].width | integer | 图片宽度(像素)≥ 1 |
images[].height | integer | 图片高度(像素)≥ 1 |
images[].mime_type | string | null | 资源 MIME 类型 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/extract_images \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/extract_images",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/extract_images",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/extract_images",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"pdf": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/extract_images", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/extract_images"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"pdf\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/extract_images");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"pdf\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/extract_images");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"pdf\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/extract_images")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"pdf": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/extract_images")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"pdf": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.10pdf.form.extract
读取 AcroForm 表单字段名与取值;只读无副作用。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
返回
PdfFormExtractResult { fields }| 名称 | 类型 | 说明 |
|---|---|---|
fields | object[] | 提取的表单字段 |
fields[].name | string | - |
fields[].type | string | AcroForm 字段类型(text、checkbox、radio、choice、signature)。 |
fields[].value | string | boolean | null | - |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/form/extract \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/form/extract",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/form/extract",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/form/extract",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"pdf": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/form/extract", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/form/extract"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"pdf\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/form/extract");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"pdf\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/form/extract");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"pdf\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/form/extract")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"pdf": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/form/extract")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"pdf": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.11pdf.form.fill
填充 AcroForm 表单字段;flatten 压平为不可编辑;幂等写入,idempotency_key 用于重试去重。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
fields | Record<string, string> | 必填 | 字段名到取值的映射,用于填充表单。 |
flatten | boolean | 可选 | 为 true 时将填充值压平,使表单不可再编辑。default: false |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
PdfDocument { pdf_id, url, page_count, source }| 名称 | 类型 | 说明 |
|---|---|---|
pdf_id | string | PDF document的唯一标识符pattern: ^pdf_[A-Za-z0-9]{20,}$ |
url | string | 资源或端点 URL |
size_bytes | integer | 资源大小(字节)≥ 0 |
page_count | integer | pages in the document数量≥ 1 |
sha256 | string | 资源内容的 SHA-256 哈希pattern: ^[a-f0-9]{64}$ |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
retention_days | integer | null | days to retain this resource数量≥ 0 |
source | "html" | "markdown" | "template" | "ocr" | "mutate" | "convert" | "compress" | "encrypt" | "redact" | "form" | PDF 来源(upload、url、html) |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/form/fill \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample", "fields": {}}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/form/fill",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample', 'fields': {}},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/form/fill",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample", "fields": {}}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/form/fill",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample", "fields": {}}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"pdf": "sample", "fields": {}}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/form/fill", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/form/fill"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"pdf\": \"sample\", \"fields\": {}}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/form/fill");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"pdf\": \"sample\", \"fields\": {}}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/form/fill");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"pdf\": \"sample\", \"fields\": {}}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/form/fill")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"pdf": "sample", "fields": {}}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/form/fill")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"pdf": "sample", "fields": {}}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.12pdf.encrypt
为 PDF 应用密码与权限加密;幂等写入,idempotency_key 用于重试去重。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
user_password | string | 可选 | 打开文档所需的用户密码。 |
owner_password | string | 可选 | 用于权限控制的所有者密码。 |
permissions | string[] | 可选 | 允许的操作权限列表(如 print、copy 等)。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
PdfDocument { pdf_id, url, source }| 名称 | 类型 | 说明 |
|---|---|---|
pdf_id | string | PDF document的唯一标识符pattern: ^pdf_[A-Za-z0-9]{20,}$ |
url | string | 资源或端点 URL |
size_bytes | integer | 资源大小(字节)≥ 0 |
page_count | integer | pages in the document数量≥ 1 |
sha256 | string | 资源内容的 SHA-256 哈希pattern: ^[a-f0-9]{64}$ |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
retention_days | integer | null | days to retain this resource数量≥ 0 |
source | "html" | "markdown" | "template" | "ocr" | "mutate" | "convert" | "compress" | "encrypt" | "redact" | "form" | PDF 来源(upload、url、html) |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/encrypt \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/encrypt",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/encrypt",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/encrypt",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"pdf": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/encrypt", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/encrypt"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"pdf\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/encrypt");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"pdf\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/encrypt");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"pdf\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/encrypt")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"pdf": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/encrypt")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"pdf": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.13pdf.decrypt
去除 PDF 密码保护;缺密码返回 PDF_PARSE_PASSWORD_REQUIRED(401),密码错误返回 PDF_DECRYPT_FAILED(403);幂等写入。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
password | string | 必填 | 用于解密文档的密码。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
PdfDocument { pdf_id, url, source }| 名称 | 类型 | 说明 |
|---|---|---|
pdf_id | string | PDF document的唯一标识符pattern: ^pdf_[A-Za-z0-9]{20,}$ |
url | string | 资源或端点 URL |
size_bytes | integer | 资源大小(字节)≥ 0 |
page_count | integer | pages in the document数量≥ 1 |
sha256 | string | 资源内容的 SHA-256 哈希pattern: ^[a-f0-9]{64}$ |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
retention_days | integer | null | days to retain this resource数量≥ 0 |
source | "html" | "markdown" | "template" | "ocr" | "mutate" | "convert" | "compress" | "encrypt" | "redact" | "form" | PDF 来源(upload、url、html) |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/decrypt \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample", "password": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/decrypt",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample', 'password': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/decrypt",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample", "password": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/decrypt",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample", "password": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"pdf": "sample", "password": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/decrypt", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/decrypt"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"pdf\": \"sample\", \"password\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/decrypt");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"pdf\": \"sample\", \"password\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/decrypt");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"pdf\": \"sample\", \"password\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/decrypt")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"pdf": "sample", "password": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/decrypt")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"pdf": "sample", "password": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.14pdf.rotate
旋转指定页面;角度不在 {0,90,180,270} 或页码越界均返回 PDF_TEMPLATE_INVALID;幂等写入。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
degrees | 0 | 90 | 180 | 270 | 可选 | 旋转角度,取值 0、90、180 或 270。default: 90 |
pages | number[] | 可选 | 限定旋转的页码(1 起始);省略则旋转全部页面。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
PdfDocument { pdf_id, url, source }| 名称 | 类型 | 说明 |
|---|---|---|
pdf_id | string | PDF document的唯一标识符pattern: ^pdf_[A-Za-z0-9]{20,}$ |
url | string | 资源或端点 URL |
size_bytes | integer | 资源大小(字节)≥ 0 |
page_count | integer | pages in the document数量≥ 1 |
sha256 | string | 资源内容的 SHA-256 哈希pattern: ^[a-f0-9]{64}$ |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
retention_days | integer | null | days to retain this resource数量≥ 0 |
source | "html" | "markdown" | "template" | "ocr" | "mutate" | "convert" | "compress" | "encrypt" | "redact" | "form" | PDF 来源(upload、url、html) |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/rotate \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/rotate",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/rotate",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/rotate",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"pdf": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/rotate", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/rotate"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"pdf\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/rotate");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"pdf\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/rotate");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"pdf\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/rotate")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"pdf": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/rotate")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"pdf": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.15pdf.redact
按区域或正则模式不可逆地涂黑内容;幂等写入,idempotency_key 用于重试去重。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
regions | Array<{ page; x; y; width; height }> | 可选 | 需涂黑的矩形区域列表(含页码与坐标尺寸)。 |
patterns | string[] | 可选 | 用于匹配并涂黑敏感内容的正则模式列表。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
PdfDocument { pdf_id, url, source }| 名称 | 类型 | 说明 |
|---|---|---|
pdf_id | string | PDF document的唯一标识符pattern: ^pdf_[A-Za-z0-9]{20,}$ |
url | string | 资源或端点 URL |
size_bytes | integer | 资源大小(字节)≥ 0 |
page_count | integer | pages in the document数量≥ 1 |
sha256 | string | 资源内容的 SHA-256 哈希pattern: ^[a-f0-9]{64}$ |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
retention_days | integer | null | days to retain this resource数量≥ 0 |
source | "html" | "markdown" | "template" | "ocr" | "mutate" | "convert" | "compress" | "encrypt" | "redact" | "form" | PDF 来源(upload、url、html) |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/redact \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/redact",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/redact",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/redact",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"pdf": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/redact", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/redact"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"pdf\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/redact");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"pdf\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/redact");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"pdf\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/redact")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"pdf": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/redact")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"pdf": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.16pdf.sign
为 PDF 应用 PKCS#7 / PAdES 数字签名;证书/私钥 PEM 头无效返回 PDF_SIGN_CERT_INVALID;幂等写入。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
cert_pem | string | 必填 | 签名证书的 PEM 文本(须含有效 PEM 头)。 |
key_pem | string | 必填 | 签名私钥的 PEM 文本(须含有效 PEM 头)。 |
reason | string | 可选 | 签名原因(可选,写入签名元数据)。 |
location | string | 可选 | 签名地点(可选,写入签名元数据)。 |
retention_days | number | 可选 | 签名产物的保留天数(可选)。≥ 0 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
SignedPdfDocument { pdf_id, url, signed_at, signer }| 名称 | 类型 | 说明 |
|---|---|---|
pdf_id | string | PDF document的唯一标识符pattern: ^pdf_[A-Za-z0-9]{20,}$ |
url | string | 资源或端点 URL |
size_bytes | integer | 资源大小(字节)≥ 0 |
page_count | integer | pages in the document数量≥ 1 |
sha256 | string | 资源内容的 SHA-256 哈希pattern: ^[a-f0-9]{64}$ |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
retention_days | integer | null | days to retain this resource数量≥ 0 |
signed | boolean | PDF 是否已数字签名 |
signer_common_name | string | 从签名证书提取的 CN(通用名)。 |
signed_at | string | PDF 签名时间(ISO 8601)format: date-time |
reason | string | null | 当前状态或操作原因 |
location | string | null | PDF 签名地点 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/sign \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample", "cert_pem": "sample", "key_pem": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/sign",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample', 'cert_pem': 'sample', 'key_pem': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/sign",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample", "cert_pem": "sample", "key_pem": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/sign",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample", "cert_pem": "sample", "key_pem": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"pdf": "sample", "cert_pem": "sample", "key_pem": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/sign", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/sign"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"pdf\": \"sample\", \"cert_pem\": \"sample\", \"key_pem\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/sign");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"pdf\": \"sample\", \"cert_pem\": \"sample\", \"key_pem\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/sign");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"pdf\": \"sample\", \"cert_pem\": \"sample\", \"key_pem\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/sign")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"pdf": "sample", "cert_pem": "sample", "key_pem": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/sign")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"pdf": "sample", "cert_pem": "sample", "key_pem": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.17pdf.verify
根据证书校验已签名 PDF 的签名有效性;只读无副作用;cert_pem 必填。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
signed_pdf | string | 必填 | 已签名的 PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
cert_pem | string | 必填 | 用于校验签名的证书 PEM 文本。 |
返回
SignatureVerification { valid, signer, signed_at }| 名称 | 类型 | 说明 |
|---|---|---|
valid | boolean | 仅当每个签名均经 cert_pem 验证且文档完整时为 true。 |
signatures | object[] | 数字签名验证结果 |
signatures[].signer_common_name | string | - |
signatures[].valid | boolean | 签名密码学验证有效。 |
signatures[].intact | boolean | 自此签名后文档未被修改。 |
signatures[].signed_at | string | null | -format: date-time |
signatures[].reason | string | null | - |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/verify \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"signed_pdf": "sample", "cert_pem": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/verify",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'signed_pdf': 'sample', 'cert_pem': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/verify",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"signed_pdf": "sample", "cert_pem": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/verify",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"signed_pdf": "sample", "cert_pem": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"signed_pdf": "sample", "cert_pem": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/verify", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/verify"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"signed_pdf\": \"sample\", \"cert_pem\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/verify");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"signed_pdf\": \"sample\", \"cert_pem\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/verify");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"signed_pdf\": \"sample\", \"cert_pem\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/verify")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"signed_pdf": "sample", "cert_pem": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/verify")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"signed_pdf": "sample", "cert_pem": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.18pdf.job.get
按 job_id 查询异步 PDF 作业的状态与结果。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
job_id | string | 必填 | 异步 PDF 作业标识符。 |
返回
PdfJob { job_id, status, result, error }| 名称 | 类型 | 说明 |
|---|---|---|
job_id | string | async job的唯一标识符 |
status | "queued" | "running" | "completed" | "failed" | 当前资源状态 |
result | object | null | status="completed" 时填充(PdfDocument 或 PdfDocumentListResult)。 |
error | string | null | status="failed" 时填充。 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/pdf/job/get/JOB_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/pdf/job/get/JOB_ID",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/job/get/JOB_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/job/get/JOB_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.infrai.cc/v1/pdf/job/get/JOB_ID", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/job/get/JOB_ID"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("GET"), "https://api.infrai.cc/v1/pdf/job/get/JOB_ID");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/job/get/JOB_ID");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/job/get/JOB_ID")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.get("https://api.infrai.cc/v1/pdf/job/get/JOB_ID")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.19pdf.template.create
创建可复用的 HTML PDF 模板;幂等写入,idempotency_key 用于重试去重。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | string | 必填 | 模板名称。 |
html | string | 必填 | 模板的 HTML 内容,可含变量占位符。 |
vars_schema | object | 可选 | 模板变量的 JSON Schema(可选),用于校验渲染入参。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
PdfTemplate { template_id, name, created_at }| 名称 | 类型 | 说明 |
|---|---|---|
template_id | string | 用于渲染的模板标识符 |
name | string | 资源的可读名称 |
html | string | 邮件的 HTML 正文 |
vars_schema | object | null | 描述所需模板变量的 JSON Schema。 |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/pdf/template/create \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "example", "html": "<h1>Hello from infrai</h1>"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/template/create",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'name': 'example', 'html': '<h1>Hello from infrai</h1>'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/template/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"name": "example", "html": "<h1>Hello from infrai</h1>"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/template/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"name": "example", "html": "<h1>Hello from infrai</h1>"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"name": "example", "html": "<h1>Hello from infrai</h1>"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/pdf/template/create", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/pdf/template/create"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"name\": \"example\", \"html\": \"<h1>Hello from infrai</h1>\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/pdf/template/create");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"name\": \"example\", \"html\": \"<h1>Hello from infrai</h1>\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/pdf/template/create");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"name\": \"example\", \"html\": \"<h1>Hello from infrai</h1>\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/pdf/template/create")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"name": "example", "html": "<h1>Hello from infrai</h1>"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/pdf/template/create")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"name": "example", "html": "<h1>Hello from infrai</h1>"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}3. 全部能力
本模块全部已路由能力——完整的对外 REST 契约。上方方法是带讲解的入门示例,此表是完整参考。
pdf.compressPOST /v1/pdf/compressCompress a PDF to reduce file size, using the global fast/balanced/quality processing mode; idempotent write.
参数 (4)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF input: URL, base64 data, or stored pdf_id. |
mode | "fast" | "balanced" | "quality" | 可选 | Compression effort vs fidelity; reuses the global processing mode axis.default: "balanced" |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
store | boolean | 可选 | Opt in to RETAIN the produced PDF in Infrai's own store (default false = stateless passthrough: produce, return inline, keep nothing). When true, Infrai persists the document, bills a self-hosted storage line item and applies a retention TTL — and only then do pdf.list/get/delete see it.default: false |
pdf.convertPOST /v1/pdf/convertConvert a PDF to another format; unsupported targets return PDF_CONVERT_UNSUPPORTED (422); idempotent write.
参数 (4)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF input: URL, base64 data, or stored pdf_id. |
to | "docx" | "xlsx" | "pptx" | "png" | "jpg" | "html" | 必填 | Target format. (SSOT: enums/PdfConvertTarget) |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
store | boolean | 可选 | Opt in to RETAIN the produced PDF in Infrai's own store (default false = stateless passthrough: produce, return inline, keep nothing). When true, Infrai persists the document, bills a self-hosted storage line item and applies a retention TTL — and only then do pdf.list/get/delete see it.default: false |
pdf.decryptPOST /v1/pdf/decryptRemove password protection from a PDF; wrong password returns PDF_DECRYPT_FAILED (403); idempotent write.
参数 (4)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF input: URL, base64 data, or stored pdf_id. |
password | string | 必填 | Password to decrypt the document. |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
store | boolean | 可选 | Opt in to RETAIN the produced PDF in Infrai's own store (default false = stateless passthrough: produce, return inline, keep nothing). When true, Infrai persists the document, bills a self-hosted storage line item and applies a retention TTL — and only then do pdf.list/get/delete see it.default: false |
pdf.encryptPOST /v1/pdf/encryptEncrypt a PDF with a password and permission flags; idempotent write.
参数 (6)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF input: URL, base64 data, or stored pdf_id. |
user_password | string | null | 可选 | Password required to open the document. |
owner_password | string | null | 可选 | Password required to change permissions. |
permissions | string[] | null | 可选 | Allowed actions (e.g. print, copy, modify). |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
store | boolean | 可选 | Opt in to RETAIN the produced PDF in Infrai's own store (default false = stateless passthrough: produce, return inline, keep nothing). When true, Infrai persists the document, bills a self-hosted storage line item and applies a retention TTL — and only then do pdf.list/get/delete see it.default: false |
pdf.extract_imagesPOST /v1/pdf/extract_imagesExtract embedded images from a PDF, returned as data: URIs; read-only, no side effects.
参数 (2)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF input: URL, base64 data, or stored pdf_id. |
pages | integer[] | null | 可选 | 1-indexed pages to scan; null = all pages. |
pdf.form.extractPOST /v1/pdf/form/extractRead AcroForm field names and values from a PDF; read-only, no side effects.
参数 (1)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF input: URL, base64 data, or stored pdf_id. |
pdf.form.fillPOST /v1/pdf/form/fillFill AcroForm fields, optionally flattening to a non-editable PDF; idempotent write.
参数 (5)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF input: URL, base64 data, or stored pdf_id. |
fields | object | 必填 | Map of AcroForm field name -> value. |
flatten | boolean | 可选 | If true, flatten fields so they are no longer editable.default: false |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
store | boolean | 可选 | Opt in to RETAIN the produced PDF in Infrai's own store (default false = stateless passthrough: produce, return inline, keep nothing). When true, Infrai persists the document, bills a self-hosted storage line item and applies a retention TTL — and only then do pdf.list/get/delete see it.default: false |
pdf.generatePOST /v1/pdf/generateGenerate a PDF from HTML, Markdown, inline template, or a stored template rendered with variables; idempotent write.
参数 (10)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
html | string | null | 可选 | Inline HTML source. |
markdown | string | null | 可选 | Inline Markdown source. |
template_html | string | null | 可选 | Inline HTML template rendered with template_vars. |
template_id | string | null | 可选 | Stored template id; server loads its HTML and renders with `vars` (source='template'). |
template_vars | object | null | 可选 | Variables for template_html. |
vars | object | null | 可选 | Variables for template_id rendering. |
page_size | "A4" | "A3" | "A5" | "Letter" | "Legal" | "Tabloid" | 可选 | Page size (e.g. A4, Letter) |
orientation | "portrait" | "landscape" | 可选 | Page orientation (portrait, landscape)default: "portrait" |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
store | boolean | 可选 | Opt in to RETAIN the produced PDF in Infrai's own store (default false = stateless passthrough: produce, return inline, keep nothing). When true, Infrai persists the document, bills a self-hosted storage line item and applies a retention TTL — and only then do pdf.list/get/delete see it.default: false |
pdf.job.getGET /v1/pdf/job/get/{job_id}Get the status and result of an asynchronous PDF job by job_id.
参数 (1)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
job_id | string | 必填 | Path parameter. |
pdf.mergePOST /v1/pdf/mergeConcatenate multiple PDFs in order into a single document; idempotent write.
参数 (3)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
inputs | string[] | 必填 | Ordered list of PDF inputs (URL, base64, or stored pdf_id).≥ 1 item |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
store | boolean | 可选 | Opt in to RETAIN the produced PDF in Infrai's own store (default false = stateless passthrough: produce, return inline, keep nothing). When true, Infrai persists the document, bills a self-hosted storage line item and applies a retention TTL — and only then do pdf.list/get/delete see it.default: false |
pdf.ocrPOST /v1/pdf/ocrRun OCR on a scanned PDF; unsupported language returns PDF_OCR_LANG_UNSUPPORTED (400); idempotent write.
参数 (4)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF input: URL, base64 data, or stored pdf_id. |
lang | string | 可选 | OCR language code.default: "eng" |
quality | "fast" | "balanced" | "quality" | 可选 | OCR effort vs accuracy; reuses the global processing mode axis.default: "fast" |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
pdf.parsePOST /v1/pdf/parseExtract text, outline, and metadata from a PDF for RAG ingestion; read-only, no side effects.
参数 (2)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF input: URL, base64 data, or stored pdf_id. |
pages | integer[] | null | 可选 | 1-indexed pages to parse; null = all pages. |
pdf.redactPOST /v1/pdf/redactIrreversibly black out content by region or regex pattern; idempotent write.
参数 (5)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF input: URL, base64 data, or stored pdf_id. |
regions | object[] | null | 可选 | Explicit rectangular regions to redact. |
patterns | string[] | null | 可选 | Regex patterns; matched text is redacted. |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
store | boolean | 可选 | Opt in to RETAIN the produced PDF in Infrai's own store (default false = stateless passthrough: produce, return inline, keep nothing). When true, Infrai persists the document, bills a self-hosted storage line item and applies a retention TTL — and only then do pdf.list/get/delete see it.default: false |
pdf.rotatePOST /v1/pdf/rotateRotate specified pages by 0, 90, 180, or 270 degrees; idempotent write.
参数 (5)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF input: URL, base64 data, or stored pdf_id. |
degrees | 0 | 90 | 180 | 270 | 可选 | Rotation angle in degreesdefault: 90 |
pages | integer[] | null | 可选 | 1-indexed pages to rotate; null = all pages. |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
store | boolean | 可选 | Opt in to RETAIN the produced PDF in Infrai's own store (default false = stateless passthrough: produce, return inline, keep nothing). When true, Infrai persists the document, bills a self-hosted storage line item and applies a retention TTL — and only then do pdf.list/get/delete see it.default: false |
pdf.signPOST /v1/pdf/signApply a PKCS#7 / PAdES digital signature to a PDF; invalid certificate returns PDF_SIGN_CERT_INVALID; idempotent write.
参数 (8)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF input: URL, base64 data, or stored pdf_id. |
cert_pem | string | 必填 | Signing certificate, PEM-encoded. |
key_pem | string | 必填 | Private key, PEM-encoded. |
reason | string | null | 可选 | Reason for the current state or action |
location | string | null | 可选 | Location where the PDF was signed |
retention_days | integer | null | 可选 | Number of days to retain this resource≥ 0 |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
store | boolean | 可选 | Opt in to RETAIN the produced PDF in Infrai's own store (default false = stateless passthrough: produce, return inline, keep nothing). When true, Infrai persists the document, bills a self-hosted storage line item and applies a retention TTL — and only then do pdf.list/get/delete see it.default: false |
pdf.splitPOST /v1/pdf/splitSplit a PDF into multiple documents by 1-indexed inclusive page ranges; idempotent write.
参数 (4)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
ranges | integer[][] | 必填 | List of [start,end] page ranges, 1-indexed inclusive.≥ 1 item |
pdf | string | 必填 | PDF input: URL, base64 data, or stored pdf_id. |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
store | boolean | 可选 | Opt in to RETAIN the produced PDF in Infrai's own store (default false = stateless passthrough: produce, return inline, keep nothing). When true, Infrai persists the document, bills a self-hosted storage line item and applies a retention TTL — and only then do pdf.list/get/delete see it.default: false |
pdf.template.createPOST /v1/pdf/template/createCreate a reusable HTML PDF template; idempotent write.
参数 (4)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | string | 必填 | Human-readable name for this resource |
html | string | 必填 | Template HTML with double-brace var placeholders. |
vars_schema | object | null | 可选 | JSON-Schema describing required template variables. |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
pdf.verifyPOST /v1/pdf/verifyVerify a signed PDF's signature validity against a certificate; read-only, no side effects.
参数 (2)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
signed_pdf | string | 必填 | Signed PDF input: URL, base64 data, or stored pdf_id. |
cert_pem | string | 必填 | Certificate to verify against, PEM-encoded. |
pdf.watermarkPOST /v1/pdf/watermarkStamp a text and/or image watermark onto a PDF; idempotent write.
参数 (7)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
pdf | string | 必填 | PDF input: URL, base64 data, or stored pdf_id. |
text | string | null | 可选 | Text watermark; one of text/image required. |
image | string | null | 可选 | Image watermark input (URL/base64); one of text/image required. |
opacity | number | 可选 | Watermark opacity (0.0 to 1.0)0–1default: 0.3 |
position | "center" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | 可选 | Position for the watermark (e.g. top-left, center)default: "center" |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
store | boolean | 可选 | Opt in to RETAIN the produced PDF in Infrai's own store (default false = stateless passthrough: produce, return inline, keep nothing). When true, Infrai persists the document, bills a self-hosted storage line item and applies a retention TTL — and only then do pdf.list/get/delete see it.default: false |
4. 完整示例
本模块的生产级端到端范例:先一次性配置,再运行业务流程,尽量覆盖本模块的多数 API。
单文件可运行 Python 程序(仅标准库、无 SDK):拷贝后填入 INFRAI_API_KEY 运行,即可按真实业务流逐步体验本模块核心 API——每一步都真实调用并计费,后续步骤复用前一步返回的真实字段。12 行 helper 就是全部集成代码。
#!/usr/bin/env python3
"""Infrai · pdf — runnable real-app example (single file, zero deps).
Copy this file, set your key, run it: every step is a REAL call to
api.infrai.cc, billed at the real (tiny) per-call price, printing the
live JSON response. Get a key at https://infrai.cc/login (Google/
GitHub sign-in grants $2 free credit); add funds at
https://infrai.cc/billing. No SDK — the 12-line helper below is the
entire integration."""
import json
import os
from urllib import error, request
KEY = os.environ.get("INFRAI_API_KEY") or "ifr_..." # <- your key
BASE = "https://api.infrai.cc"
# Same raw HTTPS POST/GET as every per-method example on this page —
# wrapped once for reuse. There is nothing else to it: no SDK.
def infrai(method, path, body=None):
req = request.Request(
BASE + path, method=method,
data=json.dumps(body).encode() if body is not None else None,
headers={"Authorization": f"Bearer {KEY}",
"Content-Type": "application/json"})
try:
with request.urlopen(req, timeout=60) as r:
return json.loads(r.read())
except error.HTTPError as e:
return json.loads(e.read())
def show(label, resp):
print(f"\n== {label} ==")
print(json.dumps(resp, indent=2, ensure_ascii=False))
return resp
# 1) pdf.generate — POST /v1/pdf/generate · Generate a PDF from HTML, Markdown, inline template, or a stored template rendered with variables; idempotent write. # NOTE: non-trivial real cost
r1 = show("pdf.generate", infrai("POST", "/v1/pdf/generate", {"html":"<h1>Invoice #42</h1>","page_size":"A4","orientation":"portrait"}))
# 2) pdf.merge — POST /v1/pdf/merge · Concatenate multiple PDFs in order into a single document; idempotent write.
r2 = show("pdf.merge", infrai("POST", "/v1/pdf/merge", {"inputs":["hello"]}))
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."# 1) Auth: every call is a raw HTTPS request to the Infrai gateway carrying
# only your project key. No SDK, no install.
# Get your key: sign in with Google/GitHub at https://infrai.cc/login for a
# project key + $2 free credit (email sign-in starts at $0). On 402
# INSUFFICIENT_CREDIT, add funds at https://infrai.cc/billing (or POST
# /v1/account/topup and open the returned checkout_url).
export INFRAI_API_KEY="ifr_..." # from https://infrai.cc/login
# 2) pdf.generate
curl -X POST https://api.infrai.cc/v1/pdf/generate \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Invoice #42</h1>", "page_size": "A4", "orientation": "portrait"}'
# 3) pdf.merge
curl -X POST https://api.infrai.cc/v1/pdf/merge \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"inputs": ["hello"]}'
# 4) pdf.split
curl -X POST https://api.infrai.cc/v1/pdf/split \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample", "ranges": [[1]]}'
# 5) pdf.ocr
curl -X POST https://api.infrai.cc/v1/pdf/ocr \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/scan.pdf", "lang": "auto", "quality": "accurate"}'
# 6) pdf.watermark
curl -X POST https://api.infrai.cc/v1/pdf/watermark \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample"}'
# 7) pdf.compress
curl -X POST https://api.infrai.cc/v1/pdf/compress \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample"}'
# 8) pdf.convert
curl -X POST https://api.infrai.cc/v1/pdf/convert \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample", "to": "docx"}'
# 9) pdf.parse
curl -X POST https://api.infrai.cc/v1/pdf/parse \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pdf": "sample"}'
# 1) Auth: every call is a raw HTTPS request carrying only your project key.
# No SDK to install — just the `requests` library.
import os, requests
BASE = "https://api.infrai.cc"
HEADERS = {
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
"Content-Type": "application/json",
}
# 2) pdf.generate
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/generate",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'html': '<h1>Invoice #42</h1>', 'page_size': 'A4', 'orientation': 'portrait'},
)
resp.raise_for_status()
print(resp.json())
# 3) pdf.merge
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/merge",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'inputs': ['hello']},
)
resp.raise_for_status()
print(resp.json())
# 4) pdf.split
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/split",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample', 'ranges': [[1]]},
)
resp.raise_for_status()
print(resp.json())
# 5) pdf.ocr
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/ocr",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'url': 'https://example.com/scan.pdf', 'lang': 'auto', 'quality': 'accurate'},
)
resp.raise_for_status()
print(resp.json())
# 6) pdf.watermark
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/watermark",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample'},
)
resp.raise_for_status()
print(resp.json())
# 7) pdf.compress
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/compress",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample'},
)
resp.raise_for_status()
print(resp.json())
# 8) pdf.convert
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/convert",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample', 'to': 'docx'},
)
resp.raise_for_status()
print(resp.json())
# 9) pdf.parse
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/pdf/parse",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'pdf': 'sample'},
)
resp.raise_for_status()
print(resp.json())
// 1) Auth: every call is a raw HTTPS request carrying only your project key.
// No SDK to install — just the built-in fetch().
const BASE = "https://api.infrai.cc";
const HEADERS = {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
};
// 2) pdf.generate
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/generate",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"html": "<h1>Invoice #42</h1>", "page_size": "A4", "orientation": "portrait"}),
},
);
console.log(await resp.json());
// 3) pdf.merge
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/merge",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"inputs": ["hello"]}),
},
);
console.log(await resp.json());
// 4) pdf.split
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/split",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample", "ranges": [[1]]}),
},
);
console.log(await resp.json());
// 5) pdf.ocr
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/ocr",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"url": "https://example.com/scan.pdf", "lang": "auto", "quality": "accurate"}),
},
);
console.log(await resp.json());
// 6) pdf.watermark
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/watermark",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
console.log(await resp.json());
// 7) pdf.compress
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/compress",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
console.log(await resp.json());
// 8) pdf.convert
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/convert",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample", "to": "docx"}),
},
);
console.log(await resp.json());
// 9) pdf.parse
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/parse",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
console.log(await resp.json());
// 1) Auth: every call is a raw HTTPS request carrying only your project key.
// No SDK to install — just the built-in fetch(), typed.
const BASE = "https://api.infrai.cc";
const HEADERS: Record<string, string> = {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
};
// 2) pdf.generate
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/generate",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"html": "<h1>Invoice #42</h1>", "page_size": "A4", "orientation": "portrait"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 3) pdf.merge
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/merge",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"inputs": ["hello"]}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 4) pdf.split
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/split",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample", "ranges": [[1]]}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 5) pdf.ocr
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/ocr",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"url": "https://example.com/scan.pdf", "lang": "auto", "quality": "accurate"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 6) pdf.watermark
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/watermark",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 7) pdf.compress
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/compress",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 8) pdf.convert
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/convert",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample", "to": "docx"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 9) pdf.parse
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/pdf/parse",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"pdf": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);