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

apifriend

v0.1.1

Published

API proxy with multi-source management, auto failover, and rate limiting

Readme

APIFriend

API proxy service with multi-source management, automatic failover, and rate limiting.

Features

  • Multi-Source Load Balancing - Configure multiple API sources with priority-based selection
  • Auto Failover - Automatically switch to backup sources on failure
  • Rate Limiting - Support RPM/TPM/daily limits to prevent overages
  • Model Mapping - Map request model names to actual models
  • OpenAI & Anthropic Compatible - Supports /v1/chat/completions and /v1/messages endpoints
  • Admin Dashboard - Modern Liquid Glass style UI
  • State Persistence - Retain stats across restarts

Quick Start

# Clone the repository
git clone https://github.com/ituiyuio/APIFriend.git
cd APIFriend

# Install dependencies
npm install

# Copy example config
cp config.example.json config.json

# Edit config and add your API keys
# Then start
npm start

After starting:

  • Proxy URL: http://127.0.0.1:3000/v1/chat/completions
  • Admin Dashboard: http://127.0.0.1:3000/admin/sources

Configuration

{
  "server": {
    "port": 3000,
    "host": "127.0.0.1"
  },
  "security": {
    "proxyApiKey": "your-secure-key"
  },
  "sources": [
    {
      "name": "openrouter",
      "baseUrl": "https://openrouter.ai/api/v1",
      "apiKey": "YOUR_API_KEY",
      "priority": 1,
      "enabled": true,
      "format": "openai",
      "rateLimit": {
        "requestsPerMinute": 20,
        "tokensPerMinute": 6000
      },
      "modelMapping": {
        "friend": "anthropic/claude-3.5-sonnet",
        "default": "anthropic/claude-3.5-sonnet"
      }
    }
  ],
  "failover": {
    "timeoutMs": 15000,
    "maxRetries": 3,
    "cooldownMinutes": 5
  }
}

Source Fields

| Field | Description | |-------|-------------| | name | Source identifier | | baseUrl | API base URL | | apiKey | API key | | priority | Lower number = higher priority | | enabled | Whether source is active | | format | API format: openai or anthropic | | rateLimit | Rate limit configuration | | modelMapping | Model name mapping |

API Endpoints

Proxy Endpoints

POST /v1/chat/completions    # OpenAI compatible
POST /v1/messages            # Anthropic compatible
GET  /v1/models              # List available models

Admin Endpoints

GET    /admin/sources              # List all sources
POST   /admin/sources              # Create source
GET    /admin/sources/:name        # Get source details
PATCH  /admin/sources/:name        # Update source
DELETE /admin/sources/:name        # Delete source
POST   /admin/sources/:name/toggle # Toggle enabled status
POST   /admin/sources/:name/reset  # Reset source stats
GET    /admin/stats                # Get statistics
GET    /admin/stats/history        # Get historical stats
GET    /admin/health               # Health check
POST   /admin/reload               # Reload config

Usage Example

import openai

client = openai.OpenAI(
    api_key="any",
    base_url="http://127.0.0.1:3000/v1"
)

response = client.chat.completions.create(
    model="friend",
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)

Claude Code

For Claude Code, use:

claude --model friend

Admin Dashboard

Visit http://127.0.0.1:3000/admin/sources to view:

  • Source status and statistics
  • Real-time rate limiting
  • Request trend charts
  • Enable/disable sources

Sponsor / 赞助支持

If APIFriend helps you, consider supporting the project:

如果 APIFriend 对你有帮助,欢迎赞助支持:

❤️ https://afdian.com/a/Yomin

License

MIT