İçeriğe geç
Yeni VERI*FACTU 2027'de geliyor ve elpizzero şimdiden hazır. Nasıl olduğunu gör Konuşalım mı?Partners: para agencias
API Export Salt okunur · api@elpizzero.com

API Export

elpizzero hesabınızdaki verileri —siparişler, menü, bölgeler, restoran ve metrikler— kendi sistemlerinize (CRM, BI, muhasebe, ekranlar vb.) aktarmak için salt okunur REST API. Değişikliklere gerçek zamanlı tepki verebilmeniz için canlı akış (SSE) ve giden webhooks içerir.

Kapsam. Bu API sipariş oluşturmaz ve değiştirmez. Siparişlerin elpizzero'ya aktarılması herkese açık değildir ve burada belgelenmez: doğrulamanın ardından hesap bazında etkinleştirilir. Böyle bir şeye ihtiyacınız varsa bize şu adresten yazın: api@elpizzero.com.

Kimlik doğrulama

Başlıkta Bearer token. Token'lar elp_live_<32hex> veya elp_test_<32hex> biçimindedir.

Authorization: Bearer elp_live_3b8f0c2a1d4e5f6079a8b7c6d5e4f3a2

Token'ları Panel → Entegrasyonlar → API Anahtarları bölümünde izinlerini seçerek oluşturun ve iptal edin. Token yalnızca bir kez tam olarak gösterilir.

İzinler

ScopeEtkinleştirir
pedidos.leer/pedidos, /pedidos/{id}, /pedidos/{id}/historial, /resumen
carta.leer/carta
restaurante.leer/restaurante, /zonas
stream.escuchar/stream (SSE)
webhook.recibir/webhooks (ekleme/silme/listeleme)

Gerekli scope'u olmayan token → 403 alcance_insuficiente.

Ortamlar

elp_live_ ve elp_test_ aynı gerçek verileri okur; simüle verili bir sandbox yoktur. Önek, token'larınızı ayırt etmeniz için yalnızca bir etikettir.

Rate limit

Token başına dakikada 60 istek. Her yanıtta başlıklar: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset. Aşıldığında → 429 + Retry-After.

Kurallar

Hatalar

Tekdüze gövde + tutarlı HTTP kodu:

{
  "ok": false,
  "error": "Esta llave no tiene el alcance necesario: pedidos.leer",
  "codigo": "alcance_insuficiente",
  "doc": "https://elpizzero.com/docs/api/export#auth"
}
HTTPcodigo
401llave_ausente · llave_invalida · llave_revocada · llave_expirada
403alcance_insuficiente · restaurante_inactivo
400parametro_invalido (valores_validos içerir)
404no_encontrado
405 / 429metodo_invalido · limite_alcanzado

Siparişleri listele

GET /pedidos

Restoranın siparişleri, id azalan sırada, cursor ile sayfalama.

QueryTipoAçıklama
estadocsvpendienteconfirmadoen_preparacionlistoen_repartoentregadocancelado
tipoenumrepartorecogidamesa
desde / hastaISOcreado_en üzerinde aralık (desde ≤ x < hasta).
limiteint1–100, varsayılan 25.
cursorstringÖnceki sayfadaki paginacion.siguiente değeri.
curl "https://elpizzero.com/api/export/pedidos?estado=entregado&desde=2026-05-01&limite=50" \
  -H "Authorization: Bearer elp_live_..."
{
  "datos": [ /* Objeto Pedido */ ],
  "paginacion": { "limite":50, "siguiente":"ni", "anterior":null, "total_aprox":494 }
}
Tüm geçmişi almak için cursor = paginacion.siguiente ile, değer null olana kadar yineleyin.

Bir siparişi getir

GET /pedidos/{id}

Sipariş nesnesini döndürür. {id} önekli, ör. ped_ni. Size ait değilse 404 no_encontrado.

Bir siparişin geçmişi

GET /pedidos/{id}/historial
{
  "pedido_id": "ped_ni",
  "eventos": [
    { "momento":"2026-05-31T20:42:15Z", "accion":"order_created",
      "origen":"sistema", // sistema|panel|tpv|apk_recepcion|api
      "usuario":null, "detalle":{} }
  ]
}

Menü

GET /carta

Kategoriler → ürünler → boyutlar → seçenek grupları → seçenekler şeklinde tam ağaç. ?solo_disponibles=true gizli/tükenmiş öğeleri hariç tutar.

{
  "restaurante_id":"rest_1", "restaurante_slug":"tu-restaurante",
  "moneda":"EUR", "idioma_origen":"es", "generado_en":"2026-06-01T18:41:27Z",
  "categorias": [{
    "id":"cat_v", "nombre":"Pizzas", "activa":true,
    "visible_dias":["lun","mar","mie","jue","vie","sab","dom"], "visible_horario":null,
    "productos": [{
      "id":"prod_3J", "nombre":"Margarita", "precio_cents":680,
      "disponible":true, "destacado":false, "alergenos":["gluten","lacteos"],
      "tamaños":[{ "id":"tam_11", "nombre":"mediana", "precio_cents":680, "predeterminado":true }],
      "grupos_opcion":[{ "id":"grp_73", "nombre":"Extras", "requerido":false,
        "min_seleccion":0, "max_seleccion":5,
        "opciones":[{ "id":"opt_8", "nombre":"Extra queso", "precio_cents":120 }] }]
    }]
  }]
}

Teslimat bölgeleri

GET /zonas

Çokgenli bölgeler GeoJSON olarak (koordinatlar [lng, lat], kapalı halka).

{ "datos": [{
  "id":"zon_8", "nombre":"Albatera", "slug":"albatera",
  "color":"#44c3e5", "tarifa_cents":250, "pedido_minimo_cents":2000,
  "minutos_estimados":40, "activa":true,
  "poligono":{ "tipo":"Polygon", "coordenadas":[[[-0.872,38.186], /* … */]] }
}] }

Restoran

GET /restaurante

Restoran kartı: iletişim, konum, güne göre çalışma saatleri, marka, kanala göre diller, itibar. Hassas vergi verileri yok.

{
  "id":"rest_1", "slug":"tu-restaurante", "nombre":"Tu Restaurante",
  "moneda":"EUR", "zona_horaria":"Europe/Madrid",
  "acepta_pedidos":true, "pedido_minimo_cents":500,
  "horario":{ "viernes":[{"desde":"18:45","hasta":"23:30"}] /* … */ },
  "contacto":{ "email":"…", "telefono":"…", "web":"…" },
  "ubicacion":{ "direccion":"…", "ciudad":"…", "lat":38.14, "lng":-0.88 },
  "branding":{ "logo_url":"…", "color_primario":"…", "galeria":[] },
  "reputacion":{ "puntuacion":4.7, "votos":128 }
}

Özet / metrikler

GET /resumen?periodo=30d

periodo ∈ hoyayer7d30dmes_actual. Restoranın saat diliminde hesaplanır; iptal edilen/reddedilenleri hariç tutar.

{
  "periodo":"30d", "desde":"2026-05-03T00:00:00+02:00", "hasta":"2026-06-02T00:00:00+02:00",
  "zona_horaria":"Europe/Madrid",
  "kpis":{ "pedidos_total":442, "pedidos_cancelados":52, "clientes_distintos":413,
    "ventas_cents":893435, "ticket_medio_cents":2021, "moneda":"EUR" },
  "mix_tipo":{ "reparto":268, "recogida":171, "mesa":3 },
  "top_productos":[{ "producto_id":"prod_3K", "nombre":"Margarita", "unidades":150, "ventas_cents":113845 }]
}

Canlı akış (SSE)

GET /stream

Server-Sent Events. Olayları anında iletir. Kimlik doğrulama query ile (EventSource başlık desteklemez). Last-Event-ID ile her 5 dakikada yerel yeniden bağlanma; yaklaşık her 25 sn'de bir conexion.ping.

const es = new EventSource("https://elpizzero.com/api/export/stream?llave=elp_live_...");
es.addEventListener("pedido.nuevo", e => {
  const ev = JSON.parse(e.data);   // ev.datos.pedido = Objeto Pedido
  console.log(ev.datos.pedido.numero);
});

İsteğe bağlı filtre ?eventos=pedido.nuevo,pedido.aceptado. Yayımlanan türler:

pedido.nuevopedido.aceptadopedido.rechazadopedido.estado_cambiadopedido.item_modificadopedido.entregadopedido.cancelado

Giden webhooks

Pull → push alternatifi: bir sipariş değiştiğinde URL'nize POST göndeririz. Yalnızca giden.

POST /webhooks
curl -X POST "https://elpizzero.com/api/export/webhooks" \
  -H "Authorization: Bearer elp_live_..." -H "Content-Type: application/json" \
  -d '{"url":"https://tu-sistema.com/hook","nombre":"Mi CRM","eventos":["pedido.aceptado","pedido.entregado"]}'
{ "id":"wh_3", "url":"https://tu-sistema.com/hook",
  "eventos":["pedido.aceptado","pedido.entregado"],
  "secreto_firma":"a1b2…(64 hex, se muestra UNA vez)", "activo":true }

Olaylar: akıştakiler + pedido.* ve * joker karakterleri.  GET /webhooks listeler · DEL /webhooks/{id} siler.

Teslimat ve imza

Her gönderim şu başlıkları içerir; gövde akıştaki nesnenin aynısıdır:

X-Elp-Evento: pedido.aceptado
X-Elp-Id: 84213            # úsalo como clave de idempotencia
X-Elp-Firma: <hmac_sha256_hex(secreto, cuerpo_crudo)>
X-Elp-Intento: 1
// Verificación (Node)
const firma = crypto.createHmac("sha256", SECRETO).update(rawBody).digest("hex");
if (firma !== req.headers["x-elp-firma"]) return res.sendStatus(401);
Hata durumunda yeniden deneriz (X-Elp-Intento artar). X-Elp-Id ile tekilleştirin.

Sipariş nesnesi

/pedidos, /pedidos/{id}, akış ve webhooks tarafından döndürülen yapı. Örnekteki müşteri verileri anonimleştirilmiştir. direccion/mesa/entrega/fiscal geçerli olmadığında null olur.

{
  "id":"ped_ni", "numero":"20260531-095",
  "tipo":"reparto",          // reparto|recogida|mesa
  "estado":"en_preparacion",
  "fuente":"web_publica",    // web_publica|tpv|manual|admin
  "creado_en":"2026-05-31T20:42:15Z", "aceptado_en":"…Z",
  "entregado_en":null, "programado_para":null,

  "restaurante":{ "id":"rest_1", "slug":"tu-restaurante", "nombre":"Tu Restaurante" },
  "cliente":{ "nombre":"Juan Pérez", "telefono":"+34 600 000 000",
    "email":"cliente@ejemplo.com", "consintio_marketing":false },
  "direccion":{ "linea":"Calle Mayor 22", "codigo_postal":null, "pais":"ES", "lat":38.154, "lng":-0.880 },
  "mesa":null,

  "items":[{ "id":"itm_A3", "producto_id":"prod_3K", "nombre":"Margarita",
    "tamaño":"mediana", "cantidad":1,
    "precio_unitario_cents":720, "opciones_total_cents":120, "total_cents":840,
    "estado_cocina":"pendiente",
    "opciones":[{ "id":"opc_5", "grupo":"Extras", "nombre":"Extra queso", "cantidad":1, "precio_cents":120 }] }],

  "totales":{ "moneda":"EUR", "subtotal_cents":840, "descuento_cents":0, "propina_cents":0,
    "tarifa_reparto_cents":100, "impuestos_cents":85, "total_cents":1025,
    "iva_desglose":[{ "tipo_porcentaje":10, "base_cents":940, "iva_cents":85 }] },
  "pago":{ "metodo":"online", "estado":"pagado", "proveedor":"stripe",
    "referencia_externa":"pi_3Td…", "pagos":[] },
  "entrega":{ "repartidor_nombre":null, "zona_id":"zon_a", "zona_nombre":"Granja de Rocamora", "tarifa_cents":100 },
  "fiscal":{ "factura_numero":"FA-1132/2026", "factura_fecha":"…Z", "factura_pdf":"https://…/factura.pdf" },
  "instrucciones":null
}

Örnek: mutfak TV ekranı

Kendi içinde çalışan HTML+JS (salt okunur): token'ınızı yapıştırın, bir TV'de açın; siparişler akış üzerinden canlı gelir.

→ Mutfak TV örneğini aç