API documentation

Our API currently offers one method. Parameters can be sent as HTTP-GET parameters, HTTP-POST parameters and you can use the SOAP interface. Scroll down for example code in PHP and C#.

The SOAP interface returns the images base64 encoded.

You should save the image locally on your webserver or application server. You may not hot link directly to our API: this will expose your API key and it will stress our servers unintentionally.

We have added complete tutorial on how to set up a simple project using the thumbnail.ws API. See the Website PHP screenshots tutorial.

Mashape

url
The URL of the website you want to capture. E.g. http://www.reddit.com/ or https://www.google.com/
width
The width of the image. E.g. 400.
delay
How long should thumbnail.ws wait after the page has loaded to create a screenshot. Value must be given in milliseconds between 0 and 5000. Default is 2500, (2.5 second). E.g. 3000
fullpage (Premium only)
Return the full page and not only the part above the fold. An endless page can result in a very large image. E.g. true
mobile (Premium only)
Return the mobile version by setting the width of the screen to 640 and identify ourselves as an iPhone. E.g. true
format (Premium only)
Set the image format. Currently JPEG (default) and PNG are supported.
refresh (Premium only)
Deliver a fresh screenshot even if a cached version is available. E.g. true

The full HTTP url could be:

https://api.thumbnail.ws/api/YOUR-FREE-API-KEY/thumbnail/get?url=http://www.google.com/&width=640

Replace YOUR-FREE-API-KEY with the key we sent you.

PHP Code example GET

<?php
//--- Set the parameters --------------//
$url    = "http://www.google.com/";
$apikey = "YOUR-FREE-API-KEY";
$width  = 640;
//--- Make the call -------------------//
$fetchUrl = "https://api.thumbnail.ws/api/".$apikey ."/thumbnail/get?url=".urlencode($url)."&width=".$width;
$jpeg = file_get_contents($fetchUrl);
//--- Do something with the image -----//
/* file_put_contents("screenshot.jpg", $jpeg); */
header("Content-type: image/jpeg");
echo $jpeg;
exit(0);
?>

PHP Code example POST

<?php
//--- Set the parameters --------------//
$url    = "http://www.google.nl/";
$apikey = "YOUR-FREE-API-KEY";
$width  = 640;
//--- Make the call -------------------//
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.thumbnail.ws/api/' . $apikey . '/thumbnail/get');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
  'url' => $url,
  'width' => $width,
  'fullpage' => 'false'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$jpeg = curl_exec($ch);
curl_close($ch);
//--- Do something with the image -----//
/* file_put_contents("screenshot.jpg", $jpeg); */
header("Content-type: image/jpg");
echo $jpeg;
exit(0);
?>

PHP Code example SOAP

WSDL file can be found at: https://api.thumbnail.ws/soap?wsdl

<?php
$client = new SoapClient('https://api.thumbnail.ws/soap?wsdl');
try {
  $response = $client->get(array(
    "apikey" => 'YOUR_API_KEY', 
    "url" => 'http://thumbnail.ws/', 
    "width" => 800, 
    "fullpage" => false,
    "mobile" => false
  ));
  $image = base64_decode($response->image);
  
  // do something with the image. 
  // ...
  // ...
    
} catch (SoapFault $fault) {
  echo "Error: " . $fault->faultcode . ": " . $fault->getMessage() . "\n";
}

C# Code example GET

/**
 * Create a new project and add a
 *  TextBox
 *  Label
 *  Button
 *  PictureBox
 * to the form
 */
using System;
using System.Net;
using System.Windows.Forms;
using System.IO;
using System.Drawing;
namespace ThmbnailExample
{
    public partial class Form1 : Form
    {
        public Form1() { InitializeComponent(); }
        private void button1_Click(object sender, EventArgs e)
        {
            const string API_KEY = "YOUR-FREE-API-KEY";
            label1.Text = "Fetching thumbnail ...";
            // Create HTTP-GET webclient
            string url = "https://api.thumbnail.ws/api/" + API_KEY + "/thumbnail/get" +
                         "?url=" + this.textBox1.Text +
                         "&width=" + pictureBox1.Width;
            try
            {
                WebRequest request = WebRequest.Create(url);
                // Get the response.
                WebResponse response = request.GetResponse();
                // Display the status.
                label1.Text = (((HttpWebResponse)response).StatusDescription);
                // Get the stream containing content returned by the server.
                Stream dataStream = response.GetResponseStream();
                // Read the content.
                var image = Image.FromStream(dataStream);
                pictureBox1.Image = image;
                // Clean up
                response.Close();
            }
            catch (Exception ex)
            {
                label1.Text = ex.Message;
            }
        }
    }
}

C# Code example SOAP

Create a form with a TextBox, a Button and a PictureBox. Add a service reference and enter the WSDL url: https://api.thumbnail.ws/soap?wsdl. Update app.config to set the readerQuotas maxStringContentLength to 5000000. Then you are good to go.

using System;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
namespace ThumbnailSoap
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var client = new ServiceReference1.getSoapClient();
                
                string image;
                client.get(
                    "0000000000000000000000000000000000000",
                    textBox1.Text,
                    pictureBox1.Width,
                    "true",
                    out image);
                //--- Decode base64 image 
                byte[] imageData = Convert.FromBase64String(image);
                //--- Set image in pictureBox
                pictureBox1.Image = new Bitmap(new MemoryStream(imageData));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
    }
}

curl example

curl "https://api.thumbnail.ws/api/YOUR-FREE-API-KEY/thumbnail/get?url=http%3A%2F%2Fwww.google.com%2F&width=320"