Capture screenshots in C++
Add screenshot and scrolling GIF capabilities to your C++ applications with cpp-httplib or libcurl. Zero-overhead abstractions, no browser complexity.
Installation
- 1Add cpp-httplib (header-only) or link against libcurl
- 2Get your API key from the dashboard
- 3Set the X-KEY header in your HTTP requests
Authentication
Include your API key in the X-KEY header with every request:
#include <httplib.h>
httplib::Client cli("api.scrnpix.com");
httplib::Headers headers = {{"X-KEY", "your-api-key"}};
auto res = cli.Get(path, headers);C++ Screenshot Example
Capture a screenshot or create a scrolling GIF animation with a simple GET request:
#include <httplib.h>
#include <fstream>
int main() {
httplib::Client cli("https://api.scrnpix.com");
httplib::Headers headers = {{"X-KEY", "your-api-key"}};
auto res = cli.Get("/screenshot?url=https%3A%2F%2Fexample.com&width=1280&height=720&format=png", headers);
std::ofstream file("screenshot.png", std::ios::binary);
file.write(res->body.data(), res->body.size());
return 0;
}#include <httplib.h>
#include <fstream>
int main() {
httplib::Client cli("https://api.scrnpix.com");
httplib::Headers headers = {{"X-KEY", "your-api-key"}};
auto res = cli.Get("/animate?url=https%3A%2F%2Fexample.com&scroll_duration=3000&scroll_easing=ease-in-out", headers);
std::ofstream file("animation.gif", std::ios::binary);
file.write(res->body.data(), res->body.size());
return 0;
}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 (std::string or vector<char>) |
| Error Response | Error message with 4xx/5xx status |
Key Features
Zero Setup
No need to embed CEF or Chromium. Just use a lightweight HTTP library like cpp-httplib.
Production Ready
Built on Cloudflare Workers with global edge network. Handles concurrency and browser lifecycle automatically.
C++ Integration
Modern C++ with RAII. Works with Qt, Unreal Engine, game engines, or any C++ 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 C++?
No. Scrnpix runs browsers on our infrastructure. You only need an HTTP library like cpp-httplib or libcurl.
Can I use this with Qt or game engines?
Yes. Scrnpix works with any C++ environment — Qt, Unreal Engine, Unity (via native plugins), or desktop applications.
How do I handle errors in C++?
Check the response status code. A 200 status means success with image bytes in the body. Use exceptions or error codes for handling.
What C++ standard is required?
C++11 or later recommended. The API is a simple HTTP GET request.
Ready to capture screenshots in C++?
Get your API key and start rendering screenshots in seconds. Free tier includes 50 screenshots per month.
Start Free