REST API
Device
Fetch devices

Fetch Devices

GET /v2/projects/{PROJECT_ID}/devices

Get the list of the device under the project corresponding to the project ID.

devices.ts
import type { NextApiRequest, NextApiResponse } from 'next';
 
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
const projectId = "your_project_id";
const apiKey = "your_api_key";
 
try {
    const result = await fetch(`https://api.qubitro.com/v2/projects/${projectId}/devices`, {
        headers: {
            "Authorization": `Bearer ${apiKey}`
        },
        method: "GET"
    });
 
    const data = await result.json();
    res.status(200).json(data);
} catch (error) {
    console.error(`Error: ${error}`);
    res.status(500).json({ message: 'Internal server error' });
}
}
Path Parameters
OptionTypeDescription
PROJECT_ID`String`The ID of the project.
Response
{
  "success": "boolean indicating the success of the request",
  "action": "description of the action taken by the server",
  "status": "HTTP status code",
  "message": "message from the server describing the result of the operation",
  "data": [
    {
      "id": "unique identifier of the device",
      "name": "name of the device",
      "description": "description of the device",
      "brand": "brand of the device",
      "model": "model of the device",
      "avatar": "URL of the device's avatar",
      "last_seen": "timestamp indicating when the device was last seen"
    }
  ]
}
Response codes
OptionTypeDescription
200OKThe request was successful.
400Bad RequestThe request could not be understood or was missing required parameters.
401UnauthorizedAuthentication failed or was not provided.
403ForbiddenAuthentication succeeded, but the authenticated user does not have access to the requested resource.
404Not FoundThe requested resource could not be found.
500Internal Server ErrorAn error occurred on the server.

logo

Start building today

Collect, process, and activate device data. Scale from one device to thousands.

Qubitro Logo

Product

Decision Aids

Resources

Company

© 2024 Qubitro, Inc. All rights reserved