gityar provides a comprehensive REST API that allows you to automate tasks, integrate with other tools, and build custom applications.
curl -u "username:password" http://localhost:3000/api/v1/user
Generate a token in Settings → Applications → Generate New Token
curl -H "Authorization: token YOUR_TOKEN" http://localhost:3000/api/v1/user
curl http://localhost:3000/api/v1/user?token=YOUR_TOKEN
http://localhost:3000/api/v1
Or your configured domain:
https://gityar.example.com/api/v1
GET /api/v1/user
Response:
{
"id": 1,
"login": "username",
"full_name": "Full Name",
"email": "user@example.com",
"avatar_url": "http://localhost:3000/user/avatar/username",
"created_at": "2024-01-01T00:00:00Z"
}
GET /api/v1/users/:username
GET /api/v1/user/repos
GET /api/v1/users/:username/repos
GET /api/v1/repos/:owner/:repo
POST /api/v1/user/repos
{
"name": "my-repo",
"description": "My repository",
"private": false,
"auto_init": true
}
DELETE /api/v1/repos/:owner/:repo
GET /api/v1/repos/:owner/:repo/issues
GET /api/v1/issues?filter=all
POST /api/v1/repos/:owner/:repo/issues
{
"title": "Bug: Something broken",
"body": "Detailed description",
"labels": [1, 2],
"assignee": "username"
}
GET /api/v1/repos/:owner/:repo/issues/:index
PATCH /api/v1/repos/:owner/:repo/issues/:index
{
"title": "Updated title",
"state": "closed"
}
GET /api/v1/repos/:owner/:repo/pulls
POST /api/v1/repos/:owner/:repo/pulls
{
"title": "Add new feature",
"body": "Description of changes",
"head": "feature-branch",
"base": "main"
}
POST /api/v1/repos/:owner/:repo/pulls/:index/merge
GET /api/v1/user/orgs
GET /api/v1/orgs/:org
POST /api/v1/orgs
{
"username": "my-org",
"full_name": "My Organization"
}
GET /api/v1/repos/:owner/:repo/hooks
POST /api/v1/repos/:owner/:repo/hooks
{
"type": "gitea",
"config": {
"url": "https://example.com/webhook",
"content_type": "json",
"secret": "your-secret"
},
"events": ["push", "issues"],
"active": true
}
All list endpoints support pagination:
GET /api/v1/user/repos?page=2&limit=20
Response headers include:
X-Page: Current page numberX-PerPage: Items per pageX-Total-Count: Total itemsAPI requests are rate-limited to prevent abuse.
Headers:
X-RateLimit-Limit: Maximum requests per hourX-RateLimit-Remaining: Remaining requestsX-RateLimit-Reset: Time when limit resets{
"message": "Invalid request",
"url": "http://localhost:3000/api/v1"
}
{
"message": "Unauthorized"
}
{
"message": "Repository not found",
"url": "http://localhost:3000/api/v1"
}
{
"message": "Validation failed",
"errors": [
{
"resource": "Repository",
"field": "name",
"code": "invalid"
}
]
}
import requests
# Authentication
headers = {
'Authorization': 'token YOUR_TOKEN'
}
# List repositories
response = requests.get(
'http://localhost:3000/api/v1/user/repos',
headers=headers
)
repos = response.json()
for repo in repos:
print(repo['full_name'])
# Create issue
response = requests.post(
'http://localhost:3000/api/v1/repos/owner/repo/issues',
headers=headers,
json={
'title': 'Bug report',
'body': 'Detailed description'
}
)
const axios = require('axios');
const client = axios.create({
baseURL: 'http://localhost:3000/api/v1',
headers: {
'Authorization': 'token YOUR_TOKEN'
}
});
// List repositories
async function listRepos() {
const response = await client.get('/user/repos');
return response.data;
}
// Create issue
async function createIssue(owner, repo, issue) {
const response = await client.post(
`/repos/${owner}/${repo}/issues`,
issue
);
return response.data;
}
# Get user info
curl -H "Authorization: token YOUR_TOKEN" \
http://localhost:3000/api/v1/user
# Create repository
curl -X POST \
-H "Authorization: token YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"my-repo","description":"My repository"}' \
http://localhost:3000/api/v1/user/repos