Skip to main content
Version: v2

Browserless GraphQL API

Aside from providing the default production-sfo.browserless.io domain for running sessions, Browserless also exposes a GraphQL API for other operations. This document goes over some critical queries, however there's more information and descriptions at the interactive GraphiQL interface located here.

info

The Graphql API only applies to Dedicated and Enterprise accounts.

Pressure

The pressure query shows how much load your instance(s) are under, and whether they can accept more traffic or not. This is real-time, so if you need to check if your instance can take more traffic you can do a request to check prior to running your puppeteer.connect call.

warning

The pressure queries are still in BETA and may experience breaking schema changes.

# https://api.browserless.io/graphql
{
pressure(apiToken: "YOUR-API-TOKEN") {
running
recentlyRejected
queued
isAvailable
date
}
}

This request will return a JSON object with the following payload:

{
"data": {
"pressure": {
"running": 0,
"recentlyRejected": 0,
"queued": 0,
"isAvailable": true,
"date": 1524762532204
}
}
}

Metrics

The metrics query gives you insight to how your worker(s) are performing. It details things like successful, rejected, and timed-out sessions. Eventually this will be expanded to include things like average session-time and other helpful data-points.

Below is an example of a request for metrics and the responding payload.

warning

The metrics queries are still in BETA and may experience breaking schema changes.

# https://api.browserless.io/graphql
{
metrics(apiToken: "YOUR-API-TOKEN") {
successful
rejected
timedout
queued
cpu
memory
date
}
}

This request returns an array of object detailing the metrics of your instance(s). If there's more than one instance stats are aggregated together in 5-minute intervals. CPU and Memory are averaged accross instances.

{
"data": {
"metrics": [
{
"successful": 0,
"rejected": 0,
"timedout": 0,
"queued": 0,
"cpu": 0.002734375,
"memory": 0.9055320561641963,
"date": 1524227700000
},
//...
]
}
}

See More

There's a lot more you can do in the GraphQL API behind browserless, so be sure to check it out here!