Skip to main content

Python SDK for compdfkit API

Project description

ComPDFKit API in Python

ComPDFKit API provides a variety of Python API tools that allow you to create an efficient document processing workflow in a single API call. Try our various APIs for free — no credit card required.

Requirements

Programming Environment: Python 3.8 and higher.

Installation

You can install the library via pip. Run the following command:

pip install compdfkit-api-python

Create API Client

You can use your publicKey and secretKey to complete the authentication. You need to sign in your ComPDFKit API account to get your publicKey and secretKey at the dashboard. If you are new to ComPDFKit, click here to sign up for a free trial.

# Create a client
client = CPDFClient(public_key, secret_key)

Create Task

A task ID is automatically generated for you based on the type of PDF tool you choose. You can provide the callback notification URL. After the task processing is completed, we will notify you of the task result through the callback interface. You can perform other operations according to the request result, such as checking the status of the task, uploading files, starting the task, or downloading the result file.

# Create a client
client = CPDFClient(public_key, secret_key)

# Create a task
# Create an example of a PDF TO WORD task
create_task_result = client.create_task(CPDFConversionEnum.PDF_TO_WORD)

# Get a task id
task_id = create_task_result.task_id

Upload Files

Upload the original file and bind the file to the task ID. The field parameter is used to pass the JSON string to set the processing parameters for the file. Each file will generate automatically a unique filekey. Please note that a maximum of five files can be uploaded for a task ID and no files can be uploaded for that task after it has started.

# Create a client
client = CPDFClient(public_key, secret_key)

# Create a task
# Create an example of a PDF TO WORD task
create_task_result = client.create_task(CPDFConversionEnum.PDF_TO_WORD)

# Get a task id
task_id = create_task_result.task_id

# Upload files
client.upload_file(convert_file, task_id)

Execute the task

After the file upload is completed, call this interface with the task ID to process the files.

# Create a client
client = CPDFClient(public_key, secret_key)

# Create a task
# Create an example of a PDF TO WORD task
create_task_result = client.create_task(CPDFConversionEnum.PDF_TO_WORD)

# Get a task id
task_id = create_task_result.task_id

# Upload files
client.upload_file(convert_file, task_id)

# execute Task
client.execute_task(task_id)

Get Task Info

Request task status and file-related meta data based on the task ID.

# Create a client
client = CPDFClient(public_key, secret_key)

# Create a task
# Create an example of a PDF TO WORD task
create_task_result = client.create_task(CPDFConversionEnum.PDF_TO_WORD)

# Get a task id
task_id = create_task_result.task_id

# Upload files
client.upload_file(convert_file, task_id)

# execute Task
client.execute_task(task_id)

# Query TaskInfo
task_info = client.get_task_info(task_id)

Resources

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

compdfkit-api-python-1.3.2.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

compdfkit_api_python-1.3.2-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file compdfkit-api-python-1.3.2.tar.gz.

File metadata

  • Download URL: compdfkit-api-python-1.3.2.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.17

File hashes

Hashes for compdfkit-api-python-1.3.2.tar.gz
Algorithm Hash digest
SHA256 c01c5595397274cfaa7244ef998b451839605ed816ead3696e845e95c85f557f
MD5 ccfcc8db35d399582d2cc31748f94a5a
BLAKE2b-256 503543a1e7b50a6fba5e0f2b4e4fb9efd9a04ec89c54a024c142a045d9712384

See more details on using hashes here.

File details

Details for the file compdfkit_api_python-1.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for compdfkit_api_python-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b058237f19c7665c367231b057a04ec6c097c42c343347a94fb2f34467527363
MD5 0c04a855c7bd2b9cece6c1deea3c1fb2
BLAKE2b-256 0835c210a84394db6c44092a0c5fe10c873a72cc1543103205d714262de7c0aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page