Shopify API
GET /api/v1/shopify/oauth/authorize
Shopify OAuth-Flow starten.
Rate Limit: 5 Requests / Minute / User
Query-Parameter:
| Parameter | Typ | Beschreibung |
|---|---|---|
shop | string | z.B. mein-shop.myshopify.com |
Response (200):
{
"data": {
"authorize_url": "https://mein-shop.myshopify.com/admin/oauth/authorize?..."
}
}
Logik:
- Generiert CSRF-Nonce (UUID)
- Speichert State + 10-Min-Expiry in DB
- Gibt Shopify Authorization-URL zurück
GET /api/v1/shopify/oauth/callback
OAuth-Callback (Browser-Redirect, keine Auth nötig).
Rate Limit: 10 Requests / Minute / IP
Query-Parameter:
| Parameter | Beschreibung |
|---|---|
code | Auth-Code von Shopify |
state | CSRF-Nonce |
shop | Shop-URL |
hmac | Shopify HMAC-Signatur |
timestamp | Zeitstempel |
Response: Redirect zu /dashboard/settings?tab=shopify&shopify=connected
Logik:
- HMAC-Signatur validieren
- State-Nonce prüfen + Expiry
- Code gegen permanenten Access-Token tauschen
- Token mit pgcrypto AES-256 verschlüsseln
- Verbindung testen + Locations synchronisieren
- Vollsync-Job in Queue einreihen
POST /api/v1/shopify/sync
Manuellen Sync triggern.
Rate Limit: 3 Requests / 2 Minuten / User
Request:
{ "type": "full" }
Optionen: full | incremental
Response (200):
{
"data": {
"type": "full",
"status": "queued",
"message": "Vollsync wurde eingeplant"
}
}
Prüfungen:
- Shopify-Verbindung muss existieren
- Usage-Limit des Plans wird geprüft
Sync-Architektur
POST /shopify/sync → Job in Queue → Cron /cron/shopify-queue (jede Minute)
↓
Verarbeitung mit Retry (5 Versuche, Exponential Backoff)
↓
Shopify Mirror-Tabellen aktualisiert
Job-Typen:
full_sync— Alle Produkte, Bestellungen, Kundenincremental_sync— Nur Änderungen seit letztem Syncinventory_push— Bestand an Shopify senden
Mirror-Tabellen (read-only):
shopify_productsshopify_product_variantsshopify_ordersshopify_fulfillmentsshopify_customers
Inventar-Sync: Roestify → Shopify (bei Abpackung)
Datenfluss: Shopify ist Quelle für Produkte/Orders. Roestify ist Quelle für Inventar.