Sirene Documentation
Functions
call_siren_api(siren)
Retrieve detailed company information from the INSEE SIRENE API using a SIREN number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
siren
|
Union[str, int]
|
The SIREN number (9-digit company identifier in France). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
A dictionary containing the SIRENE API response data. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the API call fails or no data is returned. |
Example
from sirene import call_siren_api
siren_number = "123456789"
response_data = call_siren_api(siren_number)
print("SIRENE API response:", response_data)
get_company_title(siren_number)
Retrieve the company's official NAF title and registered name from a SIREN number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
siren_number
|
Union[str, int]
|
The SIREN number (9-digit identifier). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Tuple[str, str]: A tuple containing: - The official NAF title of the company. - The registered company name as per SIRENE. |
Example
from sirene import get_company_title
siren_number = "123456789"
naf_title, company_name = get_company_title(siren_number)
print("NAF Title:", naf_title)
print("Registered Name:", company_name)
get_company_title_from_siren_api(response)
Extract the company's official title (NAF label) from the SIRENE API response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
dict
|
A dictionary containing the SIRENE API response. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
The company title (in French) based on the NAF code. |
Example
from sirene import call_siren_api, get_company_title_from_siren_api
siren_number = "123456789"
response_data = call_siren_api(siren_number)
company_title = get_company_title_from_siren_api(response_data)
print("NAF Title:", company_title)
get_siren_access_token(client_id, client_secret)
Obtain an OAuth2 access token for the INSEE SIRENE API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client_id
|
str
|
The OAuth2 client ID (SIREN_ID_CLIENT). |
required |
client_secret
|
str
|
The OAuth2 client secret (SIREN_SECRET_ID). |
required |
Returns:
| Type | Description |
|---|---|
|
Optional[str]: The access token string if the request succeeds, otherwise None. |
Example
from sirene import get_siren_access_token
import os
client_id = os.environ["SIREN_ID_CLIENT"]
client_secret = os.environ["SIREN_SECRET_ID"]
token = get_siren_access_token(client_id, client_secret)
if token:
print("Access token acquired successfully:", token)
else:
print("Failed to retrieve access token.")