Skip to content

AmreshSinha/sshot

Repository files navigation

label icon
Quick Start
rocket

Welcome to SSHOT

(/s:shot/)

SSHOT is a ✨ Web Screenshot API ✨ with caching kept in mind!

Just pass in the parameters for the screenshot, copy the link and you are good to go! 🚀

A screenshot is fetched using puppeteer and ✨ cached for 24 hours ✨. The expiry time will keep getting pushed forward if the file is being accessed frequently.


Quick start

You can call it from anywhere whether its a normal HTTP GET call from browser or a curl request from terminal

+++ HTTP GET

https://sshot.fossian.com/api?link=https://github.com

+++ cURL

curl "https://sshot.fossian.com/api?link=https://github.com" --output filename.png

+++ Wget

wget "https://sshot.fossian.com/api?link=https://github.com" -O filename.png

+++

If the request is not cached or expired, a new screenshot will be taken and a cache will stored as a record in redis database.

Cache will expire after 24 hours of inactivity 🗑️.


API Parameters

Endpoint: https://sshot.fossian.com/api?

Example: https://sshot.fossian.com/api?link=https://google.com&device=tablet

Parameter Description
link Link of the webpage whose screenshot you want to take. For long links URL Percent-Encoding is recommended.
Links should start with http(s)://
dimension Size of the website screenshot in format [width]x[height] .
Default dimension is 1920x1080 .
width can be any number between 100 and 1920 (both inclusive).
height can be any number between 100 and 1920 (both inclusive).
[!badge Default:] 1920x1080 pixels

Currently full length webpage screenshot is not implemented.
Will implement it soon don't worry! 😎

Examples:
360x800 - mobile dimension website 360x800 pixels
800x600 - website screenshot size 800x600 pixels
768x1024 - tablet dimension website 768x1024 pixels
1024x768 - website screenshot size 1024x768 pixels
1920x1080 - desktop dimension website 1920x1080 pixels
device Feeling lazy in providing a dimension?
You can just pass a device as a parameter for dimension.
These are the device params currently available: desktop, mobile and tablet .

[!badge variant="warning" text="Note"]
If dimension and device both are provided then dimension will be used and device will be ignored.
delay delay comes handy if the website has a lot animations. Using delay you can wait for the specified time and then take the screenshot after that.
[!badge Default:] delay is 200 ms.

Allowed range is between 0 and 5000 ms (both inclusive).

Error Messages

You may get a 400 Error Header and a Error 400 status message when you provide any parameter wrongly.

Error code Description
ERR_INVALID_LINK Link provided is not valid! Make sure it starts with http(s):// .
ERR_NO_LINK Link is not provided! Looks like you haven't provided any link at all!
ERR_INVALID_DIMENSION Dimension provided is not valid! Make sure the dimension are in range and in the format [width]x[height] .
ERR_INVALID_DEVICE Device provided is not valid! Make sure the device is desktop, mobile or tablet .
ERR_INVALID_DELAY Delay provided is not valid! Make sure the delay is in the range 0 to 5000 .
ERR_TIMEOUT Link provided took more than 10s to load and thus haulted and resulted in ERR_TIMEOUT