Get Class by ID

Returns the class with the specified ID.

Request

HTTP Request

GET /node/api/classes/:id

Path parameters

Parameter Type Description

id

String
required

The ID of the class to be retrieved.

Request body

The request body is empty.

Response

Returns the class in the JSON format. See the Class model page for more information.

Example

Request

  • Bash

  • JavaScript

  • NodeJS

  • Python

login=<...>
password=<...>
saymon_hostname=<...>
class_id=<...>
url=https://$saymon_hostname/node/api/classes/$class_id

curl -X GET $url -u $login:$password
let login = <...>
let password = <...>
let saymonHostname = <...>
let classID = <...>
let auth = "Basic " + btoa(login + ":" + password)
let path = "/node/api/classes/" + classID

let myHeaders = new Headers();
myHeaders.append("Authorization", auth);

let requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch(saymonHostname + path, requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
let http = require('follow-redirects').http;
let fs = require('fs');

let login = <...>
let password = <...>
let saymonHostname = <...>
let classId = <...>
let path = "/node/api/classes/" + classId;
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");

let options = {
  'method': 'GET',
  'hostname': '192.168.1.101',
  'path': '/node/api/classes/4',
  'headers': {
    'Authorization': auth
  },
  'maxRedirects': 20
};

let req = http.request(options, function (res) {
  let chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    let body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();
import requests

login = <...>
password = <...>
saymon_hostname = <...>
class_id = <...>
url = "http://" + saymon_hostname + "/node/api/classes/" + class_id

response = requests.request("GET", url, auth=(login, password))
print(response.text)

Response

{
    "id": 4,
    "name": "CPU",
    "category_id": 1,
    "description": "Central Processor Unit",
    "operations": []
}