Full text search
Company full text search is used to find companies by his name. It works on extended data gathering the various labels associated with the company (official name, aliases and brands) collected and updated by Sparklane.
Specifications
- search for companies whose at least one of labels starts with requested text
- case or accents insensitive
- ignore low value words (eg "the", "a", "of", ...)
- possibility to restrict the search to a county or a zip using code
Examples
The "Sparklane" company can be found with the following patterns:
- Case insensitive: "Sparkla", "sparkla"
- Accent insensitive: "spârklâ", ..
- Using county code: "spark 44"
The "SFR" company can be found with the following patterns:
- Initials: "SFR"
- Complete name: "societe francaise du radiotelephone"
- Changing words order: "francaise du radiotele"
- Uncomplete name: "societe radiotele"
This endpoint could be used to offer an company name autocomplete. Launching requests during user typing, you could purpose matching company names and automaticly fill company number from user selection.
Interface
Specification
URL
https://api.sparklane.fr/v5/companies/fr/term
Parameters
In-query parameters:
- q (required / string) Searched term
- limit (optional / integer) Maximum results number
- fields (optional / string array) Reduce result's fields in response
- withEstablishments (optional / boolean) Get matching establishments
Response
List of companies:
- uniqueId Sparklane id (unique across datasources)
- compNumber Company number (unique for a datasource)
- estNumber Company head establishment number
- name Legal company names
- zip Company head location zip code
- town Company head location town
- address Establishment full address
Code samples
Bash CURL
Request |
|
---|---|
Response |
|
HTML/Javascript
<div>
<label for="siren">SIREN: </label><input type="text" name="siren">
<label for="nom">Name: </label><input type="text" name="nom">
</div>
<!-- Import JQuery UI library (see https://jqueryui.com/) -->
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.min.css">
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
// Use JQuery UI autocomplete (see https://jqueryui.com/autocomplete/)
$("input[name=nom]").autocomplete({
minLength : 3, // Launch autocomplete request only since 3 characters
delay : 300, // 300ms debounce between each request
source : function(request, response) {
$.ajax({
// Call Sparklane API with term parameter
url : "https://api.sparklane.fr/v5/companies/fr/term?q=" + request.term,
// Set Basic auth header
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic " + YOUR_TOKEN);
},
success : function(data) {
// Build response: use compNumber as id and name as label
response(data.map(function(c) {
return { id : c.compNumber, label : c.name };
}));
}
});
},
// Set selected result to SIREN field
select : function(event, ui) {
$("input[name=siren]").val(ui.item.id);
}
});