Analyzing google.com
The EyeQuant API allows you to take screenshots of web pages, so analyzing the visible portion of web page by url can be triggered in a single API request:
curl \
-X POST \
-H "Authorization: Bearer $apikey" \
-H "Content-Type: application/json" \
-d '{
"input": {
"type": "webPageUrl",
"content": "http://www.google.com",
"medium": "desktopWeb",
"title": "Example"
}
}' \
https://api.eyequant.com/v2/analyses
cURL
This documentation uses the command-line tool cURL in all examples. It comes pre-installed on many systems and is available here.
What's going on here? Breaking it down:
- We are making a HTTP
POST
to the/v2/analyses
resource, authenticated with our API key (replace$apikey
with your credentials). - We are specifying that we are sending JSON data via the
Content-Type
header. - Our input for the analysis is a
webPageUrl
and the medium isdesktopWeb
.
This instructs the API to take a screenshot of www.google.com, simulating a desktop web browser, and to run an analysis on the result.
The API's response to this call looks like this:
HTTP/1.1 201 Created
...
Location: https://api.eyequant.com/v2/analyses/611457618c1d4283a830d10a9ad4f8ae
{
"location": "https://api.eyequant.com/v2/analyses/611457618c1d4283a830d10a9ad4f8ae",
"id": "611457618c1d4283a830d10a9ad4f8ae"
}
This informs us that the analysis has been accepted, a resource has been created to represent it, and that we can find it at the specified location.
We can follow the link to this resource find out more about the analysis:
curl \
-X GET \
-H "Authorization: Bearer $apikey" \
-H "Content-Type: application/json" \
https://api.eyequant.com/v2/analyses/611457618c1d4283a830d10a9ad4f8ae
Performing the screenshot and the analysis are both time-consuming, and it will usually take several seconds for them to complete.
While this is going on, the JSON representation of the analysis will look like this (omitting HTTP headers for brevity from now on):
{
"id": "611457618c1d4283a830d10a9ad4f8ae",
"status": "pending"
}
This means that the analysis exists under the specified id, and is currently waiting to be completed.
Once processing has completed and the results are available, the same request will return a response like this:
{
"id": "611457618c1d4283a830d10a9ad4f8ae",
"status": "success",
"outputs": {
"attention": {
"attentionMap": "https://s3.amazonaws.com/api-eyequant/attentionHeatmap.png"
}
}
Note how the status has changed to success
and the response includes a link specifying where we can download the resulting attention heatmap.
Updated about 1 month ago