Skip to main content

Referans REST API

Konfigirasyon Baz​

URL Baz: {site_url}/wp-json/wu/v2/ Otantifikasyon: Kle API ak Sekrè (HTTP Basic Auth oswa Paramèt URL)

Otantifikasyon​

Aktive API​

// Enable API in Ultimate Multisite settings or programmatically
wu_save_setting('enable_api', true);

Jwenn Idantifyan API​

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

Metòd Otantifikasyon​

HTTP Basic Auth (Rekòmande):

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

Paramèt URL:

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

Pwen Final Prensipal yo​

1. API Kliyan​

Wout Baz: /customers

Jwenn Tout Kliyan yo

GET /wu/v2/customers

Jwenn Yon Sèl Kliyan

GET /wu/v2/customers/{id}

Kreye Kliyan

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

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

Mete Kliyan Ajou

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

{
"vip": true,
"extra_information": "VIP customer notes"
}

Efase Kliyan

DELETE /wu/v2/customers/{id}

2. API Sit yo​

Wout Baz: /sites

Kreye Sit

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. API Abònman yo​

Wout Baz: /memberships

Kreye Abònman

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. API Pwodwi yo​

Wout Baz: /products

Jwenn Tout Pwodwi yo

GET /wu/v2/products

5. API Peman yo​

Wout Baz: /payments

Kreye Peman

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. API Domèn yo​

Wout Baz: /domains

Mape Domèn

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

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

Pwen Final Enskripsyon​

Pwen final /register la bay yon koule checkout/enskripsyon konplè:

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"
}
}

Repons:

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

Pwen Final Lokatè Souvren yo​

Ultimate Multisite: Multi-Tenancy 1.2.0 ajoute kouvèti REST pou lokatè souvren pou entegrasyon ki pwovizyone, enspekte, oswa verifye lokatè izole yo.

Chaj demann egzak la depann de kapasite host ki aktive a, men entegrasyon yo ta dwe atann gwoup pwen final sa yo:

POST /wu/v2/tenants/{site_id}/bootstrap
GET /wu/v2/tenants/{site_id}/migration-status
POST /wu/v2/tenants/{site_id}/verify
DELETE /wu/v2/tenants/{site_id}

Sèvi ak pwen final bootstrap la pou prepare rejis lokatè a, baz done, sistèm fichye, ak eta routaj la. Sèvi ak pwen final estati migrasyon ak verifikasyon yo anvan ou chanje trafik pwodiksyon an. Sèvi ak pwen final efasman an pou demantèlman souvren pou yo retire idantifyan baz done yo atravè koule netwayaj modil siplemantè a.

Repons tipik pou estati migrasyon gen ladan:

{
"site_id": 123,
"isolation_model": "sovereign",
"database_host": "localhost",
"verification": {
"no_legacy": "passed",
"sovereign_push": "passed",
"tenant_users": "passed"
},
"ready": true
}

Trete ready: false kòm yon blokaj anvan lansman. Tcheke detay verifikasyon yo, korije atachman host baz done a, keu a, pwovizyon itilizatè a, oswa pwoblèm routaj la, epi eseye verifikasyon ankò.

Repons Erè​

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

Pajinen ak Filtraj​

Paramèt Rekèt:

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

Paramèt komen:

  • per_page - Atik pa paj (defo: 20, maksimòm: 100)
  • page - Nimewo paj
  • search - Tèm rechèch
  • orderby - Chan tri
  • order - Direksyon tri (asc/desc)
  • status - Filtre pa estati
  • date_created - Filtre pa entèval dat