Introduction
The Gitea API provides programmatic access to Gitea’s features, allowing you to automate repository management, user administration, issue tracking, and more. The API follows REST principles and returns JSON responses.Base URL
The API is versioned and all endpoints are prefixed with/api/v1/:
Replace
your-gitea-instance.com with your actual Gitea server domain.API Versioning
Gitea currently uses API version 1 (v1) as the stable API version. The version is included in the URL path:
- Current Version:
v1 - Base Path:
/api/v1/ - Full URL Pattern:
https://{domain}/api/v1/{endpoint}
Content Types
The API consumes and produces the following content types: Consumes:application/jsontext/plain
application/json(default)text/html(for specific endpoints)
Always set the
Content-Type: application/json header when sending JSON data in request bodies.Response Formats
All API responses use JSON format. Successful responses return the requested data with appropriate HTTP status codes:- 200 OK: Request succeeded
- 201 Created: Resource created successfully
- 204 No Content: Request succeeded with no content to return
- 400 Bad Request: Invalid request parameters
- 401 Unauthorized: Authentication required or failed
- 403 Forbidden: Insufficient permissions
- 404 Not Found: Resource not found
- 422 Unprocessable Entity: Validation error
Pagination
Many list endpoints support pagination through query parameters:page: Page number (default: 1)limit: Items per page (default: 30, max: 50)
Pagination limits are configurable in the server settings:
API.MaxResponseItems: Maximum items per page (default: 50)API.DefaultPagingNum: Default items per page (default: 30)
Rate Limiting
Gitea does not enforce built-in API rate limiting at the application level. However, rate limiting may be implemented through:- Reverse Proxy: Configure rate limiting in nginx, Apache, or other reverse proxies
- External Migration: Rate limits apply when migrating repositories from external sources (e.g., GitHub)
CORS Support
CORS (Cross-Origin Resource Sharing) can be enabled in the Gitea configuration:Access-Control-Allow-OriginAccess-Control-Allow-MethodsAccess-Control-Allow-HeadersAccess-Control-Max-Age
Swagger Documentation
Gitea provides interactive Swagger/OpenAPI documentation for the API. Access it at:- Browse all available endpoints
- View request/response schemas
- Test API calls directly from the browser
- Download the OpenAPI specification
Swagger documentation can be enabled/disabled via the
API.EnableSwagger configuration option (enabled by default).API Settings
The following settings can be configured inapp.ini:
Security Schemes
The API supports multiple authentication methods:- BasicAuth: HTTP Basic Authentication
- Token: API token in query parameter (deprecated)
- AccessToken: Access token in query parameter (deprecated)
- AuthorizationHeaderToken: Bearer token in Authorization header (recommended)
- SudoParam: Sudo parameter for admin impersonation
- SudoHeader: Sudo header for admin impersonation
- TOTPHeader: TOTP header for two-factor authentication
Next Steps
Authentication
Learn about authentication methods and token management
API Reference
Explore the complete API endpoint reference