On this page

    Get started

    Take Your First Screenshot

    Create an API key, send one request and get a 1200×630 screenshot back. Copy-paste code for curl, Node.js, Python, Ruby, PHP, Go and Java.

    Time
    5 minutes
    Plan
    Free
    You need
    • A RenderScreenshot account with a verified email
    • A terminal with curl

    What you will have at the end

    A screenshot of a real page at 1200×630 pixels, the size social networks use for share images.

    You will make one API request and save the screenshot it returns. It takes about five minutes, and it uses one of the free credits you get every month.

    Create an API key

    Sign in and open API Keys in the dashboard sidebar. Click Create Key.

    Give the key a name that says where you will use it, for example My first key or Production server. Keep API key selected. The other option, a signing key pair, is for public image URLs and has its own guide.

    An API key (rs_live_) goes in the Authorization header of server-side requests.

    Click Create Key. The dashboard shows the full key one time only. Click Copy now.

    If you lose the key, revoke it and create a new one. Nobody can show it to you again, including support.

    Save the key in your shell

    Keep the key out of your source code. Put it in an environment variable, and every example on this site reads it from there:

    export RS_API_KEY=rs_live_your_key_here
    

    The variable lasts until you close the terminal. In an app, load it from your secret store or a .env file that is not committed.

    Send the request

    This request asks for a screenshot of https://example.com with the og_card preset, and saves the image as screenshot.png:

    curl -X POST https://api.renderscreenshot.com/v1/screenshot \
      -H "Authorization: Bearer $RS_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"url": "https://example.com", "preset": "og_card"}' \
      --output screenshot.png
    

    Open screenshot.png. It is a 1200×630 PNG of example.com:

    example.com is a plain test page. Step 4 renders a real one.

    The same request in your language. Each example starts with its install command:

    Node.js

    // npm install renderscreenshot
    import { Client, TakeOptions } from 'renderscreenshot';
    import { writeFile } from 'node:fs/promises';
    
    const client = new Client(process.env.RS_API_KEY);
    
    const image = await client.take(
      TakeOptions.url('https://example.com').preset('og_card')
    );
    await writeFile('screenshot.png', image);
    

    Python

    # pip install git+https://github.com/Render-Screenshot/rs-python.git
    import os
    
    from renderscreenshot import Client, TakeOptions
    
    client = Client(os.environ['RS_API_KEY'])
    
    image = client.take(TakeOptions.url('https://example.com').preset('og_card'))
    
    with open('screenshot.png', 'wb') as f:
        f.write(image)
    

    Ruby

    # gem install renderscreenshot
    require 'renderscreenshot'
    
    client = RenderScreenshot.client(ENV.fetch('RS_API_KEY'))
    
    image = client.take(
      RenderScreenshot::TakeOptions.url('https://example.com').preset('og_card')
    )
    
    File.binwrite('screenshot.png', image)
    

    PHP

    <?php
    // composer require renderscreenshot/renderscreenshot
    require 'vendor/autoload.php';
    
    use RenderScreenshot\Client;
    use RenderScreenshot\TakeOptions;
    
    $client = new Client(getenv('RS_API_KEY'));
    
    $image = $client->take(
        TakeOptions::url('https://example.com')->preset('og_card')
    );
    
    file_put_contents('screenshot.png', $image);
    

    Go

    // go get github.com/Render-Screenshot/rs-go
    package main
    
    import (
        "context"
        "log"
        "os"
    
        rs "github.com/Render-Screenshot/rs-go"
    )
    
    func main() {
        client, err := rs.New(os.Getenv("RS_API_KEY"))
        if err != nil {
            log.Fatal(err)
        }
    
        image, err := client.Take(context.Background(),
            rs.URL("https://example.com").Preset("og_card"),
        )
        if err != nil {
            log.Fatal(err)
        }
    
        if err := os.WriteFile("screenshot.png", image, 0o644); err != nil {
            log.Fatal(err)
        }
    }
    

    CLI

    # brew install render-screenshot/tap/rs   (reads RS_API_KEY)
    rs take https://example.com --preset og_card -o screenshot.png
    

    If the file does not open

    When a request fails, curl still writes the response body to screenshot.png. The file is then a short JSON error, not an image. Open it in a text editor:

    Error code What it means What to do
    missing_credentials (401) RS_API_KEY is empty in this terminal Run echo $RS_API_KEY, then export the key again
    invalid_url (400) The URL has no https:// Send the full URL, with the scheme
    email_not_verified (403) The free credits unlock when you verify your email Click the link in the verification email
    insufficient_credits (403) This month's credits are used up Wait for the reset on the 1st, or change plan

    Try one of your own pages

    Change the url value to a page you own and run the request again. Here is the same request for the RenderScreenshot home page:

    curl -X POST https://api.renderscreenshot.com/v1/screenshot \
      -H "Authorization: Bearer $RS_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"url": "https://renderscreenshot.com", "preset": "og_card"}' \
      --output home.png
    

    The result is the image at the top of this guide: the top 1200×630 pixels of the page, as a visitor with a desktop browser sees it.

    If the page looks wrong (blank, half loaded, or covered by a cookie banner), the guides fix blank or incomplete screenshots and remove cookie banners and ads show the fix.

    Find the request in your logs

    Open Logs in the dashboard. Each request shows its status, URL, key, format and render time. A failed request shows the error message, and it uses no credits.

    Try it without code

    The Playground in the dashboard sends the same request from a form. Enter a URL, pick a preset and click Generate Screenshot. It uses your credits like an API request.

    Next steps

    Try RenderScreenshot free

    150 free credits every month, no credit card required.