TypeAPI - An OpenAPI alternative for type-safe code generation.
An OpenAPI alternative to describe REST APIs for type-safe code generation. Clean syntax, human-readable, and developer-first.
How TypeAPI Works
Explore how TypeAPI handles everything from simple endpoints to complex technical scenarios with type-safe code generation.
{
"operations": {
"getMessage": {
"method": "GET",
"path": "/hello/world",
"return": {
"schema": {
"type": "reference",
"target": "Hello_World"
}
}
}
},
"definitions": {
"Hello_World": {
"type": "struct",
"properties": {
"message": {
"type": "string"
}
}
}
}
}const client = new Client() const response = await client.getMessage() interface HelloWorld { message?: string }
Simple API
A simple GET endpoint which returns a hello world message.
{
"operations": {
"getAll": {
"method": "GET",
"path": "/todo",
"arguments": {
"startIndex": {
"in": "query",
"schema": {
"type": "integer"
}
},
"count": {
"in": "query",
"schema": {
"type": "integer"
}
}
},
"return": {
"schema": {
"type": "reference",
"target": "Todos"
}
}
}
}
}const client = new Client() const response = await client.getAll(0, 10) interface Todos { entries?: Todo[] }
Argument Query
Map values from the HTTP request to arguments, in this example we map query parameters to startIndex and count.
{
"operations": {
"create": {
"method": "POST",
"path": "/todo",
"arguments": {
"payload": {
"in": "body",
"schema": {
"type": "reference",
"target": "Todo"
}
}
},
"return": {
"schema": {
"type": "reference",
"target": "Message"
}
}
}
}
}const client = new Client() const response = await client.create({ title: "hello world" }) interface Message { success?: boolean message?: string }
Argument Body
In this example we map the HTTP request body to the payload argument.
{
"operations": {
"getMessage": {
"method": "GET",
"path": "/hello/world",
"throws": [{
"code": 500,
"schema": {
"type": "reference",
"target": "Error"
}
}]
}
}
}try { const response = await client.getMessage() } catch (e) { if (e instanceof ErrorException) { const error = e.getPayload() } }
Throws
Define specific error payloads, the generated client will then also throw an exception in case of error codes.
{
"operations": {
"todo.create": {
"method": "POST",
"path": "/todo"
},
"product.create": {
"method": "POST",
"path": "/product"
}
}
}const client = new Client() await client.todo().create(payload) await client.product().create(payload)
Operation Group
Through the dot notation at the operation key you can group your operations into logical units.
Built for Modern Teams
Our code generator uses proven technology to generate fully type-safe client/server pairs across the most popular ecosystems. From C# to TypeScript, we've got you covered.
| Language | Client | Server |
|---|---|---|
| C# | HttpClient | ASP Web-API |
| Java | Apache | Spring |
| TypeScript | Fetch | NestJS |
| PHP | Guzzle | Symfony |
| Python | Requests | FastAPI |
Ready to build better APIs?
Join the ecosystem of tools designed for the next generation of type-safe backend development.