Generate PDF from a URL (ephemeral browser)
curl --request POST \
--url https://api.webcompute.dev/v1/pdf \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"proxy": "<string>",
"waitFor": "<string>",
"timeout": 30000,
"policy": {},
"format": "A4",
"landscape": false,
"printBackground": true
}
'import requests
url = "https://api.webcompute.dev/v1/pdf"
payload = {
"url": "<string>",
"proxy": "<string>",
"waitFor": "<string>",
"timeout": 30000,
"policy": {},
"format": "A4",
"landscape": False,
"printBackground": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: '<string>',
proxy: '<string>',
waitFor: '<string>',
timeout: 30000,
policy: {},
format: 'A4',
landscape: false,
printBackground: true
})
};
fetch('https://api.webcompute.dev/v1/pdf', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.webcompute.dev/v1/pdf",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => '<string>',
'proxy' => '<string>',
'waitFor' => '<string>',
'timeout' => 30000,
'policy' => [
],
'format' => 'A4',
'landscape' => false,
'printBackground' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.webcompute.dev/v1/pdf"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"proxy\": \"<string>\",\n \"waitFor\": \"<string>\",\n \"timeout\": 30000,\n \"policy\": {},\n \"format\": \"A4\",\n \"landscape\": false,\n \"printBackground\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.webcompute.dev/v1/pdf")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"proxy\": \"<string>\",\n \"waitFor\": \"<string>\",\n \"timeout\": 30000,\n \"policy\": {},\n \"format\": \"A4\",\n \"landscape\": false,\n \"printBackground\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.webcompute.dev/v1/pdf")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"proxy\": \"<string>\",\n \"waitFor\": \"<string>\",\n \"timeout\": 30000,\n \"policy\": {},\n \"format\": \"A4\",\n \"landscape\": false,\n \"printBackground\": true\n}"
response = http.request(request)
puts response.read_bodyAPI reference
Generate PDF from a URL (ephemeral browser)
POST
/
v1
/
pdf
Generate PDF from a URL (ephemeral browser)
curl --request POST \
--url https://api.webcompute.dev/v1/pdf \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"proxy": "<string>",
"waitFor": "<string>",
"timeout": 30000,
"policy": {},
"format": "A4",
"landscape": false,
"printBackground": true
}
'import requests
url = "https://api.webcompute.dev/v1/pdf"
payload = {
"url": "<string>",
"proxy": "<string>",
"waitFor": "<string>",
"timeout": 30000,
"policy": {},
"format": "A4",
"landscape": False,
"printBackground": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: '<string>',
proxy: '<string>',
waitFor: '<string>',
timeout: 30000,
policy: {},
format: 'A4',
landscape: false,
printBackground: true
})
};
fetch('https://api.webcompute.dev/v1/pdf', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.webcompute.dev/v1/pdf",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => '<string>',
'proxy' => '<string>',
'waitFor' => '<string>',
'timeout' => 30000,
'policy' => [
],
'format' => 'A4',
'landscape' => false,
'printBackground' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.webcompute.dev/v1/pdf"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"proxy\": \"<string>\",\n \"waitFor\": \"<string>\",\n \"timeout\": 30000,\n \"policy\": {},\n \"format\": \"A4\",\n \"landscape\": false,\n \"printBackground\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.webcompute.dev/v1/pdf")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"proxy\": \"<string>\",\n \"waitFor\": \"<string>\",\n \"timeout\": 30000,\n \"policy\": {},\n \"format\": \"A4\",\n \"landscape\": false,\n \"printBackground\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.webcompute.dev/v1/pdf")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"proxy\": \"<string>\",\n \"waitFor\": \"<string>\",\n \"timeout\": 30000,\n \"policy\": {},\n \"format\": \"A4\",\n \"landscape\": false,\n \"printBackground\": true\n}"
response = http.request(request)
puts response.read_bodyAuthorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Target URL to navigate to
Proxy URL (protocol://user:pass@host:port)
CSS selector to wait for before action
Action timeout in milliseconds (1-60000)
Browser navigation policy for this action
Paper size
Available options:
A4, Letter, A3, Tabloid, Ledger, Legal Landscape orientation
Print background graphics
Response
PDF result (base64 in JSON)
⌘I