Skip to main content

Managing projects and pages with the API

You can use the Node API to create and manage projects and pages on DebugBear.

Note that you'll need an Admin API key to do this, rather than a project-level API key.

Creating projects and pages

Use debugbear.projects.create to add a new project, then call createPage on the project.

const { DebugBear } = require("debugbear");
const debugbear = new DebugBear(process.env.DEBUGBEAR_API_KEY);

const project = await debugbear.projects.create({ name: "My project" });
const page = await project.createPage({
name: "Example",
url: "http://example.com/",
region: "germany",
testScheduleName: "Every 12 hours",
deviceName: "Desktop",
advancedSettings: ["Staging Basic Auth"],
tags: ["Tag 1"],
});
console.log(page);

And this is the created page:

{
"id": "11111",
"name": "Example",
"url": "http://example.com/",
"region": "germany",
"testSchedules": [
{
"id": "22222",
"name": "Every 12 hours",
"days": [0, 1, 2, 3, 4, 5, 6],
"times": []
}
],
"device": {
"id": "33333",
"name": "Desktop",
"rtt": 40,
"bandwidthKbps": 8192,
"formFactor": "desktop",
"cpuThrottling": 1
},
"advancedSettings": [
{
"id": "18",
"name": "Staging Basic Auth",
"type": "basicAuth"
}
],
"tags": ["Tag 1"]
}

Creating a project using curl

curl https://www.debugbear.com/api/v1/projects \
-X POST \
-H "x-api-key: API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Project Name"}'

The response will look like this:

{ "id": "123456", "name": "Project Name", "pages": [] }

Creating a page using curl

curl https://www.debugbear.com/api/v1/projects/123456/pages \
-X POST \
-H "x-api-key: API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Example Homepage", "url": "https://example.com", "region": "uk", "tags": ["homepage"]}'

Listing projects and pages

const projects = await debugbear.projects.list();

Response:

[
{
"id": 123456789,
"name": "My project",
"pages": [
{
"id": 999999,
"name": "Example",
"url": "http://example.com/",
"region": "germany",
"testSchedules": [
{
"id": "22222",
"name": "Every 12 hours",
"days": [0, 1, 2, 3, 4, 5, 6],
"times": []
}
],
"device": {
"id": "25321",
"name": "Mobile",
"rtt": 150,
"bandwidthKbps": 1638,
"formFactor": "mobile",
"cpuThrottling": 4
}
}
]
}
]

Using curl

curl https://www.debugbear.com/api/v1/projects \
-H "x-api-key: API_KEY"

Update pages

await debugbear.pages.update(PAGE_ID, {
tags: ["staging"],
advancedSettings: ["Staging Auth"],
});

Delete projects

const project = await debugbear.projects.create({ name: "My project" });
await project.delete();

Delete pages

const project = await debugbear.projects.create({ name: "My project" });
const page = await project.createPage({
name: "Example",
url: "http://example.com/",
});
await project.deletePage(page.id);

Valid test server regions

The following server regions are supported: australia, brazil, canada, finland, france, india, italy, israel, japan, germany, netherlands, poland, singapore, spain, qatar, southafrica, switzerland, taiwan, uk, us-east, us-central, us-ca, us-west