Skip to main content

Official Python SDK for ToolCenter's web automation and utility APIs

Project description

ToolCenter Python SDK

PyPI version Python version License: MIT

Official Python SDK for ToolCenter's web automation and utility APIs. Take screenshots, generate PDFs, create QR codes, extract metadata, and access 20+ other web-related tools through a simple Python interface.

Installation

pip install toolcenter

Quick Start

from toolcenter import ToolCenter

# Initialize client with your API key
tc = ToolCenter('your-api-key')

# Take a screenshot
result = tc.screenshot(url='https://example.com', width=1920, format='png')

# Generate a PDF
pdf_result = tc.pdf(url='https://example.com', format='A4')

# Create a QR code
qr_result = tc.qr(data='https://example.com', size=300)

Authentication

Get your API key from ToolCenter Dashboard and initialize the client:

from toolcenter import ToolCenter

tc = ToolCenter('your-api-key')

# Or with custom base URL
tc = ToolCenter('your-api-key', base_url='https://api.toolcenter.dev')

Core Features

Screenshots

Capture high-quality webpage screenshots:

# Basic screenshot
result = tc.screenshot(url='https://example.com')

# Full page screenshot with custom dimensions
result = tc.screenshot(
    url='https://example.com',
    width=1920,
    height=1080,
    full_page=True,
    format='png'
)

# Mobile device emulation
result = tc.screenshot(
    url='https://example.com',
    device='iPhone 12',
    wait_for='#content'
)

PDF Generation

Convert webpages to PDF documents:

# Basic PDF
result = tc.pdf(url='https://example.com')

# Custom format and options
result = tc.pdf(
    url='https://example.com',
    format='A4',
    landscape=True,
    print_background=True,
    margin={'top': '1in', 'bottom': '1in'}
)

QR Codes

Generate QR codes for any data:

# Basic QR code
result = tc.qr(data='https://example.com')

# Custom size and format
result = tc.qr(
    data='Hello World!',
    size=500,
    format='svg',
    error_correction='H'
)

Metadata Extraction

Extract rich metadata from websites:

# Extract all metadata
result = tc.metadata(url='https://example.com')

# Include specific data types
result = tc.metadata(
    url='https://example.com',
    include_og=True,
    include_twitter=True,
    include_schema=True
)

Available Methods

Web Content

  • screenshot(**kwargs) - Capture webpage screenshots
  • pdf(**kwargs) - Generate PDFs from webpages
  • html_to_image(**kwargs) - Convert HTML to image
  • metadata(**kwargs) - Extract webpage metadata
  • og_image(**kwargs) - Get Open Graph images
  • link_preview(**kwargs) - Generate rich link previews
  • favicon(**kwargs) - Extract website favicons

Image Processing

  • watermark(**kwargs) - Add watermarks to images
  • compress(**kwargs) - Compress and optimize images
  • colors(**kwargs) - Extract dominant colors
  • placeholder(**kwargs) - Generate placeholder images

Utilities

  • qr(**kwargs) - Generate QR codes
  • status(**kwargs) - Check website status
  • dns(**kwargs) - Perform DNS lookups
  • ssl(**kwargs) - Check SSL certificates
  • whois(**kwargs) - WHOIS domain lookups
  • tech_stack(**kwargs) - Detect website technologies

Bulk Operations

  • bulk_screenshot(urls, **kwargs) - Screenshot multiple URLs
  • bulk_pdf(urls, **kwargs) - Generate PDFs for multiple URLs
  • bulk_metadata(urls, **kwargs) - Extract metadata from multiple URLs

Account

  • usage() - Get API usage statistics

Error Handling

The SDK includes custom exception classes for different error types:

from toolcenter import ToolCenter, ToolCenterError, AuthenticationError, RateLimitError

tc = ToolCenter('your-api-key')

try:
    result = tc.screenshot(url='https://example.com')
except AuthenticationError:
    print("Invalid API key")
except RateLimitError:
    print("Rate limit exceeded")
except ToolCenterError as e:
    print(f"API error: {e}")

Bulk Operations

Process multiple URLs efficiently:

# Screenshot multiple websites
urls = [
    'https://example.com',
    'https://github.com',
    'https://stackoverflow.com'
]

results = tc.bulk_screenshot(urls, width=1920, format='png')

for url, result in results.items():
    if result['success']:
        print(f"Screenshot saved for {url}")
    else:
        print(f"Error for {url}: {result['error']}")

Advanced Usage

Custom Configuration

# Custom timeout and retry settings
tc = ToolCenter(
    api_key='your-api-key',
    base_url='https://toolcenter.dev'
)

# Screenshot with advanced options
result = tc.screenshot(
    url='https://example.com',
    width=1920,
    height=1080,
    full_page=False,
    wait_for='#main-content',
    delay=2000,  # 2 second delay
    device='Desktop'
)

Response Format

All methods return a dictionary with the following structure:

{
    "success": True,
    "data": {
        "url": "https://generated-content-url.com/image.png",
        "size": 156789,
        "format": "png",
        "width": 1920,
        "height": 1080
    },
    "usage": {
        "credits_used": 1,
        "remaining": 999
    }
}

Requirements

  • Python 3.8+
  • requests >= 2.20.0

Documentation

For complete API documentation and advanced usage examples, visit:

Support

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


Made with ❤️ by ToolCenter

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

toolcenter-1.1.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

toolcenter-1.1.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file toolcenter-1.1.0.tar.gz.

File metadata

  • Download URL: toolcenter-1.1.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for toolcenter-1.1.0.tar.gz
Algorithm Hash digest
SHA256 cdb88cdac82148193ac30989a10a0e350d0c464c13afdd65de9aa86e298760a4
MD5 9ff35ce2c5030c510bd17c67f53dd254
BLAKE2b-256 677a7a12384ee2604637cb799df54cc02b8748a4076d22715d9368756f901f39

See more details on using hashes here.

Provenance

The following attestation bundles were made for toolcenter-1.1.0.tar.gz:

Publisher: publish.yml on toolcenter-dev/sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file toolcenter-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: toolcenter-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for toolcenter-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2687ec872eaf76e24d02071fc704e4d86388081748c488a5c1ce2ae28ba5a0f2
MD5 3cfc467f09757ddf22c7104801a7c6ae
BLAKE2b-256 6760d94eaaa134e171afd323fa33c962252adf065031bfda78bdbcdcea1a328d

See more details on using hashes here.

Provenance

The following attestation bundles were made for toolcenter-1.1.0-py3-none-any.whl:

Publisher: publish.yml on toolcenter-dev/sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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