Company search API in PHP: search, record, VAT and 429 handling

Prometiam has no PHP SDK. This page gives one small file, plain PHP with the curl extension, that searches by name, reads a record, looks a company up by its register number, checks an EU VAT number and retries on 429 after the Retry-After seconds. It was run on 26 November 2026.

These are examples, not an official SDK. Prometiam publishes official clients for TypeScript and Python only; see SDKs. In PHP you call the REST API directly. The code below needs PHP 8 with the curl extension and a key in the environment variable PROMETIAM_API_KEY. On 26 November 2026 it was run with PHP 8.3.6 against the live API, using the public demo key, and the output shown is what it printed.

The client

Save this as client.php. api_get() adds the Bearer header, decodes the JSON, returns the body and the response headers (lower-cased), turns an error into an exception that names the API's error.code, and on a 429 sleeps for the Retry-After seconds (at most 120) and tries again, up to four attempts.

<?php
// Minimal client for the Prometiam Risk API. An example, not an official SDK.
const BASE = 'https://api.prometiam.com/functions/v1/risk-api';

/**
 * GET a path and return [decoded body, response headers].
 * On 429 it waits for the Retry-After header (seconds) and tries again.
 */
function api_get(string $path, array $query = [], int $maxAttempts = 4): array
{
    $key = getenv('PROMETIAM_API_KEY');
    if ($key === false || $key === '') {
        throw new RuntimeException('Set PROMETIAM_API_KEY first');
    }
    $url = BASE . $path . ($query ? '?' . http_build_query($query) : '');

    for ($attempt = 1; $attempt <= $maxAttempts; $attempt++) {
        $headers = [];
        $ch = curl_init($url);
        curl_setopt_array($ch, [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_TIMEOUT => 30,
            CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $key, 'Accept: application/json'],
            CURLOPT_HEADERFUNCTION => function ($ch, $line) use (&$headers) {
                $parts = explode(':', $line, 2);
                if (count($parts) === 2) {
                    $headers[strtolower(trim($parts[0]))] = trim($parts[1]);
                }
                return strlen($line);
            },
        ]);
        $raw = curl_exec($ch);
        if ($raw === false) {
            $err = curl_error($ch);
            curl_close($ch);
            throw new RuntimeException('Network error: ' . $err);
        }
        $status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
        curl_close($ch);
        $body = json_decode($raw, true);

        if ($status === 429 && $attempt < $maxAttempts) {
            $wait = (int) ($headers['retry-after'] ?? 5);
            fwrite(STDERR, "429, waiting {$wait} s (attempt {$attempt})\n");
            sleep(max(1, min($wait, 120)));
            continue;
        }
        if ($status >= 400) {
            $e = $body['error'] ?? [];
            throw new RuntimeException("HTTP {$status} " . ($e['code'] ?? 'error') . ': ' . ($e['message'] ?? $raw));
        }
        return [$body, $headers];
    }
    throw new RuntimeException('Gave up after ' . $maxAttempts . ' attempts');
}

Search, record, lookup and VAT

Save this as example.php next to it and run export PROMETIAM_API_KEY=...; php example.php. The demo key, rk_live_demo_publichn, works for these four calls; it is shared and capped, so use your own key in production.

<?php
require __DIR__ . '/client.php';

// Search by name
[$found] = api_get('/companies/search', ['name' => 'Tesco PLC', 'country' => 'GB', 'limit' => 1]);
$c = $found['data'][0];
echo "search      {$c['company_name']} | {$c['company_number']} | {$c['status']} | id {$c['id']}\n";

// Record by id
[$rec] = api_get('/companies/' . $c['id'], ['country' => 'GB']);
$r = $rec['data'];
echo "record      founded {$r['founding_date']} | {$r['legal_form']} | {$r['activity_code_scheme']} {$r['activity_code']} | {$r['city']}\n";

// Lookup by register number
[$one] = api_get('/companies/by-identifier', ['type' => 'company_number', 'value' => '00445790', 'country' => 'GB']);
echo "identifier  {$one['data']['company_name']} | {$one['data']['register']}\n";

// EU VAT check (VIES)
[$vat, $h] = api_get('/vat/ESA15075062');
$v = $vat['data'];
echo "vat         {$v['vat_number']} valid=" . ($v['is_valid'] ? 'true' : 'false') . " | credits {$h['x-credits-cost']}\n";

On 26 November 2026 the script printed:

search      TESCO PLC | 00445790 | active | id 2000004984338
record      founded 1947-11-27 | PLC | UK-SIC-2007 47110 | WELWYN GARDEN CITY
identifier  TESCO PLC | Companies House
vat         ESA15075062 valid=true | credits 1

Each call cost 1 credit. The calls, in order:

StepCallWhat to read
Search by nameGET /companies/search?name=Tesco PLC&country=GB&limit=1data[] holds companies; id is the key for the record call; match_type says how the name matched.
Record by idGET /companies/{id}?country=GBThe full company object, including appointments. Field list: the company object.
Lookup by identifierGET /companies/by-identifier?type=company_number&value=00445790&country=GBtype is company_number, vat or lei. country is required with company_number. Keep the number as a string: a leading zero matters.
EU VAT checkGET /vat/ESA15075062is_valid is the VIES answer; name and address are null where the member state does not disclose them. EU states and Northern Ireland only; Great Britain is out of scope.

The VAT answer also carried a registry_match block naming the Spanish register entry, and the same call can return a 503 when a member-state service is down. That is a retryable error and not a finding that the number is invalid, so do not store it as one.

429 handling

A call over a limit returns 429 with error.code of rate_limit_exceeded (the per-minute limit) or quota_exceeded (credits), and a Retry-After header in seconds, as the API documentation states. A failed call costs no credits. The loop in api_get() reads that header. The demo key's own limit was not pushed to trigger a real 429, because it is shared with other users. To test the loop, the client was copied with its base URL pointed at a local php -S server that answers 429 with Retry-After: 2 twice and then 200. That printed:

429, waiting 2 s (attempt 1)
429, waiting 2 s (attempt 2)
ok after 4.0 s: {"data":[],"pagination":{"count":0,"has_more":false,"next_cursor":null}}

A wrong key is not retried. With an invalid key the same client threw on the first attempt:

HTTP 401 unauthorized: Invalid or revoked API key

Backing off is not enough for a monthly credit shortfall: after quota_exceeded the retry time can be long, so cap the wait as the client does and stop. Read X-Credits-Remaining on responses, or call GET /account, to see credits before a batch. Details: rate limits, credits and errors.

What these examples do not do

  • No pagination helper. A list answer has pagination.next_cursor; pass it back as cursor while has_more is true.
  • No batch call. POST /companies/lookup takes up to 100 items in one request; each item counts as one request and costs credits, and an over-quota batch is refused up front with 429 batch_exceeds_quota.
  • No sanctions, people, events or monitoring. They need a key of your own and are not covered by the demo key. Sanctions screening is beta.
  • Each country has its own scope limits, listed in the documentation; read them before you rely on a field.
  • Coverage and credit lines: keep meta.attribution where the register's licence requires it.

Credits

A search, a record, a lookup and a VAT check cost 1 credit each. Starter is EUR 9.99 a month for 1,000 credits (60 requests a minute), Professional EUR 29.99 for 10,000 (120), Scale EUR 99.99 for 50,000 (300), Enterprise priced to order. The 14-day trial includes 500 credits; a card is required and nothing is charged during it. For a PHP project that needs the full request and response shapes, the quickstart lists every endpoint with curl.

Related pages

Sign up · API documentation

The free trial lasts 14 days and includes 500 credits. A card is required and nothing is charged during the trial; it then continues as Starter (EUR 9.99/month) unless you cancel.

Frequently asked questions

Is there a PHP SDK?
No. The official clients are for TypeScript and Python. The code on this page is an example you can copy, not a supported library.
Which PHP version and extensions do I need?
The example was run on PHP 8.3.6 with the curl extension. It uses typed parameters and a short list syntax, so use PHP 8 or later.
How do I send the key?
In an Authorization: Bearer header, read from an environment variable. Never put it in the URL or in a file you commit.
What should I do on a 429?
Wait for the number of seconds in the Retry-After header and repeat the call, with a cap on attempts. If the code is quota_exceeded, your credits for the month are used and waiting briefly will not help.
Does the demo key work for all of this?
It works for company search, records, lookup by identifier and VAT, and also LEI and insolvency. It is shared and capped. People, events, monitoring and sanctions screening need a key of your own.