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

circle-so-sdk

v0.1.0

Published

Typed, zero-dependency client for the Circle.so Admin API v2 — members, access groups, spaces, space groups, token version detection, and real captured API fixtures for testing.

Readme

circle-so-sdk

npm version publish license node dependencies

Typed, zero-dependency client for the Circle.so Admin API v2 — members, access groups, spaces, space groups, token version detection — plus real captured API fixtures for testing your integration without hitting Circle.

Unofficial. Not affiliated with Circle Internet Services, Inc.

Install

npm install circle-so-sdk

Requires Node.js ≥ 18 (uses the global fetch).

Quick start

import { createCircleClient, detectTokenVersion } from 'circle-so-sdk'

// Circle issues v1 (Professional plan) and v2 (Business plan) admin tokens
// that look identical. A v1 token on the v2 API returns a plain 401, so use
// the three-state probe to give users an actionable error:
const version = await detectTokenVersion(token) // 'v2' | 'v1' | 'invalid'

const circle = createCircleClient({ token })

const community = await circle.getCommunity()

// Invite (idempotent — re-inviting an existing email does not re-send):
const { member, alreadyExisted } = await circle.createOrInviteMember('[email protected]', 'User Name')

// Access groups (member identified by email, group id in the URL):
const groups = await circle.listAccessGroups()
await circle.addToAccessGroup(groupId, '[email protected]')
await circle.removeFromAccessGroup(groupId, '[email protected]')

// Spaces / space groups (id goes in the request BODY, even for DELETE):
await circle.addToSpace(spaceId, '[email protected]')
await circle.addToSpaceGroup(spaceGroupId, '[email protected]')

Error handling

All non-OK responses throw CircleApiError with a classified kind:

| kind | meaning | |---|---| | unauthorized | 401 — wrong/invalid token (or a v1 token on the v2 API) | | forbidden | 403 — plan no longer allows the endpoint (plan downgrade) | | not_found | 404 with a JSON body — missing record/param | | wrong_path | 404 with an HTML body — the route does not exist (bug guard) | | rate_limited | 429 | | server_error | 5xx |

import { CircleApiError } from 'circle-so-sdk'

try {
  await circle.addToAccessGroup(groupId, email)
} catch (error) {
  if (error instanceof CircleApiError && error.kind === 'unauthorized') {
    // pause syncing, prompt the user to re-connect
  }
}

The wrong_path distinction matters: Circle returns 404 HTML for routes that don't exist and 404 JSON for missing records. The client tells them apart via Content-Type so a typo'd endpoint doesn't masquerade as "record not found".

API quirks this client encodes

Learned from a live integration (all fixtures under circle-so-sdk/mocks were captured against the real API):

  • Asymmetric membership endpoints. Access groups take the group id in the URL and the member's email in the body (POST /access_groups/:id/community_members). Spaces and space groups instead use flat endpoints (/space_members, /space_group_members) with the id in the body — even for DELETE.
  • Members are keyed by email, not member id, for all membership operations.
  • Adds/removes are idempotent. Re-adding returns the same success response; you can apply a full expected set without querying current state first.
  • Space group membership cascades to all spaces inside the group (CircleSpace.space_group lets you detect overlaps).
  • First createOrInviteMember sends Circle's invitation email; subsequent calls for the same email are no-ops (alreadyExisted: true).

Testing your integration: circle-so-sdk/mocks

Real request/response pairs captured from the live Admin API, ready to feed into MSW:

import { http, HttpResponse } from 'msw'
import { setupServer } from 'msw/node'
import { CIRCLE_BASE_V2, circleScenarios, CIRCLE_WRONG_PATH_HTML } from 'circle-so-sdk/mocks'

const server = setupServer(
  http.post(`${CIRCLE_BASE_V2}/community_members`, () =>
    HttpResponse.json(circleScenarios.memberInvited.body, { status: 201 }),
  ),
  http.post(`${CIRCLE_BASE_V2}/access_groups/:id/community_members`, () =>
    HttpResponse.json(circleScenarios.accessGroupAdd.body, { status: 201 }),
  ),
)

Each scenario carries method, path, requestBody, status, contentType, and the captured body, so you can also drive a generic handler loop or assert against the shapes directly.

Options

createCircleClient({
  token,            // required — Circle Admin API v2 token (Business plan+)
  baseUrl,          // optional — override https://app.circle.so/api/admin/v2 (testing)
  fetch: customFetch, // optional — inject a fetch implementation
})

detectTokenVersion(token, { baseUrlV2, baseUrlV1, fetch }) // overrides optional

License

MIT