Capture screenshots in Lua
Add screenshot and scrolling GIF capabilities to your Lua applications with LuaSocket. Lightweight, embeddable, no headless browsers to manage.
Installation
- 1Install LuaSocket: luarocks install luasocket
- 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:
local http = require("socket.http")
local ltn12 = require("ltn12")
local response = {}
http.request{
url = url,
headers = {["X-KEY"] = "your-api-key"},
sink = ltn12.sink.table(response)
}Lua Screenshot Example
Capture a screenshot or create a scrolling GIF animation with a simple GET request:
local http = require("socket.http")
local ltn12 = require("ltn12")
local response = {}
http.request{
url = "https://api.scrnpix.com/screenshot?url=https%3A%2F%2Fexample.com&width=1280&height=720&format=png",
headers = {["X-KEY"] = "your-api-key"},
sink = ltn12.sink.table(response)
}
local file = io.open("screenshot.png", "wb")
file:write(table.concat(response))
file:close()local http = require("socket.http")
local ltn12 = require("ltn12")
local response = {}
http.request{
url = "https://api.scrnpix.com/animate?url=https%3A%2F%2Fexample.com&scroll_duration=3000&scroll_easing=ease-in-out",
headers = {["X-KEY"] = "your-api-key"},
sink = ltn12.sink.table(response)
}
local file = io.open("animation.gif", "wb")
file:write(table.concat(response))
file:close()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 (string) |
| Error Response | Error message with 4xx/5xx status |
Key Features
Zero Setup
No need to install browser bindings. Just use LuaSocket for simple HTTP calls.
Production Ready
Built on Cloudflare Workers with global edge network. Handles concurrency and browser lifecycle automatically.
Lua Integration
Lightweight and embeddable. Works with LÖVE, OpenResty, Neovim, game engines, or any Lua environment.
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 Lua?
No. Scrnpix runs browsers on our infrastructure. You only need LuaSocket or lua-http to make HTTP calls.
Can I use this with LÖVE or OpenResty?
Yes. Scrnpix works with any Lua environment — LÖVE games, OpenResty, Neovim plugins, or embedded Lua scripts.
How do I handle errors in Lua?
Check the HTTP status code in the response. A 200 status means success with image bytes in the body. Use pcall for error handling.
What Lua version is required?
Lua 5.1+ or LuaJIT with LuaSocket support. The API is a simple HTTP GET request.
Ready to capture screenshots in Lua?
Get your API key and start rendering screenshots in seconds. Free tier includes 50 screenshots per month.
Start Free