REST API
REST-API im Namespace polski/v1/. Verwalten Sie Einstellungen, rechtliche Checkboxen, Rechtsseiten und die Produktsuche.
Authentifizierung
Section titled “Authentifizierung”Die API erfordert eine Authentifizierung für datenverändernde Endpunkte (POST, PUT, DELETE). Der Such-Endpunkt (/search) ist öffentlich zugänglich.
Unterstützte Authentifizierungsmethoden:
- Application Passwords (WordPress 5.6+) - empfohlen
- Cookie + Nonce - für Anfragen aus dem Admin-Bereich
- Basic Auth (mit dem Plugin Basic Auth) - nur für die Entwicklung
Erforderliche Berechtigung: manage_woocommerce (standardmäßig die Rollen Administrator und Shop-Manager).
Endpunkte
Section titled “Endpunkte”GET /polski/v1/settings
Section titled “GET /polski/v1/settings”Ruft alle Einstellungsgruppen des Plugins ab.
Berechtigungen: manage_woocommerce
Beispielanfrage:
curl -u admin:XXXX-XXXX-XXXX-XXXX \ "https://yourstore.com/wp-json/polski/v1/settings"Beispielantwort:
{ "groups": [ { "id": "general", "label": "General settings", "description": "Basic plugin configuration" }, { "id": "compliance", "label": "Legal requirements", "description": "EU and Polish law requirements settings" }, { "id": "storefront", "label": "Storefront modules", "description": "Store extension modules" }, { "id": "checkout", "label": "Checkout and orders", "description": "Checkout and order process settings" } ]}GET /polski/v1/settings/{group}
Section titled “GET /polski/v1/settings/{group}”Ruft die Einstellungen aus einer ausgewählten Gruppe ab.
URL-Parameter:
| Parameter | Typ | Beschreibung |
|---|---|---|
group | string | ID der Einstellungsgruppe |
Berechtigungen: manage_woocommerce
Beispielanfrage:
curl -u admin:XXXX-XXXX-XXXX-XXXX \ "https://yourstore.com/wp-json/polski/v1/settings/compliance"Beispielantwort:
{ "group": "compliance", "settings": { "omnibus_enabled": true, "omnibus_days": 30, "gpsr_enabled": true, "withdrawal_enabled": true, "withdrawal_days": 14, "dsa_enabled": true, "ksef_enabled": false, "greenwashing_enabled": true }}POST /polski/v1/settings/{group}
Section titled “POST /polski/v1/settings/{group}”Aktualisiert die Einstellungen in einer ausgewählten Gruppe.
Berechtigungen: manage_woocommerce
Beispielanfrage:
curl -X POST \ -u admin:XXXX-XXXX-XXXX-XXXX \ -H "Content-Type: application/json" \ -d '{"omnibus_days": 30, "withdrawal_days": 14}' \ "https://yourstore.com/wp-json/polski/v1/settings/compliance"Beispielantwort:
{ "updated": true, "group": "compliance", "changes": { "omnibus_days": 30, "withdrawal_days": 14 }}GET /polski/v1/checkboxes
Section titled “GET /polski/v1/checkboxes”Ruft eine Liste aller rechtlichen Checkboxen ab (Kasse, Registrierung, Kontakt).
Berechtigungen: manage_woocommerce
Beispielantwort:
{ "checkboxes": [ { "id": 1, "label": "I accept the store terms and conditions", "required": true, "location": "checkout", "enabled": true, "position": 10, "legal_page_id": 45 }, { "id": 2, "label": "I have read the privacy policy", "required": true, "location": "checkout", "enabled": true, "position": 20, "legal_page_id": 47 } ], "total": 2}GET /polski/v1/checkboxes/stats
Section titled “GET /polski/v1/checkboxes/stats”Ruft Statistiken zur Zustimmung bei Checkboxen ab.
Berechtigungen: manage_woocommerce
Beispielantwort:
{ "stats": [ { "checkbox_id": 1, "label": "I accept the store terms and conditions", "total_shown": 1250, "total_accepted": 1180, "acceptance_rate": 94.4 } ]}GET /polski/v1/checkboxes/{id}
Section titled “GET /polski/v1/checkboxes/{id}”Ruft die Details einer einzelnen Checkbox ab.
URL-Parameter:
| Parameter | Typ | Beschreibung |
|---|---|---|
id | int | ID der Checkbox |
Berechtigungen: manage_woocommerce
Beispielantwort:
{ "id": 1, "label": "I accept the store terms and conditions", "required": true, "location": "checkout", "enabled": true, "position": 10, "legal_page_id": 45, "created_at": "2025-01-15T10:30:00", "updated_at": "2025-06-01T14:22:00", "stats": { "total_shown": 1250, "total_accepted": 1180, "acceptance_rate": 94.4 }}PUT /polski/v1/checkboxes/{id}
Section titled “PUT /polski/v1/checkboxes/{id}”Aktualisiert eine Checkbox.
Berechtigungen: manage_woocommerce
Beispielanfrage:
curl -X PUT \ -u admin:XXXX-XXXX-XXXX-XXXX \ -H "Content-Type: application/json" \ -d '{"label": "I accept the terms", "required": true}' \ "https://yourstore.com/wp-json/polski/v1/checkboxes/1"GET /polski/v1/legal-pages
Section titled “GET /polski/v1/legal-pages”Ruft eine Liste der Rechtsseiten ab (AGB, Datenschutzerklärung usw.).
Berechtigungen: manage_woocommerce
Beispielantwort:
{ "pages": [ { "id": 45, "type": "terms", "title": "Store terms and conditions", "status": "publish", "url": "https://yourstore.com/terms/", "last_modified": "2025-06-01T14:00:00", "word_count": 3200 }, { "id": 47, "type": "privacy", "title": "Privacy policy", "status": "publish", "url": "https://yourstore.com/privacy-policy/", "last_modified": "2025-05-15T09:30:00", "word_count": 2800 } ], "total": 2}POST /polski/v1/legal-pages/generate
Section titled “POST /polski/v1/legal-pages/generate”Generiert eine Rechtsseite auf Grundlage einer Vorlage.
Berechtigungen: manage_woocommerce
Body-Parameter:
| Parameter | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
type | string | Ja | Seitentyp: terms, privacy, withdrawal, dsa_report |
company_name | string | Ja | Firmenname |
company_address | string | Ja | Firmenadresse |
email | string | Ja | Kontakt-E-Mail-Adresse |
phone | string | Nein | Telefonnummer |
nip | string | Nein | NIP der Firma |
Beispielanfrage:
curl -X POST \ -u admin:XXXX-XXXX-XXXX-XXXX \ -H "Content-Type: application/json" \ -d '{"type": "terms", "company_name": "My Store Sp. z o.o.", "company_address": "ul. Przykladowa 1, 00-001 Warsaw", "email": "[email protected]"}' \ "https://yourstore.com/wp-json/polski/v1/legal-pages/generate"Beispielantwort:
{ "page_id": 120, "type": "terms", "title": "Store terms and conditions", "url": "https://yourstore.com/terms/", "status": "draft"}GET /polski/v1/search
Section titled “GET /polski/v1/search”Produktsuche (öffentlicher Endpunkt).
Query-Parameter:
| Parameter | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
q | string | Ja | Suchbegriff |
limit | int | Nein | Ergebnislimit (Standard 8) |
cat | int | Nein | Kategorie-ID |
Berechtigungen: öffentlich (keine Authentifizierung erforderlich)
Beispielanfrage:
curl "https://yourstore.com/wp-json/polski/v1/search?q=shoes&limit=5"Beispielantwort:
{ "results": [ { "id": 456, "title": "Nike Sports Shoes", "url": "https://yourstore.com/product/nike-sports-shoes/", "image": "https://yourstore.com/wp-content/uploads/nike-shoes.jpg", "price_html": "<span class=\"amount\">299.00 PLN</span>", "category": "Footwear", "in_stock": true, "rating": 4.8 } ], "total": 1, "query": "shoes"}POST /polski/v1/wizard/complete
Section titled “POST /polski/v1/wizard/complete”Markiert den Konfigurationsassistenten als abgeschlossen.
Berechtigungen: manage_woocommerce
Body-Parameter:
| Parameter | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
steps_completed | array | Ja | Liste der abgeschlossenen Schritte |
Beispielanfrage:
curl -X POST \ -u admin:XXXX-XXXX-XXXX-XXXX \ -H "Content-Type: application/json" \ -d '{"steps_completed": ["company_info", "legal_pages", "checkboxes", "compliance"]}' \ "https://yourstore.com/wp-json/polski/v1/wizard/complete"Beispielantwort:
{ "completed": true, "completed_at": "2025-06-15T12:00:00", "steps": { "company_info": true, "legal_pages": true, "checkboxes": true, "compliance": true }}HTTP-Antwortcodes
Section titled “HTTP-Antwortcodes”| Code | Beschreibung |
|---|---|
| 200 | Erfolg |
| 201 | Ressource erstellt (POST) |
| 400 | Fehlerhafte Anfrage (fehlende Parameter) |
| 401 | Nicht authentifiziert |
| 403 | Unzureichende Berechtigungen |
| 404 | Ressource nicht gefunden |
| 500 | Serverfehler |
Antwortfilterung
Section titled “Antwortfilterung”Jeder Endpunkt unterstützt einen WordPress-Filter, der die Änderung der Antwort ermöglicht:
add_filter('polski/rest/settings_response', function (array $response, WP_REST_Request $request): array { // Antwort ändern return $response;}, 10, 2);Rate Limiting
Section titled “Rate Limiting”Die API implementiert kein eigenes Rate Limiting. Für öffentliche Endpunkte wird die Verwendung eines Plugins oder einer Serverkonfiguration (z. B. Cloudflare, Nginx Rate Limiting) empfohlen.
Probleme melden: github.com/wppoland/polski/issues