With the Screenshot API, effortlessly capture website screenshots and seamlessly upload them directly to your Cloudflare R2 storage bucket. Simplify the task of generating screenshots in bulk from various URLs, sitemaps, text files, or even entire domains with automation. A single call to the Screenshot API empowers you to save valuable time and streamline the process by automatically transferring all your screenshots to your Cloudflare R2 storage.
This efficient workflow ensures your website screenshots are organized and easily accessible from a centralized location.
Cloudflare's R2 storage offers a secure and reliable solution for storing your screenshots, providing peace of mind that your data is safeguarded and readily available whenever you require it. Effortlessly capture website screenshots and seamlessly upload them to your Cloudflare R2 storage bucket with the Screenshot API, simplifying your workflow and enhancing accessibility.
Parameter | Required | Description |
---|---|---|
r2 | Required | The name of the bucket |
r2_account_id | Required | Your Cloudflare account ID. Refer to Cloudflare's Find zone and account IDs documentation. For example: https://YOUR_ACCOUNT_ID.r2.cloudflarestorage.com |
r2_access_id | Required | Your R2 Access ID (Secret Access ID). Refer to Cloudflare's R2 Authentication documentation. |
r2_access_key | Required | Your R2 Access Key (Secret Access Key). Refer to Cloudflare's R2 Authentication documentation. |
file | Optional | The name or pattern for the file without the extension The default is a unique identifier (see pattern examples) |
folder | Optional | The folder name or pattern for the file (see pattern examples) |
html | Optional | When set to true, the HTML markup will be uploaded too |
Login to Cloudflare and create a new bucket such as "my-demo-screenshots" from the R2 left side menu:
Create an API token such as "Add Screenshots API" with the "Object Read & Write" permission:
Record the Access Key ID, Secret Access Key and Account ID (from the URL):
The example below shows how to take a real-time website screenshot and store the image in an R2 bucket "my-demo-screenshots" in the "images" folder with the file name "website.png". The optional &html=true parameter will upload the "website.html" file to the R2 bucket as well.
// Line breaks added for readability https://api.addscreenshots.com/screenshots
?apikey=YOUR_API_KEY
&r2=my-demo-screenshots
&r2_account_id=1234567890qwertyuiopasdfgh
&r2_access_id=0987654321poiuytrewqlkjhgfdsa
&r2_access_key=000012345000012345000012345000012345000012345
&folder=images
&file=website
&html=true
&url=https://www.youtube.com
Your API key can be found on the API Keys page. Need an API Key? Sign up to get started.
For internal applications, replace YOUR_API_KEY with your own unique API Key.
For public facing websites or hotlinks, generate a signed URL.
The API response will include a link to the screenshot in your S3 bucket as shown below:
{ "success": true, "message": "Screenshots completed.", "storage_provider": "r2", "images": [ { "folder": "images", "file": "website.png", "request_url": "https://www.youtube.com", "page_url": "https://www.youtube.com/", "image_url": "https://my-demo-screenshots.1234567890qwertyuiopasdfgh.r2.cloudflarestorage.com/images/website.png", "html_url": "https://my-demo-screenshots.1234567890qwertyuiopasdfgh.r2.cloudflarestorage.com/images/website.html" } ] }
The folders and file names as they appear in R2 storage: