gityar, görevleri otomatikleştirmenizi, diğer araçlarla entegrasyonlar oluşturmanızı ve özel uygulamalar geliştirmenizi sağlayan kapsamlı bir REST API sağlar.
curl -u "username:password" http://localhost:3000/api/v1/user
Ayarlar → Uygulamalar → Yeni Belirteç Oluştur'da bir belirteç oluşturun
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
Veya yapılandırılmış alan adınız:
https://gityar.example.com/api/v1
GET /api/v1/user
Yanıt:
{
"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": "Benim depom",
"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": "Hata: Bir şey bozuk",
"body": "Ayrıntılı açıklama",
"labels": [1, 2],
"assignee": "username"
}
GET /api/v1/repos/:owner/:repo/issues/:index
PATCH /api/v1/repos/:owner/:repo/issues/:index
{
"title": "Güncellenmiş başlık",
"state": "closed"
}
GET /api/v1/repos/:owner/:repo/pulls
POST /api/v1/repos/:owner/:repo/pulls
{
"title": "Yeni özellik ekle",
"body": "Değişikliklerin açıklaması",
"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": "Benim Organizasyonum"
}
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
}
Tüm liste endpoint'leri sayfalama destekler:
GET /api/v1/user/repos?page=2&limit=20
Yanıt başlıkları içerir:
X-Page: Mevcut sayfa numarasıX-PerPage: Sayfa başına öğeX-Total-Count: Toplam öğe sayısıAPI istekleri kötüye kullanımı önlemek için hız sınırlıdır.
Başlıklar:
X-RateLimit-Limit: Saat başına maksimum istekX-RateLimit-Remaining: Kalan isteklerX-RateLimit-Reset: Sınırın sıfırlandığı zaman{
"message": "Geçersiz istek",
"url": "http://localhost:3000/api/v1"
}
{
"message": "Yetkisiz"
}
{
"message": "Depo bulunamadı",
"url": "http://localhost:3000/api/v1"
}
{
"message": "Doğrulama başarısız",
"errors": [
{
"resource": "Repository",
"field": "name",
"code": "invalid"
}
]
}
import requests
# Kimlik doğrulama
headers = {
'Authorization': 'token YOUR_TOKEN'
}
# Depoları listele
response = requests.get(
'http://localhost:3000/api/v1/user/repos',
headers=headers
)
repos = response.json()
for repo in repos:
print(repo['full_name'])
# Sorun oluştur
response = requests.post(
'http://localhost:3000/api/v1/repos/owner/repo/issues',
headers=headers,
json={
'title': 'Hata raporu',
'body': 'Ayrıntılı açıklama'
}
)
const axios = require('axios');
const client = axios.create({
baseURL: 'http://localhost:3000/api/v1',
headers: {
'Authorization': 'token YOUR_TOKEN'
}
});
// Depoları listele
async function listRepos() {
const response = await client.get('/user/repos');
return response.data;
}
// Sorun oluştur
async function createIssue(owner, repo, issue) {
const response = await client.post(
`/repos/${owner}/${repo}/issues`,
issue
);
return response.data;
}
# Kullanıcı bilgilerini al
curl -H "Authorization: token YOUR_TOKEN" \
http://localhost:3000/api/v1/user
# Depo oluştur
curl -X POST \
-H "Authorization: token YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"my-repo","description":"Benim depom"}' \
http://localhost:3000/api/v1/user/repos