Introduction

Overview

Welcome to the urltodoc documentation. These pages cover everything you need to start using the API: converting website links and raw HTML into formatted PDFs and images.

Use the navigation to jump to a section, or read straight through.


Getting started

To start using the API, create an account. Once your account exists you will land on the dashboard, where you can reveal your API key with the Show key button. That key authenticates your calls.

New accounts include 100 free conversion credits, no card required. One credit is spent per successful conversion, regardless of the options you set, and you will be emailed when you run low. Buy more from the billing page in your dashboard.


Usage

Authentication

Once you have your key, authenticate each request in one of two ways:

  • Set the x-api-key header to your key, or
  • Include a key parameter in the request body or query string.

Basic usage

Requests can be made with POST or GET. The call below is about as simple as it gets: it converts google.com and, because store is set, returns a hosted URL to the generated PDF.

curl "https://urltodoc.com/api/convert?url=https://google.com&key=YOUR_API_KEY&store=true"

Code examples

The same conversion in a few common languages.

JavaScript

import axios from 'axios';

const { data } = await axios.post('https://urltodoc.com/api/convert', {
  key: 'YOUR_API_KEY',
  url: 'https://google.com',
  store: true,
  images: false,
  margins: '1,3',
});

console.log(data); // URL of the generated PDF

PHP

use GuzzleHttp\Client;

$client = new Client();

$response = $client->post('https://urltodoc.com/api/convert', [
    'json' => [
        'key'     => 'YOUR_API_KEY',
        'url'     => 'https://google.com',
        'store'   => true,
        'images'  => false,
        'margins' => '1,3',
    ],
]);

$pdfUrl = (string) $response->getBody();

Python

import requests

response = requests.post('https://urltodoc.com/api/convert', json={
    'key': 'YOUR_API_KEY',
    'url': 'https://google.com',
    'store': True,
    'images': False,
    'margins': '1,3',
})

pdf_url = response.text

Support

Questions about the API or the platform? Email us at contact@urltodoc.com and we will get back to you.