Skip to main content

OPA SDKs

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

Support

All SDKs are developed and supported by Styra unless noted with an asterisk (*)

Language RepoDocsPackage
JavaStyraInc/opa-javastyrainc.github.io/opa-java/javadoc com.styra/opa
Java (via WASM)*StyraInc/opa-java-wasmgithub.com/styrainc/opa-java-wasm com.styra.opa/opa-java-wasm
TypeScriptStyraInc/opa-typescriptstyrainc.github.io/opa-typescript @styra/opa
@styra/opa
C#StyraInc/opa-csharpstyrainc.github.io/opa-csharp Styra.Opa

Framework-specific integrations:

Framework RepoDocsPackage
ReactStyraInc/opa-typescriptstyrainc.github.io/opa-typescript @styra/opa-react
Spring BootStyraInc/opa-springbootstyrainc.github.io/opa-springboot com.styra.opa/springboot
ASP.NET CoreStyraInc/opa-aspnetcorestyrainc.github.io/opa-aspnetcore Styra.Opa.AspNetCore

Install

npm:

npm add @styra/opa

Yarn:

yarn add @styra/opa zod
note

Yarn does not install peer dependencies automatically. You will need to install zod as shown above.

Usage Examples

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

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

const path = "authz/allow";
const input = {
subject: "alice",
action: "read",
resource: "/finance/reports/fy2038_budget.csv"
};
const result = await opa.evaluate(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

These SDKs are support Open Policy Agent (OPA) and Enterprise OPA.