toolcenter / sdk
Official PHP SDK for ToolCenter API - Web automation tools including screenshots, PDFs, QR codes, metadata extraction, and more.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/toolcenter/sdk
Requires
- php: >=8.1
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^10.0
README
The official PHP SDK for ToolCenter - A comprehensive API for web automation tools including screenshots, PDFs, QR codes, metadata extraction, and much more.
Features
- 🖼️ Screenshots - Capture high-quality screenshots of any website
- 📄 PDF Generation - Convert web pages to PDF documents
- 🔗 QR Codes - Generate customizable QR codes
- 📊 Metadata Extraction - Extract rich metadata from websites
- 🎨 Image Processing - Watermarks, compression, and color extraction
- 🔍 Website Analysis - DNS, SSL, WHOIS, and tech stack detection
- 📱 Social Media - Open Graph images and link previews
- 🚀 Bulk Operations - Process multiple URLs efficiently
Installation
Install the SDK via Composer:
composer require toolcenter/sdk
Quick Start
<?php require_once 'vendor/autoload.php'; use ToolCenter\ToolCenter; // Initialize the client with your API key $tc = new ToolCenter('your-api-key-here'); // Capture a screenshot $screenshot = $tc->screenshot([ 'url' => 'https://example.com', 'width' => 1920, 'height' => 1080, 'format' => 'png' ]); echo "Screenshot URL: " . $screenshot['url'] . "\n";
Authentication
Get your API key from your ToolCenter Dashboard and initialize the client:
$tc = new ToolCenter('your-api-key-here'); // Or with a custom base URL $tc = new ToolCenter('your-api-key-here', 'https://custom.toolcenter.dev');
Usage Examples
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, 'fullPage' => true, 'format' => 'webp', 'quality' => 90 ]);
PDF Generation
// Generate PDF $result = $tc->pdf([ 'url' => 'https://example.com', 'format' => 'A4', 'orientation' => 'portrait', 'margin' => '1cm' ]); // PDF with custom options $result = $tc->pdf([ 'url' => 'https://example.com', 'format' => 'letter', 'landscape' => true, 'printBackground' => true, 'scale' => 0.8 ]);
QR Codes
// Simple QR code $result = $tc->qr([ 'data' => 'https://toolcenter.dev', 'size' => 300 ]); // Customized QR code $result = $tc->qr([ 'data' => 'Hello World!', 'size' => 500, 'format' => 'svg', 'errorCorrection' => 'M', 'margin' => 4 ]);
Metadata Extraction
// Extract website metadata $result = $tc->metadata([ 'url' => 'https://example.com' ]); // Include images and social media data $result = $tc->metadata([ 'url' => 'https://example.com', 'includeImages' => true, 'includeSocial' => true ]);
Bulk Operations
// Bulk screenshots $urls = [ 'https://example.com', 'https://google.com', 'https://github.com' ]; $results = $tc->bulkScreenshot($urls); // Bulk PDFs $results = $tc->bulkPdf($urls); // Bulk metadata $results = $tc->bulkMetadata($urls);
Laravel Integration
Service Provider
Create a service provider to register the ToolCenter client:
<?php namespace App\Providers; use Illuminate\Support\ServiceProvider; use ToolCenter\ToolCenter; class ToolCenterServiceProvider extends ServiceProvider { public function register() { $this->app->singleton(ToolCenter::class, function ($app) { return new ToolCenter(config('services.toolcenter.api_key')); }); } }
Configuration
Add your API key to config/services.php:
'toolcenter' => [ 'api_key' => env('TOOLCENTER_API_KEY'), ],
Usage in Laravel
<?php namespace App\Http\Controllers; use ToolCenter\ToolCenter; class ScreenshotController extends Controller { public function __construct(private ToolCenter $toolCenter) { } public function capture(Request $request) { $screenshot = $this->toolCenter->screenshot([ 'url' => $request->input('url'), 'width' => 1920, 'height' => 1080 ]); return response()->json($screenshot); } }
API Methods
Core Methods
| Method | Description | Endpoint |
|---|---|---|
screenshot(array $options) |
Capture website screenshots | POST /api/v1/screenshot |
pdf(array $options) |
Generate PDFs from web pages | POST /api/v1/pdf |
qr(array $options) |
Generate QR codes | POST /api/v1/qr |
ogImage(array $options) |
Create Open Graph images | POST /api/v1/og-image |
metadata(array $options) |
Extract website metadata | POST /api/v1/metadata |
htmlToImage(array $options) |
Convert HTML to image | POST /api/v1/html-to-image |
linkPreview(array $options) |
Generate link previews | POST /api/v1/link-preview |
Image Processing
| Method | Description | Endpoint |
|---|---|---|
watermark(array $options) |
Add watermarks to images | POST /api/v1/watermark |
compress(array $options) |
Compress images | POST /api/v1/compress |
colors(array $options) |
Extract dominant colors | POST /api/v1/colors |
placeholder(array $options) |
Generate placeholder images | POST /api/v1/placeholder |
Website Analysis
| Method | Description | Endpoint |
|---|---|---|
dns(array $options) |
DNS lookups | POST /api/v1/dns |
ssl(array $options) |
SSL certificate info | POST /api/v1/ssl |
status(array $options) |
Website status checks | POST /api/v1/status |
techStack(array $options) |
Technology stack detection | POST /api/v1/techstack |
whois(array $options) |
WHOIS lookups | POST /api/v1/whois |
favicon(array $options) |
Extract favicons | POST /api/v1/favicon |
Utility Methods
| Method | Description | Endpoint |
|---|---|---|
usage() |
Get API usage statistics | GET /api/v1/usage |
Bulk Operations
| Method | Description | Endpoint |
|---|---|---|
bulkScreenshot(array $urls) |
Bulk screenshot capture | POST /api/v1/bulk/screenshot |
bulkPdf(array $urls) |
Bulk PDF generation | POST /api/v1/bulk/pdf |
bulkMetadata(array $urls) |
Bulk metadata extraction | POST /api/v1/bulk/metadata |
Error Handling
The SDK provides custom exception classes for different error scenarios:
use ToolCenter\Exceptions\ToolCenterException; use ToolCenter\Exceptions\AuthenticationException; use ToolCenter\Exceptions\RateLimitException; try { $result = $tc->screenshot(['url' => 'https://example.com']); } catch (AuthenticationException $e) { // Handle authentication errors (401) echo "Authentication failed: " . $e->getMessage(); } catch (RateLimitException $e) { // Handle rate limit errors (429) echo "Rate limit exceeded: " . $e->getMessage(); } catch (ToolCenterException $e) { // Handle other API errors echo "API error: " . $e->getMessage(); // Get the full response for debugging $response = $e->getResponse(); print_r($response); }
Requirements
- PHP 8.1 or higher
- Guzzle HTTP client (automatically installed via Composer)
Support
- 📚 Documentation
- 💬 Support
- 🐛 Issues
- 📧 Contact
Contributing
We welcome contributions! Please feel free to submit a Pull Request.
License
This SDK is open-sourced software licensed under the MIT license.
Made with ❤️ by ToolCenter