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

thebrain-api

v0.0.1

Published

TypeScript client for TheBrain API

Readme

TheBrain API Client

A TypeScript client for TheBrain API that provides type-safe access to all API endpoints.

Installation

yarn add thebrain-api

Usage

import { TheBrainApi } from 'thebrain-api';

// Initialize the client
const api = new TheBrainApi({
  apiKey: 'your-api-key',
  // Optional configuration
  requestLimit: 10, // Number of requests per window
  rateLimitWindows: 1000, // Window size in milliseconds
  baseURL: 'https://api.bra.in' // API base URL
});

// Example: Get all brains
const brains = await api.brains.getBrains();

// Example: Create a thought
const thought = await api.thoughts.createThought(brainId, {
  name: 'New Thought',
  kind: 1, // Normal thought
  label: 'Optional Label',
  acType: 0 // Public access
});

// Example: Add a file attachment
await api.attachments.addFileAttachment(brainId, thoughtId, file);

// Example: Add a URL attachment
await api.attachments.addUrlAttachment(brainId, thoughtId, 'https://example.com', 'Optional Name');

Features

  • Full TypeScript support with type definitions
  • Automatic rate limiting
  • All API endpoints supported
  • File and URL attachment handling
  • Error handling
  • Request/response validation using Zod

API Groups

  • brains: Brain management and operations
  • thoughts: Thought operations and management
  • links: Link management between thoughts
  • attachments: File and URL attachments
  • notes: Note content management (Markdown, HTML, plain text)
  • notesImages: Note image handling
  • search: Search functionality across brains
  • users: User and organization management
  • brainAccess: Brain access control and permissions

Development

# Install dependencies
yarn install

# Build the package
yarn build

# Run tests
yarn test

# Lint code
yarn lint

# Format code
yarn format

License

MIT

Using Minified Bundles

By default, you can import the package as usual in Node.js or modern bundlers (Webpack, Vite, etc.):

// CommonJS (Node.js)
const { TheBrainApi } = require('thebrain-api');

// ES Modules (Node.js, modern bundlers)
import { TheBrainApi } from 'thebrain-api';

Minified Bundles

For advanced users who want to use the minified bundles directly (for example, in a browser via a CDN or custom build process), you can reference the minified files:

  • CommonJS minified: dist/index.min.js
  • ESM minified: dist/index.min.esm.js

Example (Browser via CDN or direct script tag)

<!-- ESM example -->
<script type="module">
  import { TheBrainApi } from 'https://unpkg.com/thebrain-api@latest/dist/index.min.esm.js';
  // Use TheBrainApi as needed
</script>
<!-- CommonJS example (for environments that support require) -->
<script src="https://unpkg.com/thebrain-api@latest/dist/index.min.js"></script>
<script>
  // thebrain-api will be available as a global variable if you UMD-wrap it (not included by default)
</script>

Note: The minified files are functionally identical to the regular bundles, but are optimized for production with reduced file size.