> This page is for version Dev.
> For other versions, use one of these documentation indexes:
> - 3.3.0 (default): https://docs.nvidia.com/vss/3.3.0/llms.txt
> - Dev: https://docs.nvidia.com/vss/dev/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/vss/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/vss/_mcp/server.

# Get ROI occupancy histogram

GET https://ai.nvidia.com/api/v3.3/analytics/metrics/occupancy/roi/histogram

Aggregate region-of-interest occupancy into histogram buckets for a sensor using either an explicit time range or a relative lookback window.

Reference: https://docs.nvidia.com/vss/system-components/middleware/api-gateway-mcp/video-analytics-api/video-analytics-api-reference/metrics/controller-metrics-get-roi-histogram

## Request

### Query parameters

- `sensorId` (string, required)
- `roiId` (string, optional)
- `fromTimestamp` (datetime, optional) — This parameter must be used together with toTimestamp. However, it is not compatible with minutesAgo.
- `toTimestamp` (datetime, optional) — This parameter must be used together with fromTimestamp. However, it is not compatible with minutesAgo.
- `minutesAgo` (long, optional) — This parameter is not compatible with fromTimestamp and toTimestamp.
- `bucketCount` (long, optional, default: 20) — This parameter provided by user is a suggestion which will be taken into account while calculating bucket size in sec (which will be a multiple of 5). There is a possibilty that the result will have less/more buckets than the one provided in the input (i.e. it can go above 1000 buckets).
- `objectType` (string, optional)

## Response

### 200

Successful Operation.

- `bucketSizeInSec` (long, required)
- `rois` (list of RoiHistogramRoisItems, required)

## Errors

### 400 Bad Request Error

Bad Request. This response will be sent if any of the required params are not present or if extra params are passed. It will also be sent if parameter dependencies (mentioned in parameter descriptions) are not satisfied.

- `error` (string, required)

### 404 Not Found Error

Resource Not Found

- `error` (string, required)

### 422 Unprocessable Entity Error

Unprocessable Entity

- `error` (string, required)

### 500 Internal Server Error

Internal Server Error

- `error` (string, required)

## Types

### RoiHistogramRoisItems

- `id` (string, required)
- `histogram` (list of RoiHistogramRoisItemsHistogramItems, required)

### RoiHistogramRoisItemsHistogramItems

- `start` (datetime, required)
- `end` (datetime, required)
- `objects` (list of RoiHistogramRoisItemsHistogramItemsObjectsItems, required)

### RoiHistogramRoisItemsHistogramItemsObjectsItems

- `type` (string, required)
- `averageCount` (double, required)
- `uniqueObjectCount` (long, required)

## Examples

**Response**

```json
{
  "bucketSizeInSec": 1,
  "rois": [
    {
      "id": "hazard_zone_1",
      "histogram": [
        {
          "start": "2022-08-25T00:00:00.000Z",
          "end": "2022-08-25T00:00:10.000Z",
          "objects": [
            {
              "type": "Person",
              "averageCount": 1,
              "uniqueObjectCount": 2
            }
          ]
        }
      ]
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://ai.nvidia.com/api/v3.3/analytics/metrics/occupancy/roi/histogram"

querystring = {"fromTimestamp":"2022-08-25T00:00:00.000Z","roiId":"hazard_zone_1","sensorId":"sensorId","toTimestamp":"2022-08-25T00:00:10.000Z"}

response = requests.get(url, params=querystring)

print(response.json())
```

```javascript
const url = 'https://ai.nvidia.com/api/v3.3/analytics/metrics/occupancy/roi/histogram?fromTimestamp=2022-08-25T00%3A00%3A00.000Z&roiId=hazard_zone_1&sensorId=sensorId&toTimestamp=2022-08-25T00%3A00%3A10.000Z';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://ai.nvidia.com/api/v3.3/analytics/metrics/occupancy/roi/histogram?fromTimestamp=2022-08-25T00%3A00%3A00.000Z&roiId=hazard_zone_1&sensorId=sensorId&toTimestamp=2022-08-25T00%3A00%3A10.000Z"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://ai.nvidia.com/api/v3.3/analytics/metrics/occupancy/roi/histogram?fromTimestamp=2022-08-25T00%3A00%3A00.000Z&roiId=hazard_zone_1&sensorId=sensorId&toTimestamp=2022-08-25T00%3A00%3A10.000Z")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://ai.nvidia.com/api/v3.3/analytics/metrics/occupancy/roi/histogram?fromTimestamp=2022-08-25T00%3A00%3A00.000Z&roiId=hazard_zone_1&sensorId=sensorId&toTimestamp=2022-08-25T00%3A00%3A10.000Z")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://ai.nvidia.com/api/v3.3/analytics/metrics/occupancy/roi/histogram?fromTimestamp=2022-08-25T00%3A00%3A00.000Z&roiId=hazard_zone_1&sensorId=sensorId&toTimestamp=2022-08-25T00%3A00%3A10.000Z');

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://ai.nvidia.com/api/v3.3/analytics/metrics/occupancy/roi/histogram?fromTimestamp=2022-08-25T00%3A00%3A00.000Z&roiId=hazard_zone_1&sensorId=sensorId&toTimestamp=2022-08-25T00%3A00%3A10.000Z");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://ai.nvidia.com/api/v3.3/analytics/metrics/occupancy/roi/histogram?fromTimestamp=2022-08-25T00%3A00%3A00.000Z&roiId=hazard_zone_1&sensorId=sensorId&toTimestamp=2022-08-25T00%3A00%3A10.000Z")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```