MakeMyPDF

MakeMyPDF API Documentation

Introduction

Welcome to the guide for the MakeMYPDF API. This is a documentation of all the steps, guidelines and details you need to use the API.

The examples given will be in Node.js, cURL, Python, PHP, Ruby, and C#

Authentication

Developers send their API keys with each request in order for our service to authenticate their accounts. You can manage your API keys from your dashboard.

Requests made without an API key will be more rate-limited and will also have the MakeMyPDF watermark. This is useful for testing our API. Note that requests without an API key will also be slower, as such developers are better served using the API key for more long-term use.

Send your API key via the HTTP Header X-API-Key with each request.

Using Your API Key
fetch('https://makemypdf.org/api/pdf/generate', {
  method: 'POST',
  headers: {
    'X-API-Key': 'your_api_key',
    ...
  },
})
...

Testing/Sandbox

We have a sandbox parameter which we set to true by default when you start using the service.

The sandbox parameter adds a watermark to generated PDFs. PDFs with the watermark do not count as conversions and do not use up your credits.

This setup ensures you can try out and run tests without worrying about using up your credits.

Once you are done, you can then remove the sandbox parameter or set it to false which removes the watermark.

Using the sandbox parameter
fetch('https://makemypdf.org/api/pdf/generate', {
  method: 'POST',
  body: {
    sandbox: true
    ...
  }
})
...

Rate Limiting

We implement rate limiting for requests without an API key. The limit is 3 requests per minute.

Once you create an account and start using your API key with each request, you can make up to 300 requests per minute.

After the limit is reached, further requests will return a response with HTTP status code 429 (Too Many Requests)

Please note that we restrict use of testing/sandbox requests to 10 requests per minute.

When you make requests, our responses will contain these headers which let you know your current usage:

HEADERPURPOSE
X-RateLimit-LimitMax number of requests allowed per minute
X-RateLimit-RemainingNumber of requests left before reaching the limit
X-RateLimit-ResetTimestamp for when the limit resets
Rate Limit Headers In Every Response
/ Each response will contain these 3 rate limit headers:

/ X-RateLimit-Limit: 300
/ X-RateLimit-Remaining: 70
/ X-RateLimit-Reset: 1466636890

Errors

The following is a list of the HTTP status codes denoting the different kinds of errors you might encounter using our API.

If you encounter anything outside of these expected errors, please feel free to let us know.

We communicate error information by providing the following properties, in combination with the HTTP status codes:

  • fieldErrors  object
    This specifies the different properties that caused validation error(s) on input:
    • [fieldName]  array of strings
      Each property consists of an array of the different errors relevant to that property.
  • formError  array of strings
    Provides information on server errors, bad request errors, timeout errors, authentication errors and other more 'general' errors that are not directly linked to any specific property.

The MakeMyPDF API uses the following error codes:

  • 400 - Bad Request
    Request is incorrect, could be incorrectly set parameters or wrong format
  • 403 - Forbidden
    Provided API key is invalid/expired or you're trying to access a resource you don't own
  • 404 - Not Found
    The page or resource you are trying to access was not found
  • 405 - Method Not Allowed
    Endpoint isn't accessible with the used method
  • 408 - Request Timeout
    The request timed out before it could be completed.
  • 429 - Too Many Requests
    You sent too many requests. See the Rate Limiting for more information
  • 500 - Internal Server Error
    Something went wrong on our servers - we promptly attend to these errors

Customer Support

If you need any assistance converting your documents or with anything else, please feel free to reach out to us. We work hard to provide assistance quickly.

Our support team is available at [email protected]

Convert an HTML document to PDF

Converting documents starts by making a POST request to our /api/pdf/generate endpoint.

Provide your API key via the X-API-Key header. The body of the request should be comprised of the following:

Please note that we restrict use of testing/sandbox requests to 10 requests per minute.

When you make requests, our responses will contain these headers which let you know your current usage:

  • input  required  object
    This specifies the document to convert. The object contains the following child parameters:
    • type  required  "url" or "html"
      This specifies whether the provided input is a URL to load or an HTML document.
    • source  required  string
      This is the actual url/html depending on the type specified above
  • sandbox  boolean
    If set to true, the provided document will be converted in a test environment and the conversion will not use up any credits. See Testing/Sandbox for more details.
Converting HTML documents to PDF
const fetch = require('node-fetch');
const { pipeline } = require('stream');
const { createWriteStream } = require('fs');
const { promisify } = require('util'); 

const streamPipeline = promisify(pipeline);

fetch('https://makemypdf.org/api/pdf/generate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your_api_key',
  },
  body: JSON.stringify({
    input: {
      type: 'url',
      source: 'https://en.wikipedia.org/wiki/Main_Page'
    },
    sandbox: false,
  })
})
  .then(async (res) => {
    if (!res.ok) {
      throw new Error('Failed to convert document');
    }
    await streamPipeline(res.body, createWriteStream('document.pdf'));
  })
...

Get information on your credits

This is how you get information on how much credits are available in total, how much you have used and how much are left - according to the API key you provide.

Provide your API key via the X-API-Key header.

Get information on your credits
const fetch = require('node-fetch');

fetch('https://makemypdf.org/api/credits/usage', {
  method: 'GET',
  headers: {
    'X-API-Key': 'your_api_key',
  }
})
  .then(async (res) => {
    if (!res.ok) {
      throw new Error('Failed to convert document');
    }
    console.log(await res.json());
    // {
    //   "limit": 20000,
    //   "remaining": 19891,
    //   "used": 109
    // }
  })
...