【开源自荐】UsageRail SDK:在自己的 API 服务里做 API key 校验、按客户限流和用量计量

Open
#201 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
24/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Tech stack
express, fastapi, javascript, node.js, python
Domain
content

Research direction

This issue is a project recommendation for UsageRail SDK, not a request to change code or documentation. Start by checking the repository’s contribution guidance and existing project listings; done would mean a specific, actionable contribution request is identified, since the issue itself does not name one.

Written by the indexing model from the issue text.

Description

1). 项目名称:UsageRail SDK(usagerail/sdk)

2). 项目地址:https://github.com/usagerail/sdk

3). 项目简介(100字以内):
给要收费的 API 用的中间件。请求进来先查 API key、这个客户的限流和剩余额度,放行后把请求数或 token 数记到客户名下。Node.js 和 Python 都有,MIT 协议。

4). 推荐原因:
我们是这个项目的开发团队。卖 API 的时候,发 key、按客户限流、扣额度、记用量这几件事几乎每个团队都要自己写一遍,这个 SDK 把它们放进一个中间件里,key 和限额在服务进程里对着同步下来的副本查,前面不用再架网关或代理。

  • Node.js 22+:npm install @usagerail/node,支持 Express、Hono(含 Cloudflare Workers)、Fastify、Next.js route handler。
  • Python 3.10+:pip install usagerail,支持 FastAPI、Starlette、Flask、Django,没有第三方依赖。
  • 用量通常按路由模板归并(比如 /v1/items/{item_id}),同一个接口不会因为 ID 不同拆成很多行。Express 里有几种挂载方式拿不到模板,文档里列了。
  • 超过限流返回 429,带 Retry-After 和 IETF 草案里的 RateLimit 响应头。

用量会在后台批量报给 UsageRail 的托管服务,再写进开发者自己 Stripe 账号的账单,所以完整用起来需要配合托管服务。SDK 代码本身全部公开,仓库里也有测每次请求开销的基准脚本。

5). 项目图片:
无

6). 其他项目细节:

欢迎试用和提 issue。

Dominant language
No language data
Stars
1.9k
Forks
76
Avg merge
3h 36m
Merged PRs (30d)
18

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenGithubs/weekly

All issues in OpenGithubs/weekly

Similar issues

More Content issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.