# Is there any Cloud API can get metrics data from a specifed Node directly not via Agent API

**URL:** <https://community.netdata.cloud/t/is-there-any-cloud-api-can-get-metrics-data-from-a-specifed-node-directly-not-via-agent-api/6094>\
**Category:** Help\
**Tags:** cloud\
**Created:** [December 16, 2024, 12:40am UTC](https://community.netdata.cloud/t/is-there-any-cloud-api-can-get-metrics-data-from-a-specifed-node-directly-not-via-agent-api/6094 "2024-12-16T00:40:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael\_yue](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.netdata.cloud/michael_yue/32/4083_2.png) [@michael\_yue](https://community.netdata.cloud/u/michael_yue)\
**Post date:** [December 16, 2024, 12:40am UTC](https://community.netdata.cloud/t/is-there-any-cloud-api-can-get-metrics-data-from-a-specifed-node-directly-not-via-agent-api/6094/1 "2024-12-16T00:40:38Z")

</div>

For example  
I have a NetData cloud server  
under this server , there are there nodes in my room  
Now I want to get my node’s metrics data , for example CPU data of the node 1  
I need to call could API to get data directly not calling NetData Agent REST API

---

<div class="post-metadata">

**Author:** ![papazach](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.netdata.cloud/papazach/32/145_2.png) [@papazach](https://community.netdata.cloud/u/papazach)\
**Post date:** [December 16, 2024, 10:06am UTC](https://community.netdata.cloud/t/is-there-any-cloud-api-can-get-metrics-data-from-a-specifed-node-directly-not-via-agent-api/6094/2 "2024-12-16T10:06:20Z")

</div>

Hello @michael_yue 👋 ,

Thanks for reaching out.

Yes there is an API you can use, will try to provide some quick guide below on how to authenticate and build your `/data` requests targeting a node.

# Authentication

You will first need to issue a Bearer token that will be placed in the value of your HTTP request’s `Authorization` header like this:

`Authorization: Bearer <your_bearer_token>`

To create such a token on behalf of your Netdata Cloud account you will need to go to:

1. Your `Account Settings` (by clicking on your account thumbnail on the bottom left)
2. Then click on `Settings`
3. Then click on `API tokens` on the right-hand side drawer
4. Click the ➕ icon to create a new Token, select `scope:all` and a enter a description of your choice.

  

 ![Screenshot 2024-12-16 at 11.15.43 AM](https://canada1.discourse-cdn.com/flex029/uploads/netdata2/original/2X/5/5bf1ac261b006ba7a5ca95300e38fb1d62e23ec3.png)  
 ![Screenshot 2024-12-16 at 11.14.48 AM](https://canada1.discourse-cdn.com/flex029/uploads/netdata2/original/2X/6/6a1f83a3d49214c040885a47bd89d9ff309183bc.png)  
 ![Screenshot 2024-12-16 at 11.14.58 AM](https://canada1.discourse-cdn.com/flex029/uploads/netdata2/original/2X/8/8f36385f7cb9fa4bb4f21984668c3a2af62f1a2a.png)

# The HTTP request

With the following `POST` HTTP request you may request for data from a node (or a set of nodes) within a space and that your account has access to.

```bash
curl -v 'https://app.netdata.cloud/api/v3/spaces/{space_id}/rooms/{room_id}/data' \
  -H 'Authorization: Bearer <your_bearer_token_goes_here>' \
  -H 'Content-Type: application/json \
  --data-raw '<request_payload_goes_here'

```

- `space_id` : You may find that at your space settings (click on the ⚙ at the lower left corner and you may find it at the section `Info`
- `room_id` : It’s a bit trickier to find this one. The quickest way is to click on your `Metrics` tab and the open the network tab on your browser. Then check the `/data` calls that are being fired to populate your charts. You could quickly extract your `room_id` (and your `space_id` as well) from there. Both `space_id` and `room_id` are UUIDs.
- JSON request payload:

```json
{
  "format": "json2",
  "options": [
    "jsonwrap",
    "nonzero",
    "flip",
    "ms",
    "jw-anomaly-rates",
    "minify"
  ],
  "scope": {
    "contexts": [
      "system.cpu" <--- you can change this to target any other context you need
    ],
    "nodes": [
      "xxxxxxxxx" <--- here you may add your <node_id>
    ]
  },
  "selectors": {
    "contexts": [
      "*"
    ],
    "nodes": [
      "*"
    ],
    "instances": [
      "*"
    ],
    "dimensions": [
      "*"
    ],
    "labels": [
      "*"
    ]
  },
  "aggregations": {
    "metrics": [
      {
        "group_by": [
          "dimension"
        ],
        "group_by_label": [],
        "aggregation": "avg"
      }
    ],
    "time": {
      "time_group": "average",
      "time_resampling": 0
    }
  },
  "window": {
    "after": 1734340051,
    "before": 1734340951,
    "points": 461
  }
}

```

Regarding the `window` field this would be where you define the target time window for your data request.  
You could either pass in the `after` (\>=) or `before` (\<=) fields **unix** timestamps in **sec**.

You could also pass _relative_ _durations_ in sec. in there for example if you want to retrieve the last 15mins of a metric you can only pass the `before` field with a value of `-900`.

To retrieve the node\_id (a UUID) you actually want to target you can navigate to he `Nodes` tab in your Netdata Cloud space, click on the node you are interested in and then you can extract it from the URL bar of your browser as follows:

```auto
https://app.netdata.cloud/spaces/{your-space-slug}/rooms/{your-room-slug}/nodes/{here-is-your-node_id} ...

```

You should check the [Netdata Agent Swagger Documentation for the v2 Data Query](https://learn.netdata.cloud/api#/data/dataQuery2) to find more info about the rest of the fields in the payload.

Note that this is **not** official Netdata Cloud API documentation, it is for the Netdata Agent. But many concepts and payloads are applicable in both platforms and data queries are one of them.

* * *

We plan at some point to make things more straightforward concerning Netdata Cloud API usage and have proper docs on this but hopefully for now this will cover your needs.

Happy Monitoring!  
Costas
