Bir API ne kadar iyi tasarlanmış olursa olsun, dokümantasyonu yoksa kullanılamaz. Geliştirici deneyimi (DX), API'nin benimsenmesinde belirleyicidir.
OpenAPI şeması
openapi: 3.0.3
info:
title: Arivo API
version: 2.4.0
description: Arivo yazılım pazaryeri API'si
servers:
- url: https://api.arivo.com.tr/v2
paths:
/urunler:
get:
summary: Ürün listesi
parameters:
- name: page
in: query
schema: { type: integer, minimum: 1, default: 1 }
- name: limit
in: query
schema: { type: integer, minimum: 1, maximum: 100, default: 12 }
- name: q
in: query
schema: { type: string }
responses:
'200':
description: Başarılı
content:
application/json:
schema:
type: object
properties:
data:
type: array
items: { $ref: '#/components/schemas/Urun' }
meta:
$ref: '#/components/schemas/Sayfalama'
components:
schemas:
Urun:
type: object
required: [id, ad, fiyat]
properties:
id: { type: integer, example: 42 }
ad: { type: string, example: PHP Kurulum Paketi }
fiyat: { type: number, format: float, example: 199.90 }
slug: { type: string }
Sayfalama:
type: object
properties:
page: { type: integer }
total: { type: integer }
Tutarlı hata şeması
{
"hata": true,
"kod": "VALIDATION_ERROR",
"mesaj": "Doğrulama başarısız.",
"alanlar": {
"email": "Bu e-posta zaten kayıtlı.",
"fiyat": "Fiyat 50 TL'den küçük olamaz."
},
"istek_id": "req_8f3a2b"
}
istek_id alanı, kullanıcının destek talebinde bu kimliği paylaşmasına izin verir; hata ayıklamayı hızlandırır.
Örnek yanıtlar
// Basarili
{
"data": [{ "id": 42, "ad": "PHP Paketi", "fiyat": 199.90 }],
"meta": { "page": 1, "total": 137, "total_pages": 12 }
}
// Sayfa disi
HTTP/1.1 400 Bad Request
{ "hata": true, "kod": "INVALID_PAGE", "mesaj": "sayfa en fazla 12 olabilir." }
Sürüm oluşturma
# CLI ile
npx @redocly/cli openapi-cli bundle openapi.yaml -o dist/openapi.json
npx @redocly/cli openapi-cli lint openapi.yaml
# Her commit'te dogrula
npx @redocly/cli openapi-cli lint openapi.yaml --fail-on-errors
Etkileşimli dokümantasyon
<!-- Scalar / Redoc -->
<script id="api-reference" data-url="/openapi.json"></script>
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
<!-- veya Swagger UI -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swagger-ui-dist/swagger-ui.css">
<script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist/swagger-ui-bundle.js"></script>
<script>SwaggerUIBundle({ url: '/openapi.json' });</script>
Örnek kod
// Her yanitta calistirilabilir ornek
const yanit = await fetch(
'https://api.arivo.com.tr/v2/urunler?limit=5&kategori=php',
{ headers: { 'Authorization': 'Bearer TOKEN' } }
);
if (!yanit.ok) {
const hata = await yanit.json();
throw new Error(hata.mesaj);
}
const { data } = await yanit.json();
Changelog
## 2.4.0 — 2026-10-07
### Yeni
- `GET /urunler` isteklerine `fields` parametresi eklendi
### Düzeltme
- Sayfalama limiti 100 ile sınırlandırıldı
### Kırıcı değişiklik yok
İstemci SDK
PHP, JavaScript ve Python istemcileri için ince SDK katmanı, entegrasyonu hızlandırır:
export class ArivoClient {
constructor(apiKey) { this.key = apiKey; }
async urunler(filtre = {}) {
const q = new URLSearchParams(filtre);
const r = await fetch(`https://api.arivo.com.tr/v2/urunler?${q}`, {
headers: { Authorization: `Bearer ${this.key}` },
});
if (!r.ok) throw new ArivoError(await r.json());
return r.json();
}
}
Sık yapılan hatalar
- Dokümantasyonu ayrı bir ekipten yazdırmak — güncellenmez.
- Hata şemasında tutarsızlık.
- Sürüm değişikliğini changelog'da belirtmemek.
- Örneklerin gerçek veri yapmaması.
Sonuç
Şemayı koda yakın tutmak (aynı depoda) dokümantasyonu güncel tutmanın en etkili yoludur. CI'da şema doğrulaması çalıştırın; yanlışlık yakalanmadan yayına çıkmasın.
Arivo'da PHP scriptler, temalar ve eklentiler bulun. Kurulum desteği dahil.
Mağazaya Git