Getting Started
Learn how to build your first API with Frey in just a few minutes
Getting Started
Welcome to Frey! This guide will help you get up and running with Frey in just a few minutes.
What is Frey?
Frey is a lightweight, entity-driven API framework built with Fastify and TypeScript. It provides a structured way to define entities with Zod schemas and automatically generates RESTful APIs with full type safety.
Key Features
- ๐ Entity-driven API generation - Define entities and get full CRUD APIs automatically
- โก Multi-runtime support - Works with both Node.js and Bun
- ๐ Type-safe - Built with TypeScript strict mode for maximum type safety
- ๐งช Well-tested - Comprehensive tests across unit and integration
- ๐ Automatic validation - Parameter parsing and validation with Zod
- ๐ ๏ธ Custom routes - Extend generated APIs with custom route handlers
- ๐ฆ Minimal dependencies - Only essential dependencies (Fastify + Zod)
Installation
Your First API
Let's create a simple user API to get started:
What Just Happened?
When you run this code, Frey automatically creates the following REST endpoints:
GET /users- List all users (calls yourfindAllhandler)POST /users- Create a new user (calls yourcreatehandler)GET /users/:id- Get a specific user (calls yourfindOnehandler)PUT /users/:id- Update a user (calls yourupdatehandler)DELETE /users/:id- Delete a user (calls yourdeletehandler)
Testing Your API
You can test your API using curl or any HTTP client:
Next Steps
Now that you have a basic understanding of Frey, explore these topics:
- Entity Configuration - Learn about advanced entity options
- Custom Routes - Add custom endpoints to your entities
- Parameter Handling - Understand how Frey handles query parameters
- Type Safety - Leverage TypeScript for maximum type safety
- Examples - See real-world examples and use cases
Need Help?
- Check out the API Reference for detailed documentation
- Look at Examples for inspiration
- Join our community discussions for support