Skip to main content

Getting Started

Step by Step

Get your API key

Sign up to get your API key. This is completely free and no credit card is required. The free plan includes 150 conversion calls per month.

The key is required to authenticate your requests to our API.

API request

With your API key, you can start making requests to our API.

The only required parameter for a basic request is the source parameter, which can be a URL, raw HTML, or a template.

{
"source": "https://www.starwars.com/databank/yoda"
}
{
"source": "<html><h1>Hello World</h1></html>"
}
{
"source": "[template:a1b-c2d]"
}

There are many more optional parameters, which are explained in the API reference. That is where you can tailor the output to your needs.

You can use the Playground to test the API and to generate PDFs or screenshots.

Explore all parameters
Try it out
How to use templates

Integration

There are plenty of ways to integrate it into your workflow.

You can either use the REST API directly in your own code, or integrate it in various no-code platforms, such as automation tools or serverless functions. See our many integration guides for more information.

For developers
No-code integrations

Questions

If you have any questions or need help to get started, feel free to contact us.

Code Examples

Each example uses only the options required for a minimal working request: authorization and the content source. For every available parameter, see the API reference.

const axios = require('axios');
const fs = require('fs');

axios.post('https://api.polydoc.tech/pdf/convert', {
source: 'https://www.starwars.com/databank/yoda'
}, {
headers: {
'Authorization': 'Bearer <YOUR API KEY>',
'Content-Type': 'application/json',
'X-Sandbox': 'true'
},
responseType: 'arraybuffer'
})
.then(response => {
fs.writeFileSync('yoda.pdf', response.data);
})
.catch(error => {
console.error(error);
});
import requests

headers = {
'Authorization': 'Bearer <YOUR API KEY>',
'Content-Type': 'application/json',
'X-Sandbox': 'true'
}

data = {
'source': 'https://www.starwars.com/databank/yoda'
}

response = requests.post(
'https://api.polydoc.tech/pdf/convert', headers=headers, json=data
)

with open('yoda.pdf', 'wb') as f:
f.write(response.content)
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://api.polydoc.tech/pdf/convert")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer <YOUR API KEY>"
request["Content-Type"] = "application/json"
request["X-Sandbox"] = "true"
request.body = JSON.dump({
"source" => "https://www.starwars.com/databank/yoda"
})

req_options = {
use_ssl: uri.scheme == "https",
}

response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(request)
end

File.open("yoda.pdf", "wb") do |file|
file.write(response.body)
end
package main

import (
"bytes"
"encoding/json"
"io"
"net/http"
"os"
)

func main() {
url := "https://api.polydoc.tech/pdf/convert"
data := map[string]interface{}{
"source": "https://www.starwars.com/databank/yoda",
}
jsonData, _ := json.Marshal(data)

req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <YOUR API KEY>")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Sandbox", "true")

client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()

body, _ := io.ReadAll(resp.Body)
os.WriteFile("yoda.pdf", body, 0644)
}
<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.polydoc.tech/pdf/convert');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
"source" => "https://www.starwars.com/databank/yoda"
]));

$headers = [
'Authorization: Bearer <YOUR API KEY>',
'Content-Type: application/json',
'X-Sandbox: true'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);

file_put_contents('yoda.pdf', $result);
?>
use reqwest::blocking::Client;
use serde_json::json;
use std::error::Error;
use std::fs::File;
use std::io::Write;

fn main() -> Result<(), Box<dyn Error>> {
let client = Client::new();
let res = client.post("https://api.polydoc.tech/pdf/convert")
.header("Authorization", "Bearer <YOUR API KEY>")
.header("Content-Type", "application/json")
.header("X-Sandbox", "true")
.json(&json!({
"source": "https://www.starwars.com/databank/yoda"
}))
.send()?;

let mut file = File::create("yoda.pdf")?;
file.write_all(&res.bytes()?)?;

Ok(())
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpRequest.BodyPublishers;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;

public class Main {
public static void main(String[] args) {
try {
HttpClient client = HttpClient.newHttpClient();
ObjectMapper objectMapper = new ObjectMapper();
Map <String, Object> requestBody = Map.of(
"source", "https://www.starwars.com/databank/yoda"
);
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI("https://api.polydoc.tech/pdf/convert"))
.header("Authorization", "Bearer <YOUR API KEY>")
.header("Content-Type", "application/json")
.header("X-Sandbox", "true")
.POST(BodyPublishers.ofString(objectMapper.writeValueAsString(requestBody)))
.build();
HttpResponse <byte[]> response = client.send(
request, HttpResponse.BodyHandlers.ofByteArray()
);
if (response.statusCode() == 200) {
Files.write(Paths.get("yoda.pdf"), response.body(), StandardOpenOption.CREATE);
} else {
System.err.println("Error: " + response.statusCode());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;

class Main {
static async Task Main(string[] args) {
using(HttpClient client = new HttpClient()) {
var requestBody = new {
source = "https://www.starwars.com/databank/yoda"
};
var json = JsonConvert.SerializeObject(requestBody);
var content = new StringContent(json, Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
"Bearer", "<YOUR API KEY>"
);
client.DefaultRequestHeaders.Add("X-Sandbox", "true");
HttpResponseMessage response = await client.PostAsync(
"https://api.polydoc.tech/pdf/convert", content
);
if (response.IsSuccessStatusCode) {
byte[] pdfBytes = await response.Content.ReadAsByteArrayAsync();
await File.WriteAllBytesAsync("yoda.pdf", pdfBytes);
} else {
Console.WriteLine("Error: " + response.StatusCode);
}
}
}
}
curl --location \
--request POST 'https://api.polydoc.tech/pdf/convert' \
--header 'Authorization: Bearer <YOUR API KEY>' \
--header 'Content-Type: application/json' \
--header 'X-Sandbox: true' \
--data-raw '{
"source": "https://www.starwars.com/databank/yoda"
}' --output yoda.pdf