Documentation

    Amazon Web Services

    Microsoft Azure

    RapidAPI

    APILayer

Last Update: 2024-10-22

Website Screenshot API


Table of Content


Subscribe on Azure Marketplace
Code samples
API endpoint: Screenshot
API endpoint: Usage
Troubleshooting

Subscribe at Azure Marketplace


Visit our listings page on the Azure Marketplace and click on 'Get It Now'.

In the Azure portal, choose the Pay-As-You-Go plan and click on 'Subscribe'.

Select a resource group, give the subscription an internal name, and click on 'Review + subscribe'.

Click on 'Subscribe' to finalize your subscription.

Begin creating your account on our platform by clicking on 'Configure account now'.

You will be directed to the registration page. Here, fill in your account details in the provided fields. After entering all necessary information, click on 'Subscribe' to proceed.

Upon successful registration, your unique API key will be displayed. It is crucial to store this key in a secure location for future use.

Code samples


The following documentation page outlines how to use the API endpoint to capture a full page screenshot of a webpage at https://www.silverlining.cloud. Replace <YourApiKey> with the actual API Key you received during the sign-up process:

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api-azr.silverlining.cloud/screenshot/take-screenshot");
request.Headers.Add("Ocp-Apim-Subscription-Key", "<YourApiKey>");
var content = new StringContent("{\n    \"url\": \"http://www.silverlining.cloud\",\n    \"wait\": 1,\n    \"full_page\": true\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Take Screenshot Endpoint Playground

This API Playground for our Website Screenshot API allows you to experience the service in real-time. Simply provide a website URL, along with optional parameters, and receive a direct link to the captured screenshot from the API. Whether you’re integrating screenshots into your application, creating a visual archive, or just testing out the service, the playground offers an easy-to-use interface to view real-time responses instantly.

"To see the result, please send a request to the API."
API endpoint: /screenshot


URL endpoint: https://api-azr.silverlining.cloud/screenshot/take-screenshot


Method: POST


"header": {
  "Ocp-Apim-Subscription-Key": STRING,
  "Content-Type": "application/json"
}


"body": {
  "url": STRING,
  "wait": NUMBER,
  "full_page": BOOLEAN,
  "browser_size": STRING,
  "execute_js": STRING,
  "screenshot_element": STRING,
  "screenshot_crop_box": STRING,
  "return_as_file": BOOLEAN
}



Required

"url": The URL of the webpage for which you want to capture a screenshot. Include the protocol (http, https).

 
Optional

"wait": Specify the number of seconds to wait before capturing the screenshot. This can be useful for waiting for lazy-loading elements. The value must be between 1 and 10 seconds. The default is 0.

 "full_page": Set to true if you want to capture a screenshot of the entire page instead of just the viewport. The default is false.

"browser_size": Define the browser size for the screenshot. The default is "1920x1080".

"execute_js": Provide JavaScript code to execute before capturing the screenshot. The default is an empty string.

"screenshot_element": Specify the website element using XPath syntax (e.g., '//header') for which the screenshot should be taken, instead of capturing the entire browser viewport.

"screenshot_crop_box": Define a box to crop the taken screenshot by providing X and Y coordinates along with the width and height of the box. The format should be "X, Y, width, height" (e.g., "100,200,500,400").

"return_as_file": Set to true to receive the screenshot as a base64-encoded string instead of a URL to the screenshot. The default value is false.

Response:


"body": {
  "screenshot_url": STRING,
  "input_data":{
    "url": STRING,
    "wait": NUMBER,
    "full_page": BOOLEAN,
    "browser_size": STRING,
    "execute_js": STRING,
    "screenshot_element": STRING,
    "screenshot_crop_box": STRING,
    "return_as_file": BOOLEAN
   }
}

"screenshot_url": The API response will provide a link to the captured screenshot. The screenshot will be stored for one year, allowing you to access and utilize it as needed during that time.

API endpoint: /usage


URL endpoint: https://api-azr.silverlining.cloud/screenshot/usage


Method: POST


"header": {
  "Ocp-Apim-Subscription-Key": STRING,
  "Content-Type": "application/json"
}



Required

You must include the API key in the Ocp-Apim-Subscription-Key header. The body parameters can be left empty.

Response:


"body": {
  "reportUrl": STRING,
  "downloadLink": STRING,
  "description": STRING
}

"reportUrl": A URL linking to a web-based report that displays all requests made to the API. Note that this report is only accessible if the total number of requests is below 100,000.

"downloadLink": A URL to download a .CSV file containing all requests made to our API using the specified API key.

"description": You can access usage statistics either by visiting the website using the 'reportUrl' or by downloading the usage data as a .csv file using the 'downloadLink'. Please note that, depending on the number of requests you have previously sent to our API, these links may become available up to 10 minutes after the request is made.

Troubleshooting

"message": "Invalid Input: The request contains incorrectly formatted parameters"

This error message means that the body parameters you have passed are malformed. Please follow the instructions given in the endpoint descriptions. Common issues include forgetting to add a comma (',') after every parameter line or missing a parenthesis somewhere.

Receiving 503 "The service is unavailable."

You may occasionally encounter the error message: "503 - The service is unavailable." This issue is temporary and typically resolves on its own. It is a problem originating from Microsoft Azure APIM platform and not from our service. Unfortunately, there is nothing we can do on our end to prevent it. We apologize for any inconvenience this may cause.