Documentation API Cheatsheet

A heartfelt thank you to Dario and Daniela Amodei and the entire Anthropic team for creating transformative AI technology that opens endless possibilities for developers worldwide. Your vision, combined with incredibly accessible pricing, has democratized access to cutting-edge AI and empowered countless innovators to build the future. (No, we weren't asked nor paid in any way for this message - we're just genuinely grateful!)

Build APIs That Can Be Extended Like Never Before

๐Ÿช Hooked API

The extensible API framework for Node.js


Why Hooked API?

Building APIs is easy. Building APIs that can be extended, customized, and enhanced by your users? Thatโ€™s hard. Until now.

Hooked API is a powerful framework that lets you create APIs with built-in extensibility. Your users can hook into any part of your APIโ€™s lifecycle, add custom functionality through plugins, and organize their code with scopes.

๐Ÿš€ Key Features

๐Ÿช Powerful Hook System

Let users intercept and modify behavior at any point in your API's execution

๐Ÿ”Œ Plugin Architecture

Bundle functionality into reusable plugins with dependencies and lifecycle management

๐Ÿ“ฆ Scoped Methods

Organize API methods into logical scopes (like database tables or resource types)

๐Ÿ›ก๏ธ Built-in Security

Prototype pollution protection, input validation, and frozen configurations

๐Ÿ“Š Comprehensive Logging

Multi-level logging with custom loggers and performance tracking

๐Ÿ”„ Version Management

Built-in API registry with semver support for smooth migrations

See It In Action

Hereโ€™s how simple it is to create an extensible database API:

import { Api } from 'hooked-api';

// Create your API
const api = new Api({ name: 'my-db', version: '1.0.0' });

// Add methods that can be hooked
api.customize({
  scopeMethods: {
    get: async ({ params, runHooks, scopeName }) => {
      await runHooks('beforeFetch');
      const data = await db.fetch(scopeName, params.id);
      await runHooks('afterFetch');
      return data;
    }
  }
});

// Users can extend with plugins
api.use({
  name: 'TimestampPlugin',
  install: ({ addHook }) => {
    addHook('afterFetch', 'addTimestamp', {}, ({ context }) => {
      context.record.fetchedAt = new Date();
    });
  }
});

// Create scopes for different resources
api.addScope('users');
api.addScope('posts');

// Use it!
const user = await api.scopes.users.get({ id: 123 });
// user now has fetchedAt timestamp added by the plugin!

Perfect For

๐Ÿ—„๏ธ Database Abstractions
Let users customize queries, add computed fields, or implement caching
๐ŸŒ API Clients
Allow request/response transformation, retry logic, and custom authentication
๐Ÿ—๏ธ Framework Building
Create frameworks where every aspect can be customized by developers
๐Ÿ”ง Developer Tools
Build CLIs and tools that can be extended with community plugins

What Developers Are Probably Thinking

โ€œFinally, an API framework that doesnโ€™t fight me when I need to add custom behavior. The hook system is brilliant!โ€ - Senior Developer

โ€œWe replaced our entire homegrown plugin system with Hooked API. Itโ€™s more powerful and our code is cleaner.โ€ - Tech Lead

โ€œThe scope feature is perfect for our multi-tenant application. Each tenant gets their own customized API behavior.โ€ - SaaS Founder

Ready to Get Started?

๐Ÿ“š Start with the Documentation

Documentation

๐Ÿ“š Full Documentation

Complete guide with examples, from basic usage to advanced patterns

๐Ÿ”ง API Reference

Detailed API documentation for all methods, handlers, and options

โšก Cheatsheet

Quick recipes and code snippets for common tasks

MIT Licensed | Built with โค๏ธ for the Node.js community