Skip to main content

OPA SDKs

You can quickly connect an application to Enterprise OPA or Open Policy Agent (OPA) using the following SDKs.

These are developed and supported by Styra:

Language RepoDocsPackage
JavaStyraInc/opa-javastyrainc.github.io/opa-java
TypeScriptStyraInc/opa-typescriptstyrainc.github.io/opa-typescript @styra/opa
C#StyraInc/opa-csharpstyrainc.github.io/opa-csharp Styra

Getting Started

npm:

npm add @styra/opa

Yarn:

yarn add @styra/opa

Code Examples

import { OPAClient } from "@styra/opa";

const serverURL = "http://opa-host:8181";
const opa = new OPAClient(serverURL);

const path = "authz/allow";
const input = {
subject: "alice",
action: "read",
resource: "/finance/reports/fy2038_budget.csv"
};
const result = await opa.authorize(path, input);
console.log(result ? "allowed" : "denied");

Support

Got suggestions or need help? We're here! Please reach out to us on the Styra Community Slack.

Further Reading