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.0.0.tar.gz (10.7 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.0.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for toolcenter-1.0.0.tar.gz
Algorithm Hash digest
SHA256 26b6180b598547bdda08d9c2ff731a14296baea8a1d5f65c3a7966a9aa526fe7
MD5 c086434d4212cd0af5cb467857836b00
BLAKE2b-256 8ed19115f92f77d19fa75407875ba6029f5c35b3072da8810d4778ad4bc8cc9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for toolcenter-1.0.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.0.0-py3-none-any.whl.

File metadata

  • Download URL: toolcenter-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c51b25d36009330b9f5b40e72e8adb13f6206d9f65d4be27f729414d9e0afb2
MD5 7603f4191fc682cf4868c14792615691
BLAKE2b-256 ed1b2ee76e7c860cfb20650b2be8fe6c9d05cc92225784e5d4e08ffcd4971117

See more details on using hashes here.

Provenance

The following attestation bundles were made for toolcenter-1.0.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