Python Nexthink
This Python library provides a small client for the Nexthink API.
Installation
pip install nexthink_api
# or
uv add nexthink_api
Source And Documentation
Quickstart
The recommended entrypoint for new code is NexthinkClient. The historical
NxtApiClient remains available as a compatibility facade.
The examples below assume these environment variables are set:
export nexthink_tenant="your-tenant-name"
export nexthink_region="eu"
export client_id="your-client-id"
export client_secret="your-client-secret"
When running behind a corporate proxy with TLS inspection, for example Zscaler,
call enable_truststore() before creating the client. This enables the
operating system trust store for Nexthink HTTP calls without permanently
patching Python SSL for the whole process.
import os
from nexthink_api import NexthinkClient, NxtRegionName, enable_truststore
enable_truststore()
client = NexthinkClient(
os.environ["nexthink_tenant"],
NxtRegionName(os.getenv("nexthink_region", NxtRegionName.eu.value)),
client_id=os.environ["client_id"],
client_secret=os.environ["client_secret"],
)
NQL Execute
The NQL query must already exist in Nexthink Administration as an API query.
import os
from nexthink_api import NxtNqlApiExecuteRequest
request = NxtNqlApiExecuteRequest(
queryId=os.environ["nexthink_nql_query_id"],
)
response = client.nql.execute(request, version="v2")
print(response.rows)
print(response.data)
Enrichment
This example updates one custom device field for one device identified by name.
import os
from datetime import datetime
from nexthink_api import (
MAX_ENRICHMENTS_PER_REQUEST,
NxtEnrichment,
NxtEnrichmentRequest,
NxtField,
NxtFieldName,
NxtIdentification,
NxtIdentificationName,
)
identification = NxtIdentification(
name=NxtIdentificationName.DEVICE_DEVICE_NAME,
value=os.environ["nexthink_enrichment_device_name"],
)
field = NxtField(
name=NxtFieldName.CUSTOM_DEVICE,
custom_value="nexthink_api_example",
value=datetime.now().isoformat(),
)
enrichments = [NxtEnrichment(identification=[identification], fields=[field])]
if len(enrichments) > MAX_ENRICHMENTS_PER_REQUEST:
raise ValueError("Too many enrichment objects for one request")
request = NxtEnrichmentRequest(
domain=os.getenv("nexthink_enrichment_domain", "nexthink_api_example"),
enrichments=enrichments,
)
response = client.enrichment.run(request)
print(response)
Data Management Device Deletion
The Data Management deletion API is asynchronous and destructive. Keep an explicit confirmation in scripts and validate identifiers before calling it.
import os
from nexthink_api import NxtDeviceEntry, NxtUidValidationMode
if os.getenv("confirm_data_management_delete") != "yes":
raise SystemExit("Set confirm_data_management_delete=yes before deleting devices.")
devices = [
NxtDeviceEntry(
uid=os.environ["nexthink_device_uid"],
name=os.environ["nexthink_device_name"],
)
]
response = client.data_management.delete_devices(
devices=devices,
request_id=os.environ["nexthink_request_id"],
uid_validation=NxtUidValidationMode.WARN,
)
print(response)
Examples
Runnable examples are available in examples/:
uv run python examples/nql_query_example.py
uv run python examples/enrichment_example.py
uv run python examples/data_management_device_deletion_example.py
uv run python examples/remote_actions_example.py
uv run python examples/campaigns_example.py
uv run python examples/workflows_example.py
uv run python examples/spark_handoff_example.py
API Classes
Most request and response classes are Pydantic models. Use:
model_dump()to serialize to a dictionary.model_dump_json()to serialize to JSON.model_validate(data)to build a model from serialized data.
Metadata
Release files for nexthink_api 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nexthink_api-0.1.5.tar.gz | 174.9 kB | Without provenance | Details for nexthink_api-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nexthink_api-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for nexthink_api-0.1.5-py3-none-any.whl |
Total release size: 254.6 kB
Release files / nexthink_api-0.1.5.tar.gz
| Download URL | nexthink_api-0.1.5.tar.gz |
|---|---|
| Size | 174.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
40605ade605a614ba77368c39edcff62fb49e2fe9043a16b99c5c8c10ad1aa45
|
|
BLAKE2b-256 checksum How to use checksums |
acd84ce2eccad82c83526843f19b424311d99abfe5d55a4d1b811d1f66438137
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / nexthink_api-0.1.5-py3-none-any.whl
| Download URL | nexthink_api-0.1.5-py3-none-any.whl |
|---|---|
| Size | 79.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
50bffeb0d8cdc88fdd8f1be8233b55c052ffc70dfc77c43a2c0dd9e32f53dd7f
|
|
BLAKE2b-256 checksum How to use checksums |
dd4c91c5ed5f7160920e1c79bc2f36924e37fa691788d3f21d191ea1755d5897
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for nexthink_api 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.