Skip to content

sentioxyz/api

Repository files navigation

Sentio API

npm version Release

TypeScript client for the Sentio API. The bindings are generated from Sentio's protobuf definitions with protobuf-es and call the REST API through connect-es with the @sentio/connect-gateway-es transport — fully typed requests and responses, including server-streaming endpoints.

v2 is a breaking rewrite. v1 (openapi-ts based: client.setConfig + static service classes) is replaced by connect-es style clients. The REST API itself is unchanged; see the examples below for the new shapes. The package is ESM-only and requires Node 24+.

Setup

pnpm add @sentio/api

Create an API key under your project's settings on app.sentio.xyz.

Usage

Example 1: list dashboards

import { createSentioClient, WebService } from "@sentio/api";

const web = createSentioClient(WebService, {
  apiKey: process.env.SENTIO_API_KEY,
});
const dashboards = await web.listDashboards({
  ownerName: "sentio",
  slug: "coinbase",
});
console.log(dashboards);

Example 2: insight query

import { createSentioClient, InsightsService } from "@sentio/api";

const insights = createSentioClient(InsightsService, {
  apiKey: process.env.SENTIO_API_KEY,
});

const res = await insights.query({
  projectOwner: "sentio",
  projectSlug: "coinbase",
  timeRange: {
    start: "now-30d",
    end: "now",
    step: 3600,
    timezone: "America/Los_Angeles",
  },
  limit: 20,
  queries: [
    {
      metricsQuery: {
        query: "cbETH_price",
      },
    },
  ],
});
console.log(res);

Request messages are plain partial objects (protobuf-es init shapes) — omitted fields take their proto defaults.

Several services over one transport

import { createClient, createSentioTransport, AnalyticService, WebService } from "@sentio/api";

const transport = createSentioTransport({ apiKey: process.env.SENTIO_API_KEY });
const web = createClient(WebService, transport);
const analytics = createClient(AnalyticService, transport);

Message and enum types

Each service module exports its request/response types; deep-import them via the gen subpath:

import type { Project } from "@sentio/api/gen/service/common/protos/common_pb.js";

Options

createSentioClient / createSentioTransport accept:

  • apiKey — sent as the api-key header.
  • baseUrl — defaults to https://app.sentio.xyz.
  • everything else from GatewayTransportOptions (headers, fetch, interceptors, defaultTimeoutMs, ...).

Errors are connect-es ConnectErrors carrying the mapped gRPC code and the server's google.rpc.Status details.

REST / OpenAPI

The raw REST API is documented at docs.sentio.xyz; this repository also ships the OpenAPI spec and a generated HTML reference. Both reflect the same API surface as the TypeScript client.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages