How to Check PDF Conditions and Metadata with cURL

Learn how to check conditional information about a PDF and get metadata using Query PDF API Tool from pdfRest with cURL
Share this page

Why Use Query PDF with cURL?

The pdfRest Query PDF API Tool is a powerful resource for extracting information from PDF documents. This tool allows users to query various properties of a PDF, such as the title, page count, document language, and author, among others. In this tutorial, we will demonstrate how to send an API call to the Query PDF endpoint using cURL, a versatile command-line tool used for making HTTP requests. cURL is widely used for its simplicity and broad support across various platforms, making it an ideal choice for interacting with web APIs like pdfRest.

Imagine you are working on an application that needs to organize a large number of PDF documents based on their metadata. You might need to categorize them by author, count the number of pages, or filter them by language. Using the Query PDF API, you can programmatically retrieve this information and automate the organization process. This can save a significant amount of time and effort, especially when dealing with a large volume of documents.

Query PDF with cURL Code Example

curl -X POST "" \
  -H "Accept: application/json" \
  -H "Content-Type: multipart/form-data" \
  -H "Api-Key: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
  -F "file=@/path/to/file" \
  -F "queries=title,page_count,doc_language,author"

Reference to the provided code: pdf-rest-api-samples

Breaking Down the Code

This cURL command sends a POST request to the Query PDF endpoint. Let's break down each part of the command:

-X POST ""

This specifies the request method (POST) and the URL of the API endpoint.

-H "Accept: application/json"

This header tells the server that the client expects a response in JSON format.

-H "Content-Type: multipart/form-data"

This header indicates that the request body will be sent as multipart/form-data, which is necessary for uploading files.

-H "Api-Key: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

This header includes the API key required for authentication with the pdfRest API.

-F "file=@/path/to/file"

The -F flag is used to specify each field that will be sent as part of the multipart/form-data request. In this case, it's used to upload the PDF file from the specified path.

-F "queries=title,page_count,doc_language,author"

This field specifies the information to query from the PDF. The API will return the title, page count, document language, and author of the PDF.

For more details on the parameters and how to use the Query PDF API, you can refer to the pdfRest Cloud API Reference Guide.

Beyond the Tutorial

By following the steps above, you have learned how to make a multipart API call to the Query PDF endpoint using cURL. This enables you to programmatically retrieve valuable metadata from PDF documents. With the knowledge gained, you can integrate this functionality into your applications or workflows, enhancing your ability to manage and utilize PDF files.

To further explore what you can do with pdfRest, consider trying out all of the API Tools in the API Lab. For a comprehensive understanding of the full capabilities of the pdfRest API, refer to the API Reference Guide.

Note: This is an example of a multipart API call. Code samples using JSON payloads can be found at pdf-rest-api-samples JSON Payload.

Generate a self-service API Key now!

Create your FREE API Key to start processing PDFs in seconds, only possible with pdfRest.

Compare Plans
Contact Us