Skip to content

Simple Script that illustrates how to use the Websiteshot API

Notifications You must be signed in to change notification settings

websiteshot/simple-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation


Never spend time again to create awesome screenshots of your websites.


Simple Script

Simple Script to use the Websiteshot API.

Available Options

-h, --help      Print this help and exit
-v, --verbose   Print script debug info
-p, --project   Argument: ProjectId
-a, --apikey    Argument: API Key
-t, --template  Argument: TemplateId
-j, --job       Argument: JobId
-w, --website   Argument: URL of Website
-vw, --width    Argument: Width of View
-vh, --height   Argument: Height of View
-c, --create    Creates a new Screenshot Job
-g, --get       Get needed data for JobId
-d, --download  Download first Screenshot of Job

Prerequisites

You need a Project at Websiteshot and an API Key. Set both as environment variables:

export PROJECT=...
export APIKEY=...

If you want to trigger a Screenshot by Template Id add an environment variable for the template:

export TEMPLATE=...

The Script uses cURL and jq. Both tools need to be installed on your system.

Example

Create a new Screenshot

./simple-script.sh -a $APIKEY -p $PROJECT -c

Or by Template Id:

./simple-script.sh -a $APIKEY -p $PROJECT -t $TEMPLATE -c

The Script executes the follwing cURL command:

curl -H 'Authorization: '"${apikey}"'' -H "Content-Type: application/json" -d '{"screenshotParameter":{"width":'"${width}"', "height":'"${height}"'}, "urls":[{"url":"'"${website}"'", "name":"'"${website}"'"}]}' -X POST ${baseurl}/api/projects/${project}

Output:

Create Request for Project abcdef...
Project: abcdef...
Website: https://websiteshot.app
Job: abcdef...
Screenshot Url: unset
Width: 1200
Height: 720

Get a Screenshot

./simple-script.sh -a $APIKEY -p $PROJECT -j $JOBID -g

Output:

Get Request for Job abcdef... of Project abcdef...
Project: abcdef...
Website: https://websiteshot.app
Job: abcdef...
Screenshot Url: https://...
Width: 1200
Height: 720

Download Screenshot

./simple-script.sh -a $APIKEY -p $PROJECT -j $JOBID -d

About

Simple Script that illustrates how to use the Websiteshot API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages