API Product Search

L'API Product Search permette di recuperare informazioni dettagliate sui prodotti (immagini, descrizioni in italiano e cinese) partendo da un codice a barre (EAN/UPC), artid o usercode.

La base URL per tutte le richieste è:
https://api.primastrategia.com

Autenticazione

L'API utilizza un semplice sistema basato su API Key. Devi includere la tua chiave nell'header HTTP x-api-key di ogni richiesta.

Le richieste senza chiave o con chiave non valida restituiranno un errore 401 Unauthorized.

GET Ricerca Singola

Utilizza questo endpoint per cercare un singolo prodotto quando hai a disposizione il codice a barre.

Parametri Query

ParametroDescrizione
barcode
string
Il codice EAN o UPC del prodotto da cercare.

POST Ricerca Multipla (Batch)

Per ottimizzare le prestazioni quando si devono cercare molti prodotti, utilizza l'endpoint POST. Questo accetta un array JSON di codici a barre.

Body Parameters

ParametroDescrizione
barcodes
array[string]
Una lista di stringhe contenente i codici a barre da cercare. Max 50 item per richiesta.

Oggetto Prodotto

Struttura JSON restituita nell'array products.

CampoTipoNote
barcode string Il codice identificativo univoco.
it string Nome/Descrizione in Italiano.
zh string Nome/Descrizione in Cinese.
img_url string URL pubblico dell'immagine.
Esempio di Autenticazione ↓
BASH / CURL
curl "https://api.primastrategia.com/search..." \
  -H "x-api-key: 8888"
REQUEST (GET)
GET /search?barcode=8720181527951 HTTP/1.1
Host: api.primastrategia.com
x-api-key: 8888
RESPONSE (200 OK)
{
  "success": true,
  "count": 1,
  "products": [
    {
      "barcode": "8720181527951",
      "it": "Lampada LED Tavolo",
      "zh": "台灯",
      "img_url": "https://..."
    }
  ]
}
REQUEST (POST)
POST /search HTTP/1.1
Content-Type: application/json
x-api-key: 8888

{
  "barcodes": [
    "8720181527951",
    "8720181527944"
  ]
}
JAVASCRIPT / FETCH
const res = await fetch('/search', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': '8888'
  },
  body: JSON.stringify({
    barcodes: ['8720181527951']
  })
});