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",
  everyNHours: 8,
  deviceName: "Desktop"
})
console.log(page)

And this is the created page:

{
  "id": "11111",
  "name": "Example",
  "url": "http://example.com/",
  "region": "germany",
  "everyNHours": 8,
  "device": {
    "id": "22222",
    "name": "Desktop",
    "rtt": 40,
    "bandwidthKbps": 8192,
    "formFactor": "desktop",
    "cpuThrottling": 1
  }
}

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",
        "everyNHours": 8,
        "device": {
          "id": "25321",
          "name": "Mobile",
          "rtt": 150,
          "bandwidthKbps": 1638,
          "formFactor": "mobile",
          "cpuThrottling": 4
        }
      }
    ]
  }
]  

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)

Still need help? Contact matt@debugbear.com for support.
DebugBear is a website monitoring tool built for front-end developers. Track performance metrics and Lighthouse scores in CI and production. Learn more.
© 2020 DebugBear Ltd