> For the complete documentation index, see [llms.txt](https://docs.nexthink.com/platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nexthink.com/platform/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/api-and-integrations-classic/other-integrations-classic/software-metering-api-classic.md).

# Software Metering API (classic)

## Overview <a href="#softwaremeteringapi-classic-overview" id="softwaremeteringapi-classic-overview"></a>

To integrate program usage data with external systems, Portal provides an API to query the [historical details of Software Metering](/platform/user-guide/custom-dashboards-classic/assessing-license-use-classic.md#assessinglicenseuse-classic-interpretingtheresultsofsoftwaremeteringmetrics) dashboards.

The client of the *Software Metering API* must trust the certificate in the primary Appliance (Portal).

To authenticate the client, the Software Metering API uses Basic Authentication. Nexthink recommends creating a local account to exclusively authenticate clients of the API.

## Finding out available metrics <a href="#softwaremeteringapi-classic-findingoutavailablemetrics" id="softwaremeteringapi-classic-findingoutavailablemetrics"></a>

To interactively look for Software Metering data that is available through the API:

1. Point a web browser to the following address:

   ```
   https://<Portal_DNS_FQDN>/api/softwaremetering/v1​
   ```

   * Substitute `<Portal_DNS_FQDN>` for the actual name of Portal.
2. Log in to the discovery tool of the Software Metering API as a user with the right to see software metering metrics (either because the user can see all metrics or because the associated software metering module is included in the roles of the user).
   * Type in the user credentials whenever asked by the web browser.
   * The discovery tool displays only the available metrics in the [view domain of the user](https://github.com/nexthink/documentation.online/blob/review/docs/Establishing-a-privacy-policy/README.md#limiting-the-view-to-a-domain_94994462.md).
3. Select a metric from the table.
4. Select an available hierarchy.
5. Optional: Select a program to restrict the output to a particular program.
6. Optional: Select a node (below **Path**) to restrict the output to a node of the hierarchy. Repeat for each level of the hierarchy.
7. Get the metric details for the entities where the package is installed or where the program is under usage and *format* is one of table (for an HTML table), csv, or json:
   * **Installed** *(format)*
   * **Underusage** *(format)*

Once you have reached the desired details of the metric, note down the URL built by the discovery tool to programmatically query the API later with the same request or use it as a base for your own requests.

## Querying the API <a href="#softwaremeteringapi-classic-queryingtheapi" id="softwaremeteringapi-classic-queryingtheapi"></a>

To query the Software metering API, send a GET request to a URL that includes the following parameters:

| Parameter | Description                                                                                                                                | Default value                                   |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------- |
| metric    | UID of the desired metric                                                                                                                  | (none)                                          |
| hierarchy | Name of a hierarchy                                                                                                                        | The name of the first hierarchy in Portal       |
| program   | UID of the program to measure (binary object)                                                                                              | (none)                                          |
| list      | <p>Type of to list in the output:</p><ul><li>installed</li><li>underusage</li></ul>                                                        | installed                                       |
| path      | Name of a node in the hierarchy to limit the output. Chain several path elements to limit the output further down in the hierarchy levels. | The highest node in the view domain of the user |
| format    | <p>Output format, one of:</p><ul><li>table (for an HTML table)</li><li>json</li><li>csv</li></ul>                                          | table                                           |

Example of a query URL:

```
https://<Portal_DNS_FQDN>/api/softwaremetering/v1/details?​
metric=52fa2b8b-b35e-4d7a-9db3-830617c5b6b2&​
hierarchy=DefaultHierarchy&​
program=8b37ddb4-29fe-469a-bdc0-ca3497d7c7f9&​
list=installed&​
path=Europe&path=Switzerland&path=Lausanne&​
format=json
```

\
The Software Metering API uses Basic Authentication. To test the API from a Nexthink appliance, you can use `curl`, for instance:

```
curl https://<Portal_DNS_FQDN>/api/softwaremetering/v1/details?... -u username:password
```

## Output of the Software Metering API <a href="#softwaremeteringapi-classic-outputofthesoftwaremeteringapi" id="softwaremeteringapi-classic-outputofthesoftwaremeteringapi"></a>

The output of the API is similar to the [details of Software Metering metrics](/platform/user-guide/custom-dashboards-classic/assessing-license-use-classic.md#assessinglicenseuse-classic-interpretingtheresultsofsoftwaremeteringmetrics) that you can explore in Portal. Two data fields are exclusively found on the API, though:

* Entity
* First date with package

Find below the complete list of outputs of the Software Metering API:

| Output data                     | Description                                                                                                                                                                                                                                                                                          |
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Device                          | The name of a device that has at least one of the packages installed.                                                                                                                                                                                                                                |
| Entity                          | The name of the entity to which the device belongs.                                                                                                                                                                                                                                                  |
| Average usage per day (seconds) | The average usage per day of significant binaries on the device, expressed in seconds.                                                                                                                                                                                                               |
| Average executions per day      | The average number of executions per day of significant binaries on the device.                                                                                                                                                                                                                      |
| First date with package         | The date of first detection of the earliest detected package on the device.                                                                                                                                                                                                                          |
| Last activity                   | The date of last activity of the latest executed significant binary on the device.                                                                                                                                                                                                                   |
| Binaries                        | Lists the binaries that where used on the device. It is either a collection of the binaries used (output in *json* format), or a list of the significant binaries followed by **yes**, if the binary was actually used, and **no**, if the binary was not used (output in *table* or *csv* formats). |

***

RELATED TASKS

* [Assessing license use](/platform/user-guide/custom-dashboards-classic/assessing-license-use-classic.md)

RELATED REFERENCES

* [Establishing a privacy policy](https://github.com/nexthink/documentation.online/blob/review/docs/Establishing-a-privacy-policy_94994462.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.nexthink.com/platform/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/api-and-integrations-classic/other-integrations-classic/software-metering-api-classic.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
