> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AVEVA PI Web API

> Read PI points, Asset Framework metadata, recorded values and stream sets into your app.

Mount one PI Web API selection per mount. The receiver uses one fixed HTTPS
origin and GET resource. The mount's records, source state and receiver
replies live under the same `data` label.

```ts app.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { app, label, secret } from "@bijectionhq/bijection";
import pi, { piWebApi } from "@bijectionhq/app-pi";

const historian = label();
const reader = secret();
const points = piWebApi("https://pi.example.com", "points", "F1DS_REPLACE_ME", reader, historian);

export default app({ historian, reader, points, pi: pi({ data: historian, provider: points }) });
```

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection secret set reader
bijection mutate pi.source.initialize '{"selection": {"mode": "points", "webId": "F1DS_REPLACE_ME", "nameFilter": "Plant*"}}'
```

`pi.operator` is granted from code: `ctx.grant(pi.operator, { to, under })` in one of your
mutations ([Grants](https://docs.bijection.com/access/grants.md)).

Set the secret to the base64 of the Basic credential's `user:password` for a
read-only PI principal. Pass the same label to `piWebApi` and to the mount as
`data`; the mount's `operator` role clears it. The selection's mode and WebId
must match the ones the receiver was bound with.

* **Points** read one data server's `/points` endpoint. Each pass uses
  zero-based `startIndex` pages of 64, stopping at a short page. The
  key is the PI WebId. A live list can move during paging. Missing points
  leave existing records in place.
* **Asset Framework elements** use
  `{ mode: "afElements", webId: "<AF database WebId>", nameFilter: "*" }`
  to list the database's top-level elements and their template names.
* **Asset Framework attributes** use
  `{ mode: "afAttributes", webId: "<AF element WebId>", nameFilter: "*" }`
  to list that element's direct attribute metadata. Use the separate archive
  modes for values. Each AF feed publishes by WebId and advances a live
  zero-based offset after each full 64-record page. A short page ends the
  sweep. Up to 36 KiB per response. Missing metadata remains published.
* **Recorded values** use `{ mode: "recorded", webId, start, end, windowSeconds }`
  for one stream. Supply absolute UTC, millisecond-aligned interval endpoints
  and a window of one second to one day.
* **Recorded stream sets** use the same interval settings with
  `mode: "streamSet"` and the containing AF element's WebId. PI chooses
  the associated streams. One answer may carry up to eight streams.

Archive positions advance by the requested window boundary only after the
window commits. The app retains the provider's timestamp text and keys
values by WebId and exact UTC instant. A shared boundary belongs to the
following window, and the final end instant is included. Duplicate
timestamps within one stream, partial errors and answers exceeding 64
samples or 36 KiB fail the window. Choose a window sized for archive density.
A completed range stops. A reset rereads the installed range, upserting
returned values without withdrawing omissions. Earlier archive edits or
late arrivals are visible only on a reread. Position is a traversal of the
specified range and carries no archive snapshot or continuity guarantee.

Use the revision in `source.health` when exposing mounted poll, pause,
resume or reset controls.

[AVEVA point enumeration](https://docs.aveva.com/bundle/pi-web-api-reference/page/help/controllers/dataserver/actions/getpoints.html)

[AVEVA Asset Framework elements](https://docs.aveva.com/bundle/pi-web-api-reference/page/help/controllers/assetdatabase/actions/getelements.html) · [AVEVA Asset Framework attributes](https://docs.aveva.com/bundle/pi-web-api-reference/page/help/controllers/element/actions/getattributes.html)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.