PlateRunner is a regular HTTP API, so you can use fetch directly. The important thing is to keep the key on your server.

On the server (Node 18+)

export async function lookupPlate(country, plate) {
  const clean = plate.replace(/[\s-]/g, '').toUpperCase();
  const res = await fetch(
    `https://api.platerunner.dk/v1/plates/${country}/${encodeURIComponent(clean)}`,
    { headers: { Authorization: `Bearer ${process.env.PLATERUNNER_KEY}` } }
  );
  if (res.status === 404) return null;
  if (!res.ok) throw new Error(`PlateRunner responded ${res.status}`);
  return res.json();
}

const car = await lookupPlate('DK', 'AB 12 345');
console.log(car ? `${car.make} ${car.model}` : 'Not found');

When the lookup starts in the browser

Never call PlateRunner directly from the browser, because then everyone can see your key. Instead, make a small route on your own server that the browser calls:

// for example in Express
app.get('/api/plate/:country/:plate', async (req, res) => {
  const car = await lookupPlate(req.params.country, req.params.plate);
  if (!car) return res.status(404).end();
  res.json({ make: car.make, model: car.model, variant: car.variant });
});

Then you only pass on the fields your site needs.

Save the response

Save the vehicle’s data in your own database the first time. The same vehicle should not be looked up again, which saves lookups.

See getting started for every field and error code.