Jsonpage · SIREN and SIRET API
RESOURCES · TUTORIAL

Add company autocomplete to a form

To suggest companies while the user types, call GET /v2/autocomplete from your server from 2 characters, display the name, postcode and city, then save the chosen identifier. The tutorial follows these three steps, with validation of the number on submit.

By Devintech · Published · Updated · 6 min read

01 / CALL

Step 1: call the route

The route takes the typed text (q), one or more countries (country) and a maximum number of suggestions (limit, 1 to 20, 8 by default). Only active companies are suggested, unless you add status=any. A typed number (SIREN, SIRET or a foreign equivalent) returns its company directly.

curl "https://api.jsonpage.com/v2/autocomplete?q=danone&country=FR&limit=5" \
  -H "X-API-Key: $JSONPAGE_API_KEY"
{
  "data": [
    { "id": "FR-552032534", "name": "DANONE", "status": "active",
      "postal_code": "…", "city": "…", "kind": "company" }
  ]
}
Autocomplete: from the input field to the suggestion listTypingfrom 2 charactersYour serverkeeps the keysecretJsonpageGET /v2/autocompleteListname, postcode,city
The browser calls your server, which calls the API with the key, then returns the suggestions.
Try autocomplete for freeThe Discovery plan includes autocomplete with 100 requests per minute, no credit card. See Pricing or the route documentation.
02 / SERVER

Step 2: relay the call from your server

Never call the API from the browser: the key would be visible there. Your server exposes a small address that relays the input:

async function suggestions(q) {
  const url = new URL("https://api.jsonpage.com/v2/autocomplete");
  url.searchParams.set("q", q);
  url.searchParams.set("country", "FR");
  url.searchParams.set("limit", "6");
  const res = await fetch(url, { headers: { "X-API-Key": API_KEY } });
  if (!res.ok) return [];
  return (await res.json()).data;
}
04 / VALIDATION

Step 4: validate on submit

Before saving the record, a call to GET /v2/validate?id=FR-552032534 confirms the format, the existence and the active status of the company. The response is always 200; the valid field says whether all checks passed. For more, see How to check that a SIRET number is valid.

Good practice: let the user type a name freely if no suggestion fits, show the city to tell namesakes apart, and treat an API error as an empty list rather than blocking the form.

05 / FREQUENTLY ASKED QUESTIONS

Frequently asked questions

Can I call autocomplete directly from the browser?+

It is not recommended: the API key would be visible to any visitor. Have your server relay the call.

From how many characters does the route answer?+

The input needs at least one word of 2 characters, otherwise the API returns the query_too_short error.

Can I search several countries?+

Yes. The country parameter accepts a comma-separated list of codes (FR, BE, CH, NO, LV, FI, GB). Without it, all countries are searched.

Are closed companies suggested?+

Not by default: only active companies appear. Add status=any to see every status.

06 / RELATED RESOURCES

Keep reading

TRY IT

Try it on your own numbers

The free account gives access to the company record, validation and name search: 100 requests per minute, no credit card.