Quick Start
Get a mock API running in under 2 minutes.
1. Initialize
bash
npx fexapi@latest initbash
pnpm dlx fexapi@latest initbash
bunx fexapi@latest initbash
yarn dlx fexapi@latest initThe wizard asks:
| Prompt | Default |
|---|---|
| Port number | 4000 |
| Enable CORS? | Yes |
This creates your project files:
fexapi/schema.fexapi
fexapi.config.js2. Define Your Schema
Open fexapi/schema.fexapi and define your endpoints:
txt
port: 4000
GET /users:
id:uuid
name:name
email:email
age:number
GET /posts:
id:uuid
title:string
body:string
published:booleanEach route declares an HTTP method, path, and a list of fields with their types.
3. Generate
bash
npx fexapi generatebash
pnpm dlx fexapi generatebash
bunx fexapi generatebash
yarn dlx fexapi generateThis reads your schema and outputs fexapi/.cache/generated.api.json.
4. Start the Server
bash
npx fexapi dev --watchbash
pnpm dlx fexapi dev --watchbash
bunx fexapi dev --watchbash
yarn dlx fexapi dev --watchdev --watch will regenerate and reload when fexapi/schema.fexapi, fexapi.config.js, or custom schema YAML files change.
Your mock API is now running. Try it:
bash
curl http://localhost:4000/usersResponse:
json
{
"users": [
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "John Smith",
"email": "john.smith@example.com",
"age": 34
}
]
}5. Control Record Count
Add a count query parameter to get more records:
bash
curl http://localhost:4000/users?count=20Returns 20 user records. Maximum is 50.
For routes defined in fexapi.config.js, count query values override the route count (still clamped to 1-50).
What's Next
- Configuration — customize ports, CORS, and delays
- Schema Guide — learn the full schema format
- CLI Reference — all available commands
