Overview

PDF Parrot API allows users to convert web pages to PDF format by sending a simple HTTP request. This document outlines how to interact with the API, including how to pass in URL parameters, headers, and cookies.

API Endpoint

The API endpoint to generate a PDF is:

https://pdfparrot.xyz/api/pdf

Request Parameters

To convert a web page to PDF, you must provide the following parameters:

  • url (required): The URL of the web page to convert.
  • key (required): Your API key for authentication.

Custom Headers and Cookies

You can also provide custom headers and cookies to the API by appending them as query parameters:

  • Custom headers: header_name=value
  • Custom cookies: cookie_name=value

Example Usage

Basic Request

The following is an example of a basic request to convert a web page to a PDF:

https://pdfparrot.xyz/api/pdf
    ?url=http://example.com
    &key=YOUR_API_KEY

Request with Custom Headers and Cookies

If you need to pass custom headers or cookies, append them to the query string as shown below:

https://pdfparrot.xyz/api/pdf
    ?url=http://example.com
    &key=YOUR_API_KEY
    &header_authentication=dXNlcm5hbWU6cGFzc3dvcmQ=
    &cookie_user_id=123

Response

The response will be the PDF file generated from the URL provided. If there’s an error, you will receive an appropriate HTTP status code and an error message.

Error Handling

The API uses standard HTTP status codes to indicate the success or failure of an API request. Here are some of the responses you might encounter:

  • 200 OK: The request was successful, and the server generated a PDF.
  • 400 Bad Request: The server could not understand the request due to invalid syntax.
  • 401 Unauthorized: You have not provided your API key or it is incorrect.

Security

Ensure that your API key is kept confidential. Do not expose it in client-side code or in public repositories.

Support

For further assistance or to report an issue with the API, please contact our support team at support@pdfparrot.xyz