Zum Hauptinhalt springen

Shopify API

GET /api/v1/shopify/oauth/authorize

Shopify OAuth-Flow starten.

Rate Limit: 5 Requests / Minute / User

Query-Parameter:

ParameterTypBeschreibung
shopstringz.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:

ParameterBeschreibung
codeAuth-Code von Shopify
stateCSRF-Nonce
shopShop-URL
hmacShopify HMAC-Signatur
timestampZeitstempel

Response: Redirect zu /dashboard/settings?tab=shopify&shopify=connected

Logik:

  1. HMAC-Signatur validieren
  2. State-Nonce prüfen + Expiry
  3. Code gegen permanenten Access-Token tauschen
  4. Token mit pgcrypto AES-256 verschlüsseln
  5. Verbindung testen + Locations synchronisieren
  6. 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, Kunden
  • incremental_sync — Nur Änderungen seit letztem Sync
  • inventory_push — Bestand an Shopify senden

Mirror-Tabellen (read-only):

  • shopify_products
  • shopify_product_variants
  • shopify_orders
  • shopify_fulfillments
  • shopify_customers

Inventar-Sync: Roestify → Shopify (bei Abpackung)

Datenfluss: Shopify ist Quelle für Produkte/Orders. Roestify ist Quelle für Inventar.