npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sayrio/public

v1.0.3

Published

Sayr.io public REST + Server‑Sent Events SDK

Readme

@sayrio/public

Public JavaScript & TypeScript SDK for Sayr.io.
Provides read‑only access to Sayr organizations, tasks, comments, and real‑time updates via SSE (Server‑Sent Events).

  • ✅ REST + ServerEvents
  • ✅ Browser‑safe
  • ✅ TypeScript‑first
  • ✅ Zero runtime dependencies
  • ✅ Versioned API (v1)
  • ✅ Consistent ApiResult<T> responses
  • ✅ Real‑time public updates via SSE

React hooks are available via the @sayrio/public/react sub‑path export.


Installation

npm install @sayrio/public

or:

pnpm add @sayrio/public

Core Concepts

ApiResult<T>

All SDK methods return a non‑throwing result object:

interface ApiResult<T> {
  success: boolean;
  data: T | null;
  error: string | null;
}

Always check success before accessing data.


Usage

Basic Usage (REST)

Fetch a public organization.

Sayr.org is an alias for the latest API version (v1).

import Sayr from "@sayrio/public";

const res = await Sayr.org.get("acme");

if (!res.success) {
  console.error(res.error);
  return;
}

console.log(res.data.name);

Explicit versioned API:

const res = await Sayr.v1.org.get("acme");

Organizations

Fetch an Organization

const res = await Sayr.org.get("acme");

if (res.success) {
  console.log(res.data);
}

Tasks

List Tasks (Paginated)

const res = await Sayr.org.tasks.list("acme", {
  order: "desc",
  limit: 10,
});

if (!res.success) return;

res.data.items.forEach((task) => {
  console.log(task.title);
});

console.log(res.data.pagination);

Returned shape:

ApiResult<{
  items: Task[];
  pagination: Pagination;
}>

Fetch a Single Task

const res = await Sayr.org.tasks.get("acme", 42);

if (res.success) {
  console.log(res.data.title);
}

Comments

List Task Comments (Paginated)

const res = await Sayr.org.comments.list("acme", 42);

if (!res.success) return;

res.data.items.forEach((comment) => {
  console.log(comment.contentMarkdown);
});

Returned shape:

ApiResult<{
  items: Comment[];
  pagination: Pagination;
}>

Labels & Categories

Labels

const res = await Sayr.org.labels.list("acme");

if (res.success) {
  console.log(res.data);
}

Categories

const res = await Sayr.org.categories.list("acme", "desc");

if (res.success) {
  console.log(res.data);
}

Authenticated User (/me)

The /me namespace provides read‑only access to the currently authenticated user.

Authentication is required
Set a token using Sayr.client.setToken(...).

Set Token

Sayr.client.setToken("********");

Fetch Current User

const res = await Sayr.me.get();

if (res.success) {
  console.log(res.data.email);
}

List Your Organizations

const res = await Sayr.me.organizations();

if (res.success) {
  console.log(res.data);
}

Real‑Time Updates (SSE)

Subscribe to public real‑time events using Server‑Sent Events:

Sayr.sse(org.eventsUrl, {
  [Sayr.EVENTS.UPDATE_TASK]: (data) => {
    console.log("Task updated", data);
  },
});

SSE Features

  • Automatic reconnection (native in browsers)
  • Lightweight, one‑way streaming
  • Typed event constants
  • Public‑safe payloads only

Browser Usage (No Bundler)

<script type="module">
  import Sayr from "https://esm.sh/@sayrio/public";

  const res = await Sayr.org.get("acme");

  if (res.success) {
    console.log(res.data);
  }

  // SSE Example
  Sayr.sse("https://example.com/events", {
    UPDATE_TASK: (data) => console.log("Task updated", data),
  });
</script>

API Overview

Sayr.org (latest)

Alias for Sayr.v1.org.

Organization

| Method | Description | | ----------- | --------------------------- | | get(slug) | Fetch a public organization |


Tasks

| Method | Description | | -------------------------- | ---------------------- | | tasks.list(slug, opts?) | List tasks (paginated) | | tasks.get(slug, shortId) | Fetch a single task |


Comments

| Method | Description | | ------------------------------------- | ------------------------ | | comments.list(slug, shortId, opts?) | List task comments |


Labels

| Method | Description | | ------------------- | ------------------------ | | labels.list(slug) | List organization labels |


Categories

| Method | Description | | ------------------------------- | --------------- | | categories.list(slug, order?) | List categories |


Sayr.me

Authenticated user endpoints.

| Method | Description | | ----------------- | -------------------------------------- | | get() | Fetch the authenticated user | | organizations() | List organizations the user belongs to |


Real‑Time API

Sayr.sse(url, handlers)

Create an SSE connection for public events:

const conn = Sayr.sse(eventsUrl, {
  UPDATE_TASK: () => {},
});

conn.close();

EVENTS

Typed SSE event constants:

Sayr.EVENTS.CREATE_TASK;
Sayr.EVENTS.UPDATE_TASK;
Sayr.EVENTS.UPDATE_TASK_COMMENTS;
Sayr.EVENTS.ERROR;

TypeScript

This package ships with full TypeScript definitions:

import type {
  Organization,
  Task,
  Comment,
  Label,
  Category,
} from "@sayrio/public";

React Hooks

React bindings are available via:

import {
  useOrg,
  useTasks,
  useTask,
  useComments,
} from "@sayrio/public/react";

See @sayrio/public/react README for full hook documentation.