apiblaze 0.20.45 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -17
- package/dist/index.js +3050 -2349
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,10 @@ npm install -g apiblaze # or install globally
|
|
|
13
13
|
|
|
14
14
|
Requires Node.js 18+.
|
|
15
15
|
|
|
16
|
+
### Running as `npx mcpblaze`
|
|
17
|
+
|
|
18
|
+
[`mcpblaze`](https://www.npmjs.com/package/mcpblaze) is the same CLI under its MCP name: a thin wrapper that runs this package with `APIBLAZE_BRAND=mcpblaze`. Every command and flag is identical; the wording changes — `create` says "Create an MCP server", the thing you make lives at `https://{name}-{tenant}.mcpblaze.com/{version}/{env}`, and the demo after a create is connecting Claude Code or Codex to it rather than a curl. Set `APIBLAZE_BRAND=mcpblaze` yourself to get the same output from `npx apiblaze`.
|
|
19
|
+
|
|
16
20
|
## Quick start
|
|
17
21
|
|
|
18
22
|
The easiest way is to just chat with it:
|
|
@@ -31,25 +35,36 @@ Prefer commands? A few one-liners:
|
|
|
31
35
|
npx apiblaze apichat --openapi https://apiblaze.com/pokeapi_openapi.yaml
|
|
32
36
|
|
|
33
37
|
# Make an API in one line — no account needed (prints a claim URL).
|
|
34
|
-
#
|
|
38
|
+
# Both doors open by default: an API key for your backend and widget (send X-API-Key and
|
|
39
|
+
# say who is calling with X-End-User-Id), and GitHub sign-in for people and agents.
|
|
40
|
+
# --apikey = the key door only; --oauth = the sign-in door only.
|
|
35
41
|
npx apiblaze create --target https://api.example.com
|
|
36
42
|
|
|
37
43
|
# Or build it straight from an OpenAPI spec — a URL or a local file.
|
|
38
44
|
# The routes, the API version and one environment per `servers` entry all come from the spec,
|
|
39
45
|
# and you're asked which resources to lock to the person who created them (e.g. /reservations).
|
|
46
|
+
# At the end it offers to connect Claude Code or Codex to the new MCP server — by default with
|
|
47
|
+
# an API key issued to you (works on the first message), or with GitHub sign-in.
|
|
40
48
|
npx apiblaze create --target https://petstore3.swagger.io/api/v3/openapi.json
|
|
41
49
|
|
|
42
|
-
# Same thing with zero prompts:
|
|
50
|
+
# Same thing with zero prompts: both doors, every lockable resource locked.
|
|
43
51
|
npx apiblaze create --target ./openapi.yaml --auto
|
|
44
52
|
|
|
53
|
+
# Teach Claude Code to do all of the above for you when you say "ship this API"
|
|
54
|
+
npx apiblaze skill --install
|
|
55
|
+
|
|
45
56
|
# Configure how your backend is accessed through the proxy
|
|
46
57
|
npx apiblaze config
|
|
47
58
|
|
|
48
59
|
# Configure who accesses your backend through the proxy
|
|
49
60
|
npx apiblaze tenant
|
|
50
61
|
|
|
51
|
-
#
|
|
52
|
-
|
|
62
|
+
# Your local code, shipped safely: both doors, resources locked to their creator,
|
|
63
|
+
# an admin, Claude Code connected — with localhost as the target, through a tunnel.
|
|
64
|
+
npx apiblaze dev --port 3000 --openapi ./openapi.yaml
|
|
65
|
+
|
|
66
|
+
# What to add to your frontend + frontend-server (widgets, call-through, env vars)
|
|
67
|
+
npx apiblaze integration myapi --stack nextjs
|
|
53
68
|
|
|
54
69
|
# Route a Next.js app's outbound fetch() through APIblaze
|
|
55
70
|
npx apiblaze sidecar
|
|
@@ -58,6 +73,41 @@ npx apiblaze sidecar
|
|
|
58
73
|
npx apiblaze login
|
|
59
74
|
```
|
|
60
75
|
|
|
76
|
+
## Skill
|
|
77
|
+
|
|
78
|
+
`npx apiblaze skill --install` writes `.claude/skills/ship-safely/SKILL.md` into your project. From then on, when you tell Claude Code to ship, expose or add auth to an API, it puts APIblaze in front of your code instead of hand-rolling auth: it uses the control-plane MCP (`claude mcp add --transport http apiblaze https://mcp.apiblaze.com`, then `/mcp` to sign in once) to create the server, propose and apply the ownership rules, add an admin, issue keys and hand you the integration snippets — your backend does not change.
|
|
79
|
+
Under `npx mcpblaze` the same skill names MCPblaze and `mcp.mcpblaze.com`; it is the same server.
|
|
80
|
+
|
|
81
|
+
`skills` is an alias of `skill` — Claude Code's folder is `.claude/skills/`, so both spellings do the same thing:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npx apiblaze skill # print SKILL.md to stdout
|
|
85
|
+
npx apiblaze skills # identical
|
|
86
|
+
npx apiblaze skills --install # write .claude/skills/ship-safely/SKILL.md (add --force to overwrite)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Where your callers sign in
|
|
90
|
+
|
|
91
|
+
The skill teaches Claude to ask "where do your users sign in today?" before creating anything, because a multi-tenant app usually already has a login and its users should not get a second one. Three shapes, exactly as `create --oauth` (and `dev --oauth`) accepts them:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# 1. Nothing passed — both doors: an API key for your server, plus hosted GitHub sign-in
|
|
95
|
+
# for people and agents. Bare --oauth narrows it to the sign-in door alone.
|
|
96
|
+
npx apiblaze create --target https://api.example.com
|
|
97
|
+
|
|
98
|
+
# 2. YOUR OWN OAuth app on a hosted login page — the agent's users sign in exactly where
|
|
99
|
+
# your users already do. provider is one of: auth0 · google · github · microsoft · facebook.
|
|
100
|
+
npx apiblaze create --target https://api.example.com \
|
|
101
|
+
--oauth «'{"provider":"auth0","clientId":"AbC123…","clientSecret":"s3cr3t…"}'»
|
|
102
|
+
|
|
103
|
+
# 3. YOUR OWN JWT issuer — no login page at all; the proxy verifies the tokens you already
|
|
104
|
+
# issue. All three fields are required; jwks is that issuer's JWKS URL.
|
|
105
|
+
npx apiblaze create --target https://api.example.com \
|
|
106
|
+
--oauth «'{"iss":"https://login.acme.com/","aud":"acme-api","jwks":"https://login.acme.com/.well-known/jwks.json"}'»
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Your tenants then self-serve their own keys from the key widget inside **your** app (`npx apiblaze integration <name> --stack nextjs`), your frontend-server holds one server key and says who is calling with `X-End-User-Id`, and `npx apiblaze apikeys mint --tenant <tenant> --for <email>` mints a key bound to one person.
|
|
110
|
+
|
|
61
111
|
## Embeddable widgets (React)
|
|
62
112
|
|
|
63
113
|
Let your customers self-serve from **your** site — **API keys** (`<ApiKeyWidget/>`) and
|
|
@@ -122,10 +172,12 @@ Every chat turn shows its cost.
|
|
|
122
172
|
|
|
123
173
|
| Command | What it does |
|
|
124
174
|
|---|---|
|
|
125
|
-
| `apiblaze create --target <url>` | Make an API from a backend (no account needed).
|
|
126
|
-
| `apiblaze create --target <file\|url>` | Make an API from an OpenAPI spec — a local file or a spec URL. Asks which resources to lock to their creator; `--auto` locks them all |
|
|
175
|
+
| `apiblaze create --target <url>` | Make an API from a backend (no account needed). Both doors by default: an API key for your code, GitHub sign-in for agents. `--apikey` / `--oauth` open one door only |
|
|
176
|
+
| `apiblaze create --target <file\|url>` | Make an API from an OpenAPI spec — a local file or a spec URL. Asks which resources to lock to their creator, then offers to connect Claude Code / Codex; `--auto` locks them all |
|
|
177
|
+
| `apiblaze skill [--install]` | Print (or install into `.claude/skills/`) the Claude Code skill that teaches Claude to ship your API safely with APIblaze. `apiblaze skills` is the same command; `--force` overwrites an existing SKILL.md |
|
|
127
178
|
| `apiblaze sidecar` | Route a Next.js app's external `fetch()` calls through APIblaze (one command) |
|
|
128
|
-
| `apiblaze dev [
|
|
179
|
+
| `apiblaze dev --port <p> [--openapi <spec>]` | The hero command for code on this machine: everything `create` does, with localhost as the target through a tunnel. Without `--openapi` it looks for `/openapi.json`, `/openapi.yaml`, `/docs/openapi.json` on that port. `--auto` = every answer is the default |
|
|
180
|
+
| `apiblaze integration <name> --stack nextjs` | What to add to your frontend and frontend-server (also `express`, `fastapi`, `other`): the widgets, the call-through with the key + `X-End-User-Id`, what your backend must trust, env vars, what stays open. `--json` for the raw kit |
|
|
129
181
|
| `apiblaze login` / `logout` | Sign in / out (logout asks producer or consumer) |
|
|
130
182
|
| `apiblaze whoami` | Who am I — both Producer and Consumer |
|
|
131
183
|
| `apiblaze team [name]` | Switch team |
|
|
@@ -187,16 +239,44 @@ shows both, and `logout` asks which to drop.
|
|
|
187
239
|
>
|
|
188
240
|
> Advanced: `apiblaze apikeys` manages producer control-plane keys for scripting.
|
|
189
241
|
|
|
190
|
-
##
|
|
242
|
+
## `apiblaze dev` — your local code, shipped safely
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
$ npx apiblaze dev --port 3000 --openapi ./backend/openapi.yaml
|
|
246
|
+
|
|
247
|
+
Tunnel → http://localhost:3000
|
|
248
|
+
Spec: ./backend/openapi.yaml
|
|
249
|
+
? Name: nino
|
|
250
|
+
? Do you want to prevent unauthorized users from taking unauthorized actions? Yes
|
|
251
|
+
? Lock these to the person who created them (or an admin): reservations, tables, restaurants
|
|
252
|
+
? Who is the admin? Their email address (Enter to skip): julien@ninopizzas.com
|
|
253
|
+
|
|
254
|
+
✓ https://nino.abz.run/1.0.0/dev → localhost:3000 (sign-in with GitHub, or an API key)
|
|
255
|
+
✓ reservations, tables + restaurants locked to their creator · julien@ninopizzas.com is admin
|
|
256
|
+
✓ agents: https://nino-ninodefaulttenant.mcpblaze.com/1.0.0/dev
|
|
257
|
+
|
|
258
|
+
API key (for your frontend-server, shown once): sk_dev_… → send it as X-API-Key and say who is calling with X-End-User-Id
|
|
259
|
+
|
|
260
|
+
? Connect Claude Code to it now? Yes
|
|
261
|
+
✓ connected — it acts as julien@ninopizzas.com; try "Create a reservation, then show it to me."
|
|
262
|
+
|
|
263
|
+
Tunnel is up — leave this running. Ctrl-C stops it.
|
|
264
|
+
```
|
|
191
265
|
|
|
192
|
-
|
|
266
|
+
No login needed (logged out, the proxy lives in an anonymous workspace you can claim).
|
|
267
|
+
What it does, in order:
|
|
193
268
|
|
|
194
|
-
1.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
269
|
+
1. Reads your OpenAPI spec (`--openapi`, or `/openapi.json` · `/openapi.yaml` · `/docs/openapi.json`
|
|
270
|
+
on the port). No spec → no rules; everything else still works.
|
|
271
|
+
2. Asks four short questions (name, lock resources, which ones, the admin) — `--auto` takes the defaults.
|
|
272
|
+
3. Creates the proxy with both doors open, points it at your machine through a tunnel, applies the
|
|
273
|
+
rules, adds the admin (active now — a key issued to them creates their identity first).
|
|
274
|
+
4. Offers to connect Claude Code (or Codex) with a key that acts as the admin — nothing to sign in to.
|
|
275
|
+
5. Streams live traffic until Ctrl-C, then restores the project's original target.
|
|
198
276
|
|
|
199
|
-
|
|
277
|
+
If a project already points at this machine, `dev` offers to re-attach it instead (`--project <name>`
|
|
278
|
+
picks one for scripts). Then `npx apiblaze integration <name> --stack nextjs` tells you what to add
|
|
279
|
+
to your frontend and frontend-server.
|
|
200
280
|
|
|
201
281
|
## Sidecar — proxy a Next.js app's egress
|
|
202
282
|
|
|
@@ -230,9 +310,8 @@ left alone.
|
|
|
230
310
|
|
|
231
311
|
## How it works
|
|
232
312
|
|
|
233
|
-
- **No project yet?**
|
|
234
|
-
|
|
235
|
-
`http://localhost:<port>` and tunnels it immediately — pick `none` or `api_key` auth.
|
|
313
|
+
- **No project yet?** `apiblaze dev` sets one up (see above): both doors, rules from your
|
|
314
|
+
spec, an admin, an agent — pointed at `http://localhost:<port>` and tunneled immediately.
|
|
236
315
|
- **Server not running yet?** If nothing is listening on the local port, requests aren't
|
|
237
316
|
dropped: each one is printed in full (headers + body, with API keys/JWTs masked and JWTs
|
|
238
317
|
decoded) and answered with a friendly synthetic `200`. The moment your dev server comes
|