Example Code
Code samples for taking website screenshots with Urlbox in Node.js, Ruby, Python, PHP, Java and C#, using the official SDKs or plain HTTP.
Urlbox is a plain HTTP API, so any language that can make an HTTPS request can use it. The official SDKs handle the two fiddly parts: signing render links with HMAC-SHA256, and calling the REST API with your secret.
There are three ways to call it:
- Render link — a signed URL that goes straight into an
<img>tag. - Sync render — wait for the render and get back a URL or the file.
- Async render — start the render and get the result by webhook or by polling.
Not sure which to use? Read Sync vs Async and REST API vs render links.
Samples by language
Node.js
The
urlbox NPM package, plus sync and async renders with fetch.Ruby
Sign render links with the Ruby standard library.
Python
The
urlbox PyPI package, with Django templates.PHP
The
urlbox/screenshots Composer package, with Laravel setup.Java
Sign render links in Java with
javax.crypto.C#
The
Urlbox.sdk.dotnet NuGet package for .NET.Any other language
You don't need an SDK. A sync render is a single authenticated POST:
curl -X POST https://api.urlbox.com/v1/render/sync \
-H "Authorization: Bearer YOUR_URLBOX_SECRET" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com", "full_page": true}'The response contains a renderUrl for the finished screenshot. The API reference covers every endpoint, and the Urlbox CLI runs the same renders from your terminal or CI.