PI Nexus+ / Reference
Public API Reference
This reference describes the public API other applications use to read PI Nexus+ health, objects, issues and data lineage, the event feed, and the webhooks that deliver it. The Administration Guide chapter Connect Other Applications links here; the complete field list of every response is in the OpenAPI document.
Overview
This reference describes the public API other applications use to read PI Nexus+ health, objects, issues and data lineage, the event feed, and the webhooks that deliver it. The Administration Guide chapter Connect Other Applications links here; the complete field list of every response is in the OpenAPI document.
Addresses and versions
| What | Address |
|---|---|
| Base address | https://<PI Nexus+ server>/api/v1, the address users open PI Nexus+ with, followed by /api/v1 |
| OpenAPI document | https://<PI Nexus+ server>/api/v1/openapi.json, for any valid API key or a Windows user with the Viewer role, also while the public API is off |
| Switch | Admin > Integrations; off by default. While off, every /api/v1 request gets 404 not_enabled and webhooks are not sent |
Within v1, PI Nexus+ only adds: optional fields, event types, values of existing fields, and endpoints. Clients must ignore fields and values they do not know. A change that would break a client comes as /api/v2, with v1 kept for at least 12 months.
Authentication and scopes
Send an API key in the Authorization header: Authorization: Bearer pnx_<key id>_<secret>. Keys are created under Admin > Integrations; the key is shown once, and PI Nexus+ stores only a hash of it. A Windows user with the Viewer role can also call /api/v1 with Windows authentication, with every scope and for every site.
| Scope (Can read) | Endpoints |
|---|---|
health:read (Health and issues) | /health, /health/history, /sites, /servers, /issues |
inventory:read (Objects and servers) | /objects |
lineage:read (Lineage) | /lineage |
events:read (Event feed) | /events |
A key limited to one site sees only that site's objects, issues, servers, history and events. It gets 403 site_scope when it asks for another site, and on /health, which is estate-wide (it reads its site from /sites). A revoked or expired key gets 401 at once.
Requests and responses
| Rule | Detail |
|---|---|
| Format | JSON, field names in camelCase, times in ISO 8601 UTC, ids as strings |
| Paging | limit 1 to 1000, 200 when omitted. A page carries items and nextCursor; pass nextCursor as cursor, with the same filters, for the next page. No nextCursor means the last page. There is no total count |
| Rate limit | 600 requests a minute per API key (per address for Windows callers). The event feed, and lineage with depth above 2, allow 60 a minute. Above a limit: 429 rate_limited with Retry-After in seconds. A request with a rejected key counts against its address, not against the key it names |
| Licence | A licence that does not allow operational access: 403 license_not_operational. An Evaluation licence: /health, /health/history, /sites, /servers and /issues work; /objects, /lineage and /events answer 403 evaluation_restriction, and webhooks are not sent |
| Access issues | Never listed, counted or published |
Endpoints
All are GET.
| Path | Returns | Parameters |
|---|---|---|
/health | Estate health per domain with the Operations Center's percentages, and open issues by severity | none |
/health/history | One health reading per day (the last of the day) | from, to (yyyy-MM-dd; last 30 days by default), site |
/sites | Each site with its health per domain | none |
/servers | PI Data Archives, AF servers, AF databases or PI Vision instances with their service health | kind (required: piServer, afServer, afDatabase, piVisionInstance), site |
/objects | Active objects of one kind, a page at a time | kind (required, see Object ids), server, health, site, cursor, limit |
/objects/{objectId} | One object by id, also when it is no longer active | none |
/objects/resolve | The object of a kind with exactly this path (PI points and AF kinds) | kind, path |
/issues | Issues a page at a time: open ones errors first and oldest first, resolved ones in the order they were resolved | state (open default, resolved), severity (error, warning, info), kind, objectId, resolvedSince, includeSuppressed (false), site, priority (one or more of 1 to 4, comma-separated), cursor, limit |
/issues/{issueId} | One issue with its history: opened, resolved, reopened, owner, work and priority changes | none |
/lineage | The objects that feed an object (upstream) or that it feeds (downstream), with the edges between them | objectId (required), direction (downstream default, upstream, both), depth (1 to 5, 2 default), maxNodes (1 to 2000, 500 default) |
/events | Issue and object health changes in order | after, types, limit; see Event feed |
An issue's work.priority is 1 (most urgent) to 4, or null until PI Nexus+ has ranked the issue's current occurrence, one to ten minutes after it opens or reopens; a priority set by hand counts at once. The priority filter leaves out issues without one and keeps the list's order: for the open P1 and P2 issues, most urgent first, ask for priority=1, then priority=2.
Lineage edges always point the way data flows. When maxNodes is reached, or a node has more than 500 edges in one direction, the answer is marked truncated and says why.
Object ids
Every object has an objectId built from the identities PI Nexus+ holds, never from names or paths, so it survives a rename. Treat it as an opaque string and store it; in a URL path its slashes need no escaping.
| Kind | objectId |
|---|---|
piPoint | piPoint:<server id>/<PointID> |
piPointSource | piPointSource:<server id>/<point source> |
piInterface | piInterface:<id> |
piAdapter | piAdapter:<id> |
afElement, afAttribute, afAnalysis | <kind>:<AF server id>/<database GUID>/<object GUID> |
piVisionDisplay | piVisionDisplay:<instance id>/<display id> |
monitoredHost | monitoredHost:<id> |
externalSystem | externalSystem:<id> |
piServer, afServer, afDatabase, piVisionInstance | Listed by /servers |
An issue or event on an object that is no longer in the inventory carries objectId: null and the object's last known key.
Health values
| Value | Meaning |
|---|---|
good | Checked, no problem |
warning | Checked, a warning |
error | Checked, an error (PI points' Bad is an error) |
unknown | Could not be checked |
notEvaluated | No verdict, for example an unused PI Vision display or an object without health rules |
Errors
Errors are application/problem+json (RFC 9457) with status, title, detail and a code to act on.
| Status | code | Meaning |
|---|---|---|
| 400 | invalid_query | A parameter is missing, out of range or not of its type; errors then lists the parameters |
| 400 | invalid_cursor | The cursor is damaged, or was used with other filters |
| 401 | unauthorized | No key, an unknown, revoked or expired key, or a wrong secret |
| 403 | scope_missing | The key lacks the endpoint's scope |
| 403 | site_scope | The key is limited to another site |
| 403 | evaluation_restriction | Not available with an Evaluation licence |
| 403 | license_not_operational | The licence does not allow operational access |
| 404 | not_enabled | The public API is off |
| 404 | not_found | No such endpoint, object or issue |
| 410 | cursor_expired | Events after the cursor were deleted by retention; oldestAvailable says where to restart |
| 429 | rate_limited | Over the rate limit; wait Retry-After seconds |
| 500 | server_error | An unexpected error; traceId identifies it in the PI Nexus+ log |
Event feed
GET /api/v1/events?after=<event id> returns the events after the last one you processed, oldest first, as events, nextAfter and more. Store nextAfter once you have processed the page and pass it as after next time; call again at once while more is true, otherwise poll every minute or so. types takes a comma-separated list of event types.
| Event type | Published when |
|---|---|
issue.opened | An issue opens (also when it opens suppressed; then suppressed is true) |
issue.resolved | An open issue resolves |
issue.reopened | A resolved issue opens again, also when it resolved and reopened within a minute |
issue.severityChanged | An open issue changes severity |
issue.suppressed, issue.unsuppressed | An issue is suppressed or restored |
object.healthChanged | An object's issue health moves between good, warning and error (its worst open, unsuppressed issue; Info issues do not count). health holds previous and current; issue is the issue whose change moved it, and its event comes first |
| Rule | Detail |
|---|---|
| Delay | An event appears within about a minute of the change. A change undone within that minute is not published |
| Order and duplicates | Ids increase in the order events were written. Delivery is at least once: skip an id you have already processed |
| Content | Each event carries the issue as it stood, its object with objectId, and the object's siteId, fixed when the event was written |
| Priority | issue.priority is the issue's priority when the event was written, as work.priority on /issues. A new or reopened issue is ranked one to ten minutes after it opens, so issue.opened and issue.reopened usually carry null; read the issue for its priority later |
| Retention | 14 days, or 5 million events, whichever is smaller. An older cursor gets 410 cursor_expired: re-read /issues, then continue after oldestAvailable |
| Start | Turning the public API on starts the feed from the current state; existing issues are not sent as events. Turning it off stops the feed: changes while it is off are never published, so re-read /issues after it was off |
| Deleted issues | An open issue that is deleted together with its object (a server or external system removed from PI Nexus+, an inventory purge, retention of missing inventory) publishes issue.resolved, and object.healthChanged when that moves the object's health. resolvedAt is the time of the deletion, and object.id is the id the object had |
Webhooks
A webhook receives the event feed as signed HTTP POSTs. Webhooks are set up under Admin > Integrations > Webhooks; there is no API to create them.
| Part | Detail |
|---|---|
| Body | schemaVersion (1), deliveryId, subscriptionId, sentAt, test, events (up to 100, oldest first, each as in /events), gap |
X-PINexus-Event | batch, gap or test |
X-PINexus-Delivery | The deliveryId; the same on every retry of a batch |
X-PINexus-Timestamp | Unix time in seconds when the post was sent |
X-PINexus-Signature | sha256= and the lower-case hex HMAC-SHA256 of the timestamp, a dot and the raw body, keyed with the webhook's signing secret |
| Rule | Detail |
|---|---|
| Start | A new webhook starts with the next event; earlier events are not sent |
| Filters | Event types, minimum severity, object kinds and one site. The severity filter looks at the worst severity the issue has had since it opened, so a webhook for errors still gets the downgrade and the resolve of an issue it was sent as an error |
| Success | Any 2xx answer within 15 seconds. Redirects are not followed |
| Retries | A failed batch is sent again, unchanged and in order, after 1 minute, then doubling to every 30 minutes; a 4xx other than 408 and 429 every 30 minutes; a Retry-After up to 6 hours is honoured. Later events wait behind it |
| Pause | After 72 hours of failures the webhook pauses and Admin > Integrations and Admin > Support > Readiness show a warning. Resume continues from the last event the receiver accepted |
| Gap | If retention deleted events the receiver never got, the next post has no events and gap with lastDelivered and resumesAfter; re-read /issues, then delivery continues. The first post after the public API was turned off and on again is the same notice, with lastDelivered equal to resumesAfter |
| Test | Send test posts one invented issue.opened event with test true; it does not affect delivery |
A receiver should check the signature against the raw body and reject a timestamp older than five minutes, answer quickly and process later, and skip event ids it has already processed.
Samples
All open errors, a page at a time (PowerShell):
$base = 'https://pinexus.contoso.com/api/v1'
$headers = @{ Authorization = "Bearer $env:PINEXUS_API_KEY" }
$cursor = $null
do {
$uri = "$base/issues?state=open&severity=error&limit=1000"
if ($cursor) { $uri += "&cursor=$cursor" }
$page = Invoke-RestMethod -Uri $uri -Headers $headers
foreach ($issue in $page.items) {
'{0} {1} {2}' -f $issue.object.kind, $issue.object.name, $issue.message
}
$cursor = $page.nextCursor
} while ($cursor)
Read the event feed from where the last run stopped (PowerShell; run it every few minutes):
$base = 'https://pinexus.contoso.com/api/v1'
$headers = @{ Authorization = "Bearer $env:PINEXUS_API_KEY" }
$stateFile = 'C:\ProgramData\Contoso\pinexus-last-event.txt'
$after = if (Test-Path $stateFile) { Get-Content $stateFile } else { $null }
do {
$uri = "$base/events?limit=1000"
if ($after) { $uri += "&after=$after" }
$page = Invoke-RestMethod -Uri $uri -Headers $headers
foreach ($event in $page.events) {
'{0} {1} {2}' -f $event.type, $event.object.name, $event.issue.message
}
$after = $page.nextAfter
Set-Content -Path $stateFile -Value $after
} while ($page.more)
A webhook receiver that checks the signature (Python 3, standard library):
import hashlib
import hmac
import json
import time
from http.server import BaseHTTPRequestHandler, HTTPServer
SECRET = b"whsec_..." # the signing secret PI Nexus+ showed when the webhook was created
processed = set() # keep this in your own store in production
def is_valid(timestamp: str, body: bytes, signature: str) -> bool:
if not timestamp.isdigit() or abs(time.time() - int(timestamp)) > 300:
return False
expected = "sha256=" + hmac.new(SECRET, timestamp.encode() + b"." + body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)
class Receiver(BaseHTTPRequestHandler):
def do_POST(self):
body = self.rfile.read(int(self.headers["Content-Length"]))
if not is_valid(self.headers.get("X-PINexus-Timestamp", ""), body, self.headers.get("X-PINexus-Signature", "")):
self.send_response(401)
self.end_headers()
return
envelope = json.loads(body)
if envelope["gap"]:
print("Events were missed; re-read /api/v1/issues")
for event in envelope["events"]:
if event["id"] in processed:
continue
processed.add(event["id"])
print(event["type"], event["object"]["name"], event["issue"]["message"])
self.send_response(200)
self.end_headers()
HTTPServer(("0.0.0.0", 8080), Receiver).serve_forever()
The same receiver in ASP.NET Core (C#, .NET 8 or later):
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
var secret = Environment.GetEnvironmentVariable("PINEXUS_WEBHOOK_SECRET")!; // whsec_...
var app = WebApplication.CreateBuilder(args).Build();
app.MapPost("/pinexus", async (HttpRequest request) =>
{
using var reader = new StreamReader(request.Body, Encoding.UTF8);
var body = await reader.ReadToEndAsync();
if (!PINexusSignature.IsValid(secret, request.Headers["X-PINexus-Timestamp"].ToString(), body,
request.Headers["X-PINexus-Signature"].ToString()))
{
return Results.Unauthorized();
}
using var envelope = JsonDocument.Parse(body);
foreach (var item in envelope.RootElement.GetProperty("events").EnumerateArray())
{
// Skip an event id you have already processed: delivery is at least once.
Console.WriteLine($"{item.GetProperty("type")} {item.GetProperty("object").GetProperty("name")}");
}
return Results.Ok();
});
app.Run();
static class PINexusSignature
{
public static bool IsValid(string secret, string timestamp, string body, string signature)
{
if (!long.TryParse(timestamp, out var seconds) || Math.Abs(DateTimeOffset.UtcNow.ToUnixTimeSeconds() - seconds) > 300)
{
return false;
}
var hash = HMACSHA256.HashData(Encoding.UTF8.GetBytes(secret), Encoding.UTF8.GetBytes(timestamp + "." + body));
var expected = "sha256=" + Convert.ToHexString(hash).ToLowerInvariant();
return CryptographicOperations.FixedTimeEquals(Encoding.ASCII.GetBytes(expected), Encoding.ASCII.GetBytes(signature));
}
}
