Systems Programming

Capture screenshots in C

Add screenshot and scrolling GIF capabilities to your C applications with libcurl. Maximum performance, no browser overhead.

Installation

  1. 1Install libcurl: apt install libcurl4-openssl-dev (or equivalent)
  2. 2Get your API key from the dashboard
  3. 3Set the X-KEY header using curl_slist_append

Authentication

Include your API key in the X-KEY header with every request:

#include <curl/curl.h>

CURL *curl = curl_easy_init();
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "X-KEY: your-api-key");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

C Screenshot Example

Capture a screenshot or create a scrolling GIF animation with a simple GET request:

Screenshot
#include <curl/curl.h>
#include <stdio.h>

int main() {
    CURL *curl = curl_easy_init();
    FILE *fp = fopen("screenshot.png", "wb");

    struct curl_slist *headers = NULL;
    headers = curl_slist_append(headers, "X-KEY: your-api-key");

    curl_easy_setopt(curl, CURLOPT_URL,
        "https://api.scrnpix.com/screenshot?url=https%3A%2F%2Fexample.com&width=1280&height=720&format=png");
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
    curl_easy_perform(curl);

    fclose(fp);
    curl_easy_cleanup(curl);
    return 0;
}
Animation
#include <curl/curl.h>
#include <stdio.h>

int main() {
    CURL *curl = curl_easy_init();
    FILE *fp = fopen("animation.gif", "wb");

    struct curl_slist *headers = NULL;
    headers = curl_slist_append(headers, "X-KEY: your-api-key");

    curl_easy_setopt(curl, CURLOPT_URL,
        "https://api.scrnpix.com/animate?url=https%3A%2F%2Fexample.com&scroll_duration=3000&scroll_easing=ease-in-out");
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
    curl_easy_perform(curl);

    fclose(fp);
    curl_easy_cleanup(curl);
    return 0;
}

Response Format

On success, the API returns the image binary data directly in the response body.

Status Code200 OK
Content-Typeimage/png, image/jpeg, or image/gif
BodyBinary image data (char buffer)
Error ResponseError message with 4xx/5xx status

Key Features

Zero Setup

No need to embed a browser engine. Just link against libcurl for simple HTTP calls.

Production Ready

Built on Cloudflare Workers with global edge network. Handles concurrency and browser lifecycle automatically.

C Integration

Minimal footprint with libcurl. Perfect for embedded systems, game engines, or performance-critical applications.

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 libcurl to make HTTP calls.

Can I use this in embedded systems?

Yes. Scrnpix works anywhere libcurl runs — embedded Linux, desktop applications, game engines, or servers.

How do I handle errors in C?

Check the CURLcode return value and HTTP response code. A 200 status means success with image bytes in the write callback buffer.

What C standard is required?

C99 or later with libcurl 7.x support. 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