Pronte all’uso

Esempi cURL & Postman

Snippet pronti e collezione importabile per testare la Sandbox in 2 minuti.

Disponibile

Snippet cURL

Bash / macOS / Linux. Sostituisci la chiave e incolla.

Lista ordini (base)
curl -s "https://sandbox.vorreimenu.it/api_v2.php?limit=50&cursor=0" \
  -H "Authorization: Bearer LA_TUA_CHIAVE" \
  -H "Accept: application/vnd.vorrei.v2+json"

Risposta: JSON V2 con meta.next_cursor per la pagina successiva.

Filtro per data
curl -s "https://sandbox.vorreimenu.it/api_v2.php?date_from=2025-10-31&date_to=2025-11-01&limit=100" \
  -H "Authorization: Bearer LA_TUA_CHIAVE" \
  -H "Accept: application/vnd.vorrei.v2+json"

Usa YYYY-MM-DD per ricevere solo gli ordini nel range.

Paginazione robusta
# 1) prendi una pagina
curl -s "https://sandbox.vorreimenu.it/api_v2.php?limit=100&cursor=0" \
  -H "Authorization: Bearer LA_TUA_CHIAVE" \
  -H "Accept: application/vnd.vorrei.v2+json" | tee page1.json

# 2) leggi il next_cursor e usa quello per la pagina dopo

cursor è sempre l’ultimo ordine_id processato.

Query string (alternativa)
curl -s "https://sandbox.vorreimenu.it/api_v2.php?limit=50&cursor=0&key=LA_TUA_CHIAVE" \
  -H "Accept: application/vnd.vorrei.v2+json"

Preferisci il Bearer per integrazioni server-to-server.

PowerShell & PHP

Comodi su Windows e lato server.

PowerShell
$Headers = @{
  "Authorization" = "Bearer LA_TUA_CHIAVE"
  "Accept"        = "application/vnd.vorrei.v2+json"
}
Invoke-RestMethod -Uri "https://sandbox.vorreimenu.it/api_v2.php?limit=50&cursor=0" -Headers $Headers -Method GET
PHP (cURL)
<?php
$ch = curl_init('https://sandbox.vorreimenu.it/api_v2.php?limit=50&cursor=0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  'Authorization: Bearer LA_TUA_CHIAVE',
  'Accept: application/vnd.vorrei.v2+json'
));
$body = curl_exec($ch);
curl_close($ch);
$data = json_decode($body, true);
print_r($data);

Collezione Postman

Variabili già pronte: base_url, api_key, accept_header.

Download

Salva il file seguente come /assets/postman/vorrei-sandbox.postman_collection.json e linka il bottone.

Scarica collezione

Oppure copia il JSON qui sotto e importalo in Postman.

Tests (Postman)
// Tab "Tests"
pm.test("Status 200", function () { pm.response.to.have.status(200); });
const json = pm.response.json();
pm.test("Versione V2", function () { pm.expect(json.version).to.eql("v2"); });
pm.test("Array ordini", function () { pm.expect(json.data).to.be.an("array"); });
pm.test("Ha meta.next_cursor", function () { pm.expect(json.meta).to.have.property("next_cursor"); });
JSON collezione (pronto)
{
  "info": {
    "name": "Vorrei Menu — Sandbox V2",
    "_postman_id": "c0c0a000-1111-2222-3333-444455556666",
    "description": "Esempi pronti per la Sandbox V2 (ordini da scontrino).",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "Lista ordini (base)",
      "request": {
        "method": "GET",
        "header": [
          { "key": "Authorization", "value": "Bearer {{api_key}}", "type": "text" },
          { "key": "Accept", "value": "{{accept_header}}", "type": "text" }
        ],
        "url": { "raw": "{{base_url}}/api_v2.php?limit=50&cursor=0", "host": ["{{base_url}}"], "path": ["api_v2.php"], "query": [{"key":"limit","value":"50"},{"key":"cursor","value":"0"}] }
      },
      "response": []
    },
    {
      "name": "Filtro per data",
      "request": {
        "method": "GET",
        "header": [
          { "key": "Authorization", "value": "Bearer {{api_key}}", "type": "text" },
          { "key": "Accept", "value": "{{accept_header}}", "type": "text" }
        ],
        "url": { "raw": "{{base_url}}/api_v2.php?date_from=2025-10-31&date_to=2025-11-01&limit=100", "host": ["{{base_url}}"], "path": ["api_v2.php"], "query": [{"key":"date_from","value":"2025-10-31"},{"key":"date_to","value":"2025-11-01"},{"key":"limit","value":"100"}] }
      },
      "response": [],
      "event": [
        { "listen": "test", "script": { "exec": [
          "pm.test('Status 200', () => pm.response.to.have.status(200));",
          "const json = pm.response.json();",
          "pm.test('Versione V2', () => pm.expect(json.version).to.eql('v2'));",
          "pm.test('Array ordini', () => pm.expect(json.data).to.be.an('array'));"
        ], "type": "text/javascript" } }
      ]
    },
    {
      "name": "Query string (alternativa)",
      "request": {
        "method": "GET",
        "header": [ { "key": "Accept", "value": "{{accept_header}}", "type": "text" } ],
        "url": { "raw": "{{base_url}}/api_v2.php?limit=50&cursor=0&key={{api_key}}", "host": ["{{base_url}}"], "path": ["api_v2.php"], "query": [{"key":"limit","value":"50"},{"key":"cursor","value":"0"},{"key":"key","value":"{{api_key}}"}] }
      },
      "response": []
    }
  ],
  "variable": [
    { "key": "base_url", "value": "https://sandbox.vorreimenu.it" },
    { "key": "api_key", "value": "INSERISCI_LA_TUA_CHIAVE" },
    { "key": "accept_header", "value": "application/vnd.vorrei.v2+json" }
  ]
}

Importa, imposta api_key e premi Send.

Errori standard

401 {"error":"unauthorized","message":"Chiave API non valida o mancante"}
403 {"error":"forbidden","message":"Accesso non autorizzato"}
429 {"error":"rate_limited","message":"Troppi tentativi"}
500 {"error":"server_error","message":"DB connection error"}

Gestisci i codici HTTP nel tuo adattatore (retry/backoff sul 429).

Pronto a provare?

Apri la Sandbox, importa la collezione e testa subito.

Vai alla Sandbox Scarica collezione Postman