Skip to main content

Official Python client for the Zamzar API

Project description

Python file converter library for Zamzar

@zamzar on Twitter pypi version GitHub License

Easy to use Python file conversion API with support for 1,100+ file conversions - convert documents, audio, images, video, eBooks and more. Use zamzar-python to convert files between different formats as part of your Python application with the Zamzar file conversion API. Common use cases include:

  • Convert Microsoft Word (DOCX, DOC) to PDF
  • Convert Powerpoint (PPT, PPTX) to JPG
  • Extract text from PDF files
  • Archive email (MSG files) to PDF

This is the official Python SDK for the Zamzar API.

Jump to:

Requirements

  • Before you begin, signup for a Zamzar API Account or retrieve your existing API Key from the Zamzar Developers Homepage
  • Python 3.7 and later

Installation

You can install zamzar-python using pip:

pip install --upgrade zamzar-sdk

Usage

Getting Started

Please follow the installation instructions and execute the following Python code:

from zamzar_sdk import ZamzarClient

zamzar = ZamzarClient("YOUR_API_KEY_GOES_HERE")

zamzar.convert("/tmp/example.docx", "pdf").store("/tmp/").delete_all_files()

See the examples to learn more about how to use the Zamzar Python library.

Using the sandbox environment

Whilst developing your application, you can use the lZamzar sandbox environment to test your code without consuming production credits:

from zamzar_sdk import ZamzarClient, Environment

zamzar = ZamzarClient("YOUR_API_KEY_GOES_HERE", environment=Environment.SANDBOX)

The Zamzar Python library uses the production environment by default, but you can also specify it explicitly:

from zamzar_sdk import ZamzarClient, Environment

zamzar = ZamzarClient("YOUR_API_KEY_GOES_HERE", environment=Environment.PRODUCTION)

Logging

By default, the Zamzar Python library does not log HTTP requests and responses. To enable logging, configure a logging.Logger for urllib3:

import logging

from zamzar_sdk import ZamzarClient

# Configure logging as needed. Here we configure a simple console logger
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.DEBUG)  # Set the logging level for the console handler
console_formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
console_handler.setFormatter(console_formatter)
root_logger = logging.getLogger()
root_logger.addHandler(console_handler)
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

# Enable logging for urllib3 to see HTTP requests
urllib3_logger = logging.getLogger('urllib3')
urllib3_logger.setLevel(logging.DEBUG)

# Make a request to the Zamzar API
zamzar = ZamzarClient("YOUR_API_KEY_GOES_HERE")
zamzar.account.get()

Configuring timeouts and retries

The Zamzar Python library will automatically:

  • time out long-running requests
  • retry requests that fail or time out

The default settings are defined in ZamzarClient.

To override these defaults, configure your own urllib3.Retry and pass it to the ZamzarClient constructor:

import urllib3

from zamzar_sdk import ZamzarClient

# Configure a custom retry policy
custom_policy = urllib3.Retry(
    total=5,  # Maximum number of retries
    backoff_factor=1,  # Exponential backoff factor
    backoff_max=60,  # Maximum backoff time
    status_forcelist=[429, 502, 503, 504],  # HTTP status codes to retry
    allowed_methods=None  # retry all request methods
)

# Make a request to the Zamzar API
zamzar = ZamzarClient("YOUR_API_KEY_GOES_HERE", retries=custom_policy)

Resources

Code Samples - Copy/Paste from examples which demonstrate all key areas of functionality.

Developer Docs - For more information about API operations, parameters, and responses. Use this if you need additional context on all areas of functionality.

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

zamzar_sdk-0.1.1.tar.gz (49.8 kB view details)

Uploaded Source

Built Distribution

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

zamzar_sdk-0.1.1-py3-none-any.whl (84.9 kB view details)

Uploaded Python 3

File details

Details for the file zamzar_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: zamzar_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 49.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.17

File hashes

Hashes for zamzar_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6337d41f8e49b8890800350a3c87e4177f706c3a1659460d878eb6508267b1c7
MD5 bd2df1c8e474773f41967d3daa6105a4
BLAKE2b-256 f4e3fb93f3f4a35448261794c1aad9190f78a305b45d25d0eb34fa1231befea0

See more details on using hashes here.

File details

Details for the file zamzar_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: zamzar_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 84.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.17

File hashes

Hashes for zamzar_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3f6d4905f778ee02ab241ad14d9f4ec7b95c402ee4891946662ec70eb0e2ce36
MD5 9290212558d2f0a109fb9c48e8c62d77
BLAKE2b-256 7c8e265a3a6599d2fb92e71de7a5d367d61fbf0b09b0eb0b215e1cbd06c7483a

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