Documentation
Usage Examples
HTML to Image is a simple REST API that accepts POST requests to two endpoints:
POST https://app.html2img.com/api/html # Convert HTML to image
POST https://app.html2img.com/api/screenshot # Capture screenshots
All requests require authentication via the X-API-Key
header. Since this is a standard REST API, you can use any programming language or framework capable of making HTTP requests.
Below are examples in popular languages to help you get started quickly, but feel free to use any language you prefer.
Available Language Examples
Backend Languages
PHP
Basic PHP implementation using cURL for API requests.
Laravel
Laravel integration using the HTTP facade and file storage.
Ruby on Rails
Rails implementation with ActiveStorage support.
Python
Python examples using requests, Flask, and FastAPI.
Frontend Frameworks
JavaScript
Browser and Node.js examples using the Fetch API.
React
React components and custom hooks for image generation.
Vue
Vue 3 components and composables using the Composition API.
Common Features
All examples demonstrate these key features:
- HTML to Image conversion
- Screenshot generation
- Error handling
- File storage
- Environment configuration
- Security best practices
Getting Started
- Choose your preferred language or framework from the examples above
- Follow the setup instructions to configure your environment
- Copy and adapt the example code for your specific use case
All examples assume you have an API key. If you haven’t gotten one yet, check out our Quick Start guide.
Need Help?
- Check our API Reference for detailed endpoint documentation
- See our Example Use Cases for real-world applications
- Contact our support team if you need assistance
Remember to always keep your API key secure and never expose it in client-side code.