Video
Scrolling videos and GIFs
/v1/animate records the page as MP4, WebM, MOV, AVI or GIF. It accepts the same page options as /v1/take (viewport, blocking, scripts, waiting…) plus the animation options in the reference.
// npm install @shotsmith/sdk
import { Shotsmith, AnimateOptions } from '@shotsmith/sdk';
import { writeFile } from 'node:fs/promises';
const shotsmith = new Shotsmith({
accessKey: 'YOUR_ACCESS_KEY',
});
const options = AnimateOptions.url('https://shotsmith.dev/sample')
.format('mp4')
.duration(6)
.scrollEasing('ease_in_out_quint')
.blockCookieBanners();
await writeFile('capture.mp4', await shotsmith.animate(options));
<?php
// composer require shotsmith/shotsmith-php
require 'vendor/autoload.php';
use Shotsmith\Client;
use Shotsmith\Options\AnimateOptions;
$shotsmith = new Client('YOUR_ACCESS_KEY');
$options = AnimateOptions::url('https://shotsmith.dev/sample')
->format('mp4')
->duration(6)
->scrollEasing('ease_in_out_quint')
->blockCookieBanners();
file_put_contents('capture.mp4', $shotsmith->animate($options));
// In Laravel: Shotsmith::take($options) with SHOTSMITH_ACCESS_KEY in .env
curl -G "https://shotsmith.dev/v1/animate" \ --data-urlencode "access_key=YOUR_ACCESS_KEY" \ --data-urlencode "url=https://shotsmith.dev/sample" \ --data-urlencode "format=mp4" \ --data-urlencode "duration=6" \ --data-urlencode "scroll_easing=ease_in_out_quint" \ --data-urlencode "block_cookie_banners=true" \ -o capture.mp4
import { writeFile } from 'node:fs/promises';
const params = new URLSearchParams({
access_key: 'YOUR_ACCESS_KEY',
url: 'https://shotsmith.dev/sample',
format: 'mp4',
duration: '6',
scroll_easing: 'ease_in_out_quint',
block_cookie_banners: 'true',
});
const res = await fetch(`https://shotsmith.dev/v1/animate?${params}`);
if (!res.ok) throw new Error((await res.json()).error_message);
await writeFile('capture.mp4', Buffer.from(await res.arrayBuffer()));
import urllib.request
from urllib.parse import urlencode
params = {
"access_key": "YOUR_ACCESS_KEY",
"url": "https://shotsmith.dev/sample",
"format": "mp4",
"duration": "6",
"scroll_easing": "ease_in_out_quint",
"block_cookie_banners": "true"
}
url = "https://shotsmith.dev/v1/animate?" + urlencode(params, doseq=True)
# Raises urllib.error.HTTPError on a 4xx/5xx response
with urllib.request.urlopen(url, timeout=120) as res, open("capture.mp4", "wb") as f:
f.write(res.read())
<?php
$query = http_build_query([
'access_key' => 'YOUR_ACCESS_KEY',
'url' => 'https://shotsmith.dev/sample',
'format' => 'mp4',
'duration' => '6',
'scroll_easing' => 'ease_in_out_quint',
'block_cookie_banners' => 'true',
], '', '&', PHP_QUERY_RFC3986);
$ch = curl_init('https://shotsmith.dev/v1/animate?' . $query);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($status !== 200) {
throw new RuntimeException(json_decode($body, true)['error_message'] ?? "HTTP {$status}");
}
file_put_contents('capture.mp4', $body);
package main
import (
"io"
"net/http"
"os"
)
func main() {
res, err := http.Get("https://shotsmith.dev/v1/animate?access_key=YOUR_ACCESS_KEY&url=https%3A%2F%2Fshotsmith.dev%2Fsample&format=mp4&duration=6&scroll_easing=ease_in_out_quint&block_cookie_banners=true")
if err != nil {
panic(err)
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
body, _ := io.ReadAll(res.Body)
panic(string(body))
}
out, err := os.Create("capture.mp4")
if err != nil {
panic(err)
}
defer out.Close()
io.Copy(out, res.Body)
}
require "net/http"
require "uri"
uri = URI("https://shotsmith.dev/v1/animate")
uri.query = URI.encode_www_form([
["access_key", "YOUR_ACCESS_KEY"],
["url", "https://shotsmith.dev/sample"],
["format", "mp4"],
["duration", "6"],
["scroll_easing", "ease_in_out_quint"],
["block_cookie_banners", "true"]
])
res = Net::HTTP.get_response(uri)
raise res.body unless res.is_a?(Net::HTTPSuccess)
File.binwrite("capture.mp4", res.body)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Path;
public class Capture {
public static void main(String[] args) throws Exception {
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create(
"https://shotsmith.dev/v1/animate?access_key=YOUR_ACCESS_KEY&url=https%3A%2F%2Fshotsmith.dev%2Fsample&format=mp4&duration=6&scroll_easing=ease_in_out_quint&block_cookie_banners=true"
)).build();
var res = client.send(request, HttpResponse.BodyHandlers.ofFile(Path.of("capture.mp4")));
if (res.statusCode() != 200) {
throw new RuntimeException("HTTP " + res.statusCode());
}
}
}
using System;
using System.IO;
using System.Net.Http;
using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(120) };
// Throws HttpRequestException on a 4xx/5xx response
var bytes = await http.GetByteArrayAsync(
"https://shotsmith.dev/v1/animate?access_key=YOUR_ACCESS_KEY&url=https%3A%2F%2Fshotsmith.dev%2Fsample&format=mp4&duration=6&scroll_easing=ease_in_out_quint&block_cookie_banners=true"
);
await File.WriteAllBytesAsync("capture.mp4", bytes);
Content-Type: video/mp4
X-Capture-Id: 01m8kvpk6jsmeykdfs0wy6awbn
X-Cache: MISS
X-Render-Time: 6895
X-Quota-Limit: 15000
X-Quota-Remaining: 14998
X-RateLimit-Limit: 80
X-RateLimit-Remaining: 79
(the MP4 video)
Videos up to 10 seconds come back in the response, as above. Longer videos, up to 30 seconds, take longer to record and encode than a synchronous request allows, so add async=true and collect the file from the status URL or a webhook.
The default scenario scrolls to the bottom with the chosen easing curve and back up. Set scroll_back=false to stop at the bottom, or scroll_complete=false with scroll_by to scroll a fixed distance. scenario=default records without scrolling, which suits animated pages.