Capture screenshots in Crystal
Add screenshot and scrolling GIF capabilities to your Crystal applications with HTTP::Client. Ruby-like syntax, C-like speed, no headless browsers to manage.
Installation
- 1HTTP::Client is included in Crystal standard library
- 2Get your API key from the dashboard
- 3Set the X-KEY header in your requests
Authentication
Include your API key in the X-KEY header with every request:
require "http/client"
response = HTTP::Client.get(url,
headers: HTTP::Headers{"X-KEY" => "your-api-key"}
)Crystal Screenshot Example
Capture a screenshot or create a scrolling GIF animation with a simple GET request:
require "http/client"
response = HTTP::Client.get(
"https://api.scrnpix.com/screenshot?url=https%3A%2F%2Fexample.com&width=1280&height=720&format=png",
headers: HTTP::Headers{"X-KEY" => "your-api-key"}
)
File.write("screenshot.png", response.body)require "http/client"
response = HTTP::Client.get(
"https://api.scrnpix.com/animate?url=https%3A%2F%2Fexample.com&scroll_duration=3000&scroll_easing=ease-in-out",
headers: HTTP::Headers{"X-KEY" => "your-api-key"}
)
File.write("animation.gif", response.body)Response Format
On success, the API returns the image binary data directly in the response body.
| Status Code | 200 OK |
| Content-Type | image/png, image/jpeg, or image/gif |
| Body | Binary image data (Bytes) |
| Error Response | Error message with 4xx/5xx status |
Key Features
Zero Setup
HTTP::Client is built into Crystal. No external dependencies or browser installations required.
Production Ready
Built on Cloudflare Workers with global edge network. Handles concurrency and browser lifecycle automatically.
Crystal Integration
Type-safe with familiar Ruby syntax. Integrates seamlessly with Kemal, Lucky, Amber, or any Crystal application.
Rich Features
Custom viewport sizes, full page capture, PNG/JPEG formats, scrolling GIFs with 15 easing functions.
Frequently Asked Questions
Do I need to install any browser dependencies for Crystal?
No. Scrnpix runs browsers on our infrastructure. You only need Crystal's built-in HTTP::Client to make HTTP calls.
Can I use this with Kemal or Lucky?
Yes. Scrnpix works with any Crystal framework — Kemal, Lucky, Amber, or plain Crystal applications.
How do I handle errors in Crystal?
Check the response.status_code. A 200 status means success with image bytes in response.body. Use begin-rescue for error handling.
What Crystal version is required?
Crystal 1.0+ with HTTP::Client support. The API is a simple HTTP GET request.
Ready to capture screenshots in Crystal?
Get your API key and start rendering screenshots in seconds. Free tier includes 50 screenshots per month.
Start Free