refurbished.me → refurbished.trade

Partner API - Implementatiegids

Alle calls gaan via één POST endpoint. Het type actie wordt bepaald door het action veld in de request body.

Kritisch: zo werkt de API

  • Eén enkel endpoint voor alle acties (geen REST-paden als /search, /estimate etc.)
  • Altijd POST - ook voor zoekopdrachten. GET requests geven een 405 Method Not Allowed.
  • action in de body - niet in de URL of als query parameter
  • Auth: Bearer username:api_key - twee onderdelen gescheiden door een dubbele punt

Endpoint (één URL voor alles)

POSThttps://refurbished.trade/api/functions/refurbishedMeAPI

Auth header

Authorization: Bearer <username>:<api_key>

username en api_key via refurbished.trade Admin → Partner API

JavaScript implementatie

JavaScript
// ✅ Correcte implementatie voor refurbished.me
const ENDPOINT = "https://refurbished.trade/api/functions/refurbishedMeAPI";

async function callRefurbishedTradeAPI(action, params = {}) {
  const response = await fetch(ENDPOINT, {
    method: "POST",                          // ← ALTIJD POST
    headers: {
      "Authorization": "Bearer <username>:<api_key>",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      action,                                // ← action in de body
      ...params
    }),
  });

  if (!response.ok) {
    const err = await response.json();
    throw new Error(err.error || `HTTP ${response.status}`);
  }

  return response.json();
}

// Voorbeelden:
const results = await callRefurbishedTradeAPI("search", { query: "iPhone 15" });
const estimate = await callRefurbishedTradeAPI("estimate", { model_id: "apple-iphone-15-pro-128gb" });
const order = await callRefurbishedTradeAPI("order", {
  device_model_id: "apple-iphone-15-pro-128gb",
  offer_price: 385,
  customer_name: "Jan de Vries",
  customer_email: "jan@example.com",
  customer_address: "Hoofdstraat 12",
  customer_postal_code: "3769AV",
  customer_city: "Soesterberg",
});

Veelgemaakte fouten

❌ GET requests werken niet - alle calls zijn POST

FOUT

fetch("/api/devices/search", { method: "GET" })

CORRECT

fetch(ENDPOINT, { method: "POST", body: JSON.stringify({ action: "search", query: "..." }) })

❌ Geen URL-paden - action gaat in de body

FOUT

fetch(ENDPOINT + "/search", { method: "POST" })

CORRECT

fetch(ENDPOINT, { method: "POST", body: JSON.stringify({ action: "search" }) })

❌ Auth header moet username:api_key zijn (met dubbele punt)

FOUT

"Authorization": "Bearer api_key_here"

CORRECT

"Authorization": "Bearer username:api_key"

Action referentie

POSTaction: "search"

Zoek apparaten in de catalogus op merk/model naam.

Body velden

actionrequired

"search"

queryrequired

Zoekterm (bijv. "iPhone 15 Pro")

limitoptioneel

Max resultaten (standaard: 10)

Request body

JSON
{
  "action": "search",
  "query": "iPhone 15 Pro",
  "limit": 5
}

Response

JSON
{
  "devices": [
    {
      "model_id": "apple-iphone-15-pro-128gb",
      "title": "Apple iPhone 15 Pro 128GB",
      "brand": "Apple",
      "image_url": "https://...",
      "slug": "apple-iphone-15-pro-128gb",
      "questions": [...]
    }
  ],
  "total": 1
}

cURL voorbeeld

bash
curl -X POST "https://refurbished.trade/api/functions/refurbishedMeAPI" \
  -H "Authorization: Bearer <username>:<api_key>" \
  -H "Content-Type: application/json" \
  -d '{
  "action": "search",
  "query": "iPhone 15 Pro",
  "limit": 5
}'

Order statussen

registeredlabel_printedshippedin_transitdeliveredpaid

Van registered tot paid.

HTTP Foutcodes

400Bad RequestOntbrekende of ongeldige velden
401UnauthorizedOngeldige of ontbrekende Authorization header
404Not FoundOrder niet gevonden
405Method Not Allowed⚠️ Je gebruikt GET in plaats van POST
500Server ErrorInterne fout - contact service@refurbished.store

Credentials & support

API credentials beheren via refurbished.trade Admin → Partner API. Vragen? service@refurbished.store