Skip to content

API Overview

The Swit framework provides a rich set of APIs for building microservice applications. This documentation provides a complete reference for the framework's core APIs.

Core APIs

Server API

The Server API is the heart of the framework, providing service lifecycle management, configuration, and dependency injection capabilities.

Transport API

The Transport API manages HTTP and gRPC communication.

Middleware API

The Middleware API provides extension points for request processing.

Service APIs

Swit Serve API

Complete REST API for user management service.

Swit Auth API

Authentication and authorization service API.

API Conventions

Request Format

All API requests should use JSON format:

json
{
  "field1": "value1",
  "field2": "value2"
}

Response Format

Standard response format:

json
{
  "code": 0,
  "message": "success",
  "data": {}
}

Error Handling

Error response format:

json
{
  "code": 400,
  "message": "Invalid request",
  "error": {
    "field": "username",
    "reason": "required"
  }
}

Versioning

APIs use URL path versioning:

  • /api/v1/ - Version 1
  • /api/v2/ - Version 2 (future)

Authentication

Most APIs require authentication. The following authentication methods are supported:

  • Bearer Token: Authorization: Bearer <token>
  • API Key: X-API-Key: <key>

Rate Limiting

API requests are protected by rate limiting:

  • Default limit: 100 requests per minute
  • Authenticated users: 1000 requests per minute

More Information

Released under the MIT License.