API Documentation
Have a question? Contact Us.
All API requests must be made over HTTPS and need api_key as a URL query parameter.
Example
curl https://api.printfriendly.com/v2/pdf/create?api_key=YOUR_API_KEY \
-H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
-d page_url=https://en.wikipedia.org/wiki/Eclipse
In case of success, you will get an http response with Status 200 and JSON info in the response body.
{"status":"success","file_url":"https://api.printfriendly.com/downloads/pdf_1531957353_e94df5Letter.pdf"}
API Version
Current version of API is 2.0.
Major API version must be provided in URL as ‘v’ and number, ie. v1, v2, v3.
Example
https://api.printfriendly.com/v2/pdf/create
https://api.printfriendly.com/v2/html/create
API Methods
Parameters
You must provide page_url or html parameter. All others parameters are optional.
All examples below are provided for the "pdf/create" method and also work for the "html/create" method.
Example with page_url parameter
curl https://api.printfriendly.com/v2/pdf/create?api_key=YOUR_API_KEY \
-H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
-d page_url=https://test.test \
-d css_url=https://my-site.com/pdf_style.css \
-d header_text='My Custom Header'
HTML input
curl https://api.printfriendly.com/v2/pdf/create?api_key=YOUR_API_KEY \
-H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
-d html='<html><body><h1>Title</h1><p>Text text text text text text text text text</p></body></html>'
Errors
PrintFriendly uses conventional Status codes and JSON response to provide error details.
Status Codes
All not success (not Status 200) responses have JSON body with the error details and contain the error type and message.
Error Types
Example
curl https://api.printfriendly.com/v2/pdf/create?api_key=YOUR_API_KEY \
-H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
-d page_url=https://test.test
HTML input
# HTTP RESPONSE
# HEADERS (some of headers were ommited)
Content-Type: application/json; charset=utf-8
Status: 400 Bad Request
# BODY (JSON)
{"status":"failed","message":"Print technology unable to download or parse content"}
Requests Rate Limiting
The API has 60 requests per minute limit. If your requests limit exceeded you will get response with Status: 429 Too Many Requests.
Example with page_url parameter
# HEADERS (some of headers were ommited)
Status: 429 Too Many Requests
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 20
# BODY (JSON)Empty
All API requests must be made over HTTPS and use HTTP Basic Auth with the following credentials:
Username: API KEY
Password: Not needed
Example
curl https://api.printfriendly.com/v1/pdfs/create \
-u your_api_key: \
-d page_url=https://en.wikipedia.org/wiki/Eclipse
In case of success, you will get an http response with Status 302 (Redirect) and the JSON info will be in the response body.
# HTTP RESPONSE
# HEADERS (some of headers are ommited)
Content-Type: application/json; charset=utf-8
Status: 302 Found
Location: https://v.printfriendly.com/system/pdfs/pdf_1480936999_755625A4.pdf
# BODY
{"success":"Redirect to https://v.printfriendly.com/system/pdfs/pdf_1480947535_6e7ecaA4.pdf"}
API Version
Current version of API is 1.0.
Major API version must be provided in URL as 'v' and a number, ie. v1, v2, v3.
Example
https://api.printfriendly.com/v1/pdf/create
https://api.printfriendly.com/v1/html/create
API Methods
Parameters
You must provide a page_url or html parameter. All other parameters are optional.
All examples below are provided for "pdf/create" method but also work for "html/create" method.
Example with page_url parameter
curl https://api.printfriendly.com/v1/pdfs/create \
-u your_api_key: \
-d page_url=https://test.test \
-d css_url=https://my-site.com/pdf_style.css \
-d header_text='My Custom Header'
In case of success, you will get an http response with Status 302 (Redirect) and JSON info will be in the response body.
Example with html parameter
curl https://api.printfriendly.com/v1/pdfs/create \
-u your_api_key: \
-d html='<html><body><h1>Title</h1><p>Text text text text text text text text text</p></body></html>'
In case of success, you will get http response with Status 200 and PDF/HTML content in response body.
Errors
PrintFriendly uses conventional Status codes and JSON response to provide error details.
Status Codes
All not success (not Status: 302 OK) responses have JSON body with the error details, which will include the error type and message.
Error Types
Example
curl https://api.printfriendly.com/v1/pdfs/create \
-u your_api_key: \
-d page_url=https://test.test
HTML input
# HTTP RESPONSE
# HEADERS (some of headers were ommited)
Content-Type: application/json; charset=utf-8
Status: 400 Bad Request
# BODY (JSON)
{"status":"failed","message":"Print technology unable to download or parse content"}
Requests Rate Limiting
The API has a limit of 60 requests per minute. If you exceed this limit, you will get a response with Status: 429 Too Many Requests.
Example with page_url parameter
# HEADERS (some of headers were ommited)
Status: 429 Too Many Requests
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 20
# BODY (JSON)Empty
Get Started for FREE
Try it free, no credit card required. Contact us with any questions.