Skip to main content

REST API Referansı

Temel Ayarlar

Temel URL: {site_url}/wp-json/wu/v2/ Kimlik Doğrulama: API Anahtarı ve Gizli Anahtar (HTTP Basic Auth veya URL Parametreleri)

Kimlik Doğrulama

API'yi Etkinleştirme

// Ultimate Multisite ayarlarından veya programatik olarak API'yi etkinleştirir
wu_save_setting('enable_api', true);

API Kimlik Bilgilerini Alma

$api_key = wu_get_setting('api_key');
$api_secret = wu_get_setting('api_secret');

Kimlik Doğrulama Yöntemleri

HTTP Basic Auth (Önerilen):

curl -u "api_key:api_secret" https://yoursite.com/wp-json/wu/v2/customers

URL Parametreleri:

curl "https://yoursite.com/wp-json/wu/v2/customers?api_key=your_key&api_secret=your_secret"

Temel Uç Noktalar

1. Müşteriler API'si

Temel Rota: /customers

Tüm Müşterileri Alma

GET /wu/v2/customers

Tek Bir Müşteriyi Alma

GET /wu/v2/customers/{id}

Müşteri Oluşturma

POST /wu/v2/customers
Content-Type: application/json

{
"user_id": 123,
"email_verification": "verified",
"type": "customer",
"has_trialed": false,
"vip": false
}

Müşteriyi Güncelleme

PUT /wu/v2/customers/{id}
Content-Type: application/json

{
"vip": true,
"extra_information": "VIP müşteri notları"
}

Müşteriyi Silme

DELETE /wu/v2/customers/{id}

2. Siteler API'si

Temel Rota: /sites

Site Oluşturma

POST /wu/v2/sites
Content-Type: application/json

{
"customer_id": 5,
"membership_id": 10,
"domain": "example.com",
"path": "/",
"title": "My New Site",
"template_id": 1,
"type": "customer_owned"
}

3. Üyelikler API'si

Temel Rota: /memberships

Üyelik Oluşturma

POST /wu/v2/memberships
Content-Type: application/json

{
"customer_id": 5,
"plan_id": 3,
"status": "active",
"gateway": "stripe",
"gateway_subscription_id": "sub_1234567890",
"auto_renew": true
}

4. Ürünler API'si

Temel Rota: /products

Tüm Ürünleri Alma

GET /wu/v2/products

5. Ödemeler API'si

Temel Rota: /payments

Ödeme Oluşturma

POST /wu/v2/payments
Content-Type: application/json

{
"customer_id": 5,
"membership_id": 10,
"status": "completed",
"gateway": "stripe",
"gateway_payment_id": "pi_1234567890",
"total": 29.99,
"currency": "USD"
}

6. Alan Adları API'si

Temel Rota: /domains

Alan Adı Eşleme

POST /wu/v2/domains
Content-Type: application/json

{
"domain": "custom-domain.com",
"customer_id": 5,
"primary_domain": 1,
"stage": "domain-mapping"
}

Kayıt Uç Noktası

/register uç noktası, eksiksiz bir ödeme/kayıt akışı sağlar:

POST /wu/v2/register
Content-Type: application/json

{
"customer": {
"username": "newuser",
"password": "securepass123",
"email": "[email protected]"
},
"products": ["basic-plan"],
"duration": 1,
"duration_unit": "month",
"auto_renew": true,
"site": {
"site_url": "mynewsite",
"site_title": "My New Site",
"template_id": 1
},
"payment": {
"status": "completed"
},
"membership": {
"status": "active"
}
}

Yanıt:

{
"customer": { ... },
"membership": { ... },
"payment": { ... },
"site": { "id": 123 }
}

Hata Yanıtları

{
"code": "wu_rest_invalid_parameter",
"message": "Invalid parameter value",
"data": {
"status": 400,
"params": {
"email": "Invalid email format"
}
}
}

Sayfalama ve Filtreleme

Sorgu Parametreleri:

GET /wu/v2/customers?per_page=20&page=2&search=john&status=active

Yaygın parametreler:

  • per_page - Sayfa başına öğe sayısı (varsayılan: 20, maksimum: 100)
  • page - Sayfa numarası
  • search - Aranacak terim
  • orderby - Sıralama alanı
  • order - Sıralama yönü (asc/desc)
  • status - Duruma göre filtreleme
  • date_created - Tarih aralığına göre filtreleme