Requêtes de l'API ressources¶
Paramètres¶
Le système API vous permet d’automatiser la validation des documents d’identité via une simple requête HTTP POST.
Les paramètres acceptés sont listés dans le tableau ci-dessous :
Paramètre | Type | Format | Obligatoire | Description |
---|---|---|---|---|
api_key |
string | — | Oui | Votre clé API. |
format |
string | — | Non | Format de réponse : json (défaut) ou xml . |
fr_income_taxes_file |
file | Non | Document impôt sur le revenu. | |
fr_civil_servant_payslip_file |
file | Non | Fiche de paie fonctionnaire. | |
fr_caf_payment_certificate_file |
file[] | Non | Un ou plusieurs documents : attestation de paiement de la CAF. |
Exemples d'appels sur différents langages¶
cURL¶
curl
-X POST
-F "format={{ xml }}"
-F "api_key={{ YOUR_API_KEY }}"
-F "fr_****_file=@"{{ PATH_TO_FILE }}""
https://api.app.trustdochub.com/api/resources/v1
Java¶
public String sendIdFileAndGetResults(MultipartFile file) {
WebClient client = WebClient.create();
MultipartBodyBuilder builder = new MultipartBodyBuilder();
builder.part("fr_****_file", file.getResource());
builder.part("api_key", {{ YOUR_API_KEY }});
return client.post()
.uri(URI.create("https://api.app.trustdochub.com/api/resources/v1"))
.contentType(MediaType.MULTIPART_FORM_DATA)
.body(BodyInserters.fromMultipartData(builder.build()))
.retrieve()
.bodyToMono(String.class)
.block();
}
Python¶
import requests
url = 'https://api.app.trustdochub.com/api/resources/v1'
data = {'api_key': '{{ YOUR_API_KEY }}'}
with open('file.txt', 'rb') as file:
response = requests.post(url, data=data, files={'fr_****_file': file})
print(response.text)
Node¶
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const form = new FormData();
// Chemin vers le fichier que vous souhaitez envoyer
const filePath = 'pathToFile';
// Vérifier si le fichier existe
if (!fs.existsSync(filePath)) {
console.error('Le fichier spécifié est introuvable :', filePath);
process.exit(1);
}
// Ajouter le fichier au formulaire
form.append('fr_****_file', fs.createReadStream(filePath));
// Ajouter le paramètre api_key
form.append('api_key', 'votre_clé_api'); // Remplacez par votre clé API réelle
(async () => {
try {
const response = await axios.post(
'https://api.app.trustdochub.com/api/resources/v1',
form,
{
headers: {
...form.getHeaders(),
// Si l'API nécessite une autorisation supplémentaire, ajoutez-la ici
// 'Authorization': 'Bearer votre_token',
},
}
);
console.log('Réponse du serveur :', response.data);
} catch (error) {
if (error.response) {
// La requête a été faite et le serveur a répondu avec un statut d'erreur
console.error('Erreur du serveur :', error.response.status);
console.error('Détails de l'erreur :', error.response.data);
} else if (error.request) {
// La requête a été faite mais aucune réponse n'a été reçue
console.error('Aucune réponse reçue :', error.request);
} else {
// Erreur lors de la configuration de la requête
console.error('Erreur lors de la configuration de la requête :', error.message);
}
}
})();
PHP¶
<?php require 'vendor/autoload.php';
use GuzzleHttpClient;
use GuzzleHttpExceptionRequestException;
$url = 'https://api.app.trustdochub.com/api/resources/v1';
$filePath = '{{ path_to_file }}';
if (!file_exists($filePath)) { die('Fichier introuvable : ' . $filePath); }
// Clé API
$apiKey = 'votre_clé_api'; // Remplacez par votre clé API
// Créer un client Guzzle
$client = new Client(); try { $response = $client->post($url, [
'multipart' => [
[
'name' => 'fr_****_file',
'contents' => fopen($filePath, 'r'),
'filename' => 'specimen_passeport.webp',
'headers' => ['Content-Type' => 'image/webp']
],
[
'name' => 'api_key',
'contents' => $apiKey
]
],
'verify' => true // Vérifier le certificat SSL
]);
// Afficher le code de statut HTTP
echo 'Code HTTP : ' . $response->getStatusCode() . "n";
// Afficher la réponse du serveur
echo 'Réponse du serveur : ' . $response->getBody();
} catch (RequestException $e) {
if ($e->hasResponse()) {
echo 'Erreur du serveur : ' . $e->getResponse()->getStatusCode() . "n";
echo 'Réponse du serveur : ' . $e->getResponse()->getBody();
} else {
echo 'Erreur lors de la requête : ' . $e->getMessage();
}
}
Status codes¶
Les codes suivants sont retournés par l’API :
Codes de réponse API¶
Code | Type | Description |
---|---|---|
200 |
Vérification ok | La vérification s’est bien déroulée. |
401 |
Non autorisé | La clé API n’est pas correcte. |
402 |
Crédits insuffisants | Il n’y a plus de crédits de vérification pour la période donnée. |
422 |
Document illisible | Le document n’est pas reconnu ou incorrect. |
Réponses¶
Format JSON¶
Vous pouvez obtenir les résultats au format JSON.
Pour cela il suffit d’ajouter le paramètre « format=json » dans votre requête, ou de ne pas ajouter le paramètre « format ».
Voici les réponses possibles en fonction des documents :
Impôt sur les revenus FR¶
{
"documentInfos": {
"publicationDate": null,
"signatureDate": "2022-06-13",
"taxableIncomeReference": "44444",
"sharesNumber": "1",
"noticeReference": "2222222222222",
"incomeYear": "2021",
"declarant1": "XXXXXX YYYYYY",
"taxNumberDeclarant1": "777777777777",
"declarant2": null,
"taxNumberDeclarant2": "null",
"collectionDate": "2022-07-31"
},
"certificate": {
"validityStartDate": "2022-06-21",
"validityEndDate": "2024-06-21",
"issuerReference": "FR04",
"issuerName": "AriadNEXT",
"subjectReference": "FPE3",
"issuer": "DIRECTION GENERALE DES FINANCES PUBLIQUES",
"datesConsistency": true,
"digitalSignature": true
}
}
Fiche de paie fonctionnaire FR¶
{
"documentInfos": {
"fullName": "MR XXXX YYYY",
"employerSiret": "55555555555555",
"periodStartDate": "2021-11-01",
"periodEndDate": "2021-11-30",
"contractStartDate": "1111-11-11",
"netTaxableSalary": "2290.3",
"netTaxableAccumulatedSalary": "27138.31"
},
"certificate": {
"validityStartDate": "2020-03-30",
"validityEndDate": "2023-03-31",
"issuerReference": "FR04",
"issuerName": "AriadNEXT",
"subjectReference": "FPE1",
"issuer": "DIRECTION GENERALE DES FINANCES PUBLIQUES",
"datesConsistency": true,
"digitalSignature": true
}
}
Attestation de paiement CAF (1 seul fichier / document de 2 pages)¶
{
"cafPaymentCertificates": [
{
"documentInfos": {
"documentDate": "2020-02-05",
"dateOfBirth": "1980-08-14",
"numberOfPages": 2,
"beneficiaryNumberHeader": "8888888 M",
"dateHourFooter": [
"050220202336",
"050220202336"
],
"beneficiaryNumberFooter": [
"8888888 M",
"8888888 M"
],
"barcodeNumber": [
"88888888888800000000",
"88888888888800000000"
],
"barcodeNumberDecoded": [
"88888888888800000000",
"88888888888800000000"
]
},
"documentInfosValidation": {
"datesHeaderFooterValid": true,
"beneficiaryNumberHeaderFooterValid": true,
"beneficiaryNumberBarcodeNumberValid": true,
"barcodeNumberBarcodeValid": true,
"datesHeaderMetasValid": true,
"datesFooterMetasValid": true
}
}
],
"documentsValidation": null
}
Attestation de paiement CAF (2 fichiers / documents de 2 pages)¶
{
"documentInfos": {
"numberOfCharacters": "30",
"documentType": "FR_DRIVING_LICENCE",
"country": "FRA",
"lastName": "MARTIN",
"documentNumber": "13AA00002",
"expirationDate": "2018-12-31"
},
"documentInfosValidation": {
"numberOfCharactersValid": true,
"documentTypeValid": true,
"lastNameValid": true,
"countryValid": true,
"documentNumberValid": true,
"expirationDateValid": true
},
"controlKeys": {
"documentNumberControlKey": true,
"globalControlKey": true
}
}
Format XML¶
Deuxième type de format disponible pour les réponses : le format XML.
Pour cela, il suffit d’ajouter le paramètre « format » « xml » à votre requête.
Voici les réponses possibles en fonction des documents :
Impôt sur les revenus FR¶
<FrenchIncomeTaxes>
<documentInfos>
<publicationDate/>
<signatureDate>2022-06-13</signatureDate>
<taxableIncomeReference>44444</taxableIncomeReference>
<sharesNumber>1</sharesNumber>
<noticeReference>2222222222222</noticeReference>
<incomeYear>2021</incomeYear>
<declarant1>XXXXX YYYYYY</declarant1>
<taxNumberDeclarant1>777777777777</taxNumberDeclarant1>
<declarant2/>
<taxNumberDeclarant2>null</taxNumberDeclarant2>
<collectionDate>2022-07-31</collectionDate>
</documentInfos>
<certificate>
<validityStartDate>2022-06-21</validityStartDate>
<validityEndDate>2024-06-21</validityEndDate>
<issuerReference>FR04</issuerReference>
<issuerName>AriadNEXT</issuerName>
<subjectReference>FPE3</subjectReference>
<issuer>DIRECTION GENERALE DES FINANCES PUBLIQUES</issuer>
<datesConsistency>true</datesConsistency>
<digitalSignature>true</digitalSignature>
</certificate>
</FrenchIncomeTaxes>
Fiche de paie fonctionnaire FR¶
<FrenchCivilServantPayslip>
<documentInfos>
<fullName>MR XXXX YYYY</fullName>
<employerSiret>55555555555555</employerSiret>
<periodStartDate>2021-11-01</periodStartDate>
<periodEndDate>2021-11-30</periodEndDate>
<contractStartDate>1111-11-11</contractStartDate>
<netTaxableSalary>2290.3</netTaxableSalary>
<netTaxableAccumulatedSalary>27138.31</netTaxableAccumulatedSalary>
</documentInfos>
<certificate>
<validityStartDate>2020-03-30</validityStartDate>
<validityEndDate>2023-03-31</validityEndDate>
<issuerReference>FR04</issuerReference>
<issuerName>AriadNEXT</issuerName>
<subjectReference>FPE1</subjectReference>
<issuer>DIRECTION GENERALE DES FINANCES PUBLIQUES</issuer>
<datesConsistency>true</datesConsistency>
<digitalSignature>true</digitalSignature>
</certificate>
</FrenchCivilServantPayslip>
Attestation de paiement CAF (1 seul fichier / document de 2 pages)¶
<FrenchCafPaymentCertificate>
<cafPaymentCertificates>
<cafPaymentCertificates>
<documentInfos>
<documentDate>2020-02-05</documentDate>
<dateOfBirth>1980-08-14</dateOfBirth>
<numberOfPages>2</numberOfPages>
<beneficiaryNumberHeader>8888888 M</beneficiaryNumberHeader>
<dateHourFooter>
<dateHourFooter>050220202336</dateHourFooter>
<dateHourFooter>050220202336</dateHourFooter>
</dateHourFooter>
<beneficiaryNumberFooter>
<beneficiaryNumberFooter>8888888 M</beneficiaryNumberFooter>
<beneficiaryNumberFooter>8888888 M</beneficiaryNumberFooter>
</beneficiaryNumberFooter>
<barcodeNumber>
<barcodeNumber>88888888888800000000</barcodeNumber>
<barcodeNumber>88888888888800000000</barcodeNumber>
</barcodeNumber>
<barcodeNumberDecoded>
<barcodeNumberDecoded>88888888888800000000</barcodeNumberDecoded>
<barcodeNumberDecoded>88888888888800000000</barcodeNumberDecoded>
</barcodeNumberDecoded>
</documentInfos>
<documentInfosValidation>
<datesHeaderFooterValid>true</datesHeaderFooterValid>
<beneficiaryNumberHeaderFooterValid>true</beneficiaryNumberHeaderFooterValid>
<beneficiaryNumberBarcodeNumberValid>true</beneficiaryNumberBarcodeNumberValid>
<barcodeNumberBarcodeValid>true</barcodeNumberBarcodeValid>
<datesHeaderMetasValid>true</datesHeaderMetasValid>
<datesFooterMetasValid>true</datesFooterMetasValid>
</documentInfosValidation>
</cafPaymentCertificates>
</cafPaymentCertificates>
<documentsValidation/>
</FrenchCafPaymentCertificate>
Attestation de paiement CAF (2 fichiers / documents de 2 pages)¶
<FrenchCafPaymentCertificate>
<cafPaymentCertificates>
<cafPaymentCertificates>
<documentInfos>
<documentDate>2020-02-05</documentDate>
<dateOfBirth>1980-08-14</dateOfBirth>
<numberOfPages>2</numberOfPages>
<beneficiaryNumberHeader>8888888 M</beneficiaryNumberHeader>
<dateHourFooter>
<dateHourFooter>050220202336</dateHourFooter>
<dateHourFooter>050220202336</dateHourFooter>
</dateHourFooter>
<beneficiaryNumberFooter>
<beneficiaryNumberFooter>8888888 M</beneficiaryNumberFooter>
<beneficiaryNumberFooter>8888888 M</beneficiaryNumberFooter>
</beneficiaryNumberFooter>
<barcodeNumber>
<barcodeNumber>88888888888800000000</barcodeNumber>
<barcodeNumber>88888888888800000000</barcodeNumber>
</barcodeNumber>
<barcodeNumberDecoded>
<barcodeNumberDecoded>88888888888800000000</barcodeNumberDecoded>
<barcodeNumberDecoded>88888888888800000000</barcodeNumberDecoded>
</barcodeNumberDecoded>
</documentInfos>
<documentInfosValidation>
<datesHeaderFooterValid>true</datesHeaderFooterValid>
<beneficiaryNumberHeaderFooterValid>true</beneficiaryNumberHeaderFooterValid>
<beneficiaryNumberBarcodeNumberValid>true</beneficiaryNumberBarcodeNumberValid>
<barcodeNumberBarcodeValid>true</barcodeNumberBarcodeValid>
<datesHeaderMetasValid>true</datesHeaderMetasValid>
<datesFooterMetasValid>true</datesFooterMetasValid>
</documentInfosValidation>
</cafPaymentCertificates>
<cafPaymentCertificates>
<documentInfos>
<documentDate>2021-02-05</documentDate>
<dateOfBirth>1980-08-14</dateOfBirth>
<numberOfPages>2</numberOfPages>
<beneficiaryNumberHeader>8888888 M</beneficiaryNumberHeader>
<dateHourFooter>
<dateHourFooter>050220212336</dateHourFooter>
<dateHourFooter>050220212336</dateHourFooter>
</dateHourFooter>
<beneficiaryNumberFooter>
<beneficiaryNumberFooter>8888888 M</beneficiaryNumberFooter>
<beneficiaryNumberFooter>8888888 M</beneficiaryNumberFooter>
</beneficiaryNumberFooter>
<barcodeNumber>
<barcodeNumber>88888888888800000000</barcodeNumber>
<barcodeNumber>88888888888800000000</barcodeNumber>
</barcodeNumber>
<barcodeNumberDecoded>
<barcodeNumberDecoded>88888888888800000000</barcodeNumberDecoded>
<barcodeNumberDecoded>88888888888800000000</barcodeNumberDecoded>
</barcodeNumberDecoded>
</documentInfos>
<documentInfosValidation>
<datesHeaderFooterValid>true</datesHeaderFooterValid>
<beneficiaryNumberHeaderFooterValid>true</beneficiaryNumberHeaderFooterValid>
<beneficiaryNumberBarcodeNumberValid>true</beneficiaryNumberBarcodeNumberValid>
<barcodeNumberBarcodeValid>true</barcodeNumberBarcodeValid>
<datesHeaderMetasValid>true</datesHeaderMetasValid>
<datesFooterMetasValid>true</datesFooterMetasValid>
</documentInfosValidation>
</cafPaymentCertificates>
</cafPaymentCertificates>
<documentsValidation>
<datesOfBirthValid>true</datesOfBirthValid>
<datesHeaderFooterValid>true</datesHeaderFooterValid>
<beneficiaryNumberHeaderFooterValid>true</beneficiaryNumberHeaderFooterValid>
<beneficiaryNumberBarcodeNumberValid>true</beneficiaryNumberBarcodeNumberValid>
<barcodeNumberBarcodeValid>true</barcodeNumberBarcodeValid>
<datesHeaderMetasValid>true</datesHeaderMetasValid>
<datesFooterMetasValid>true</datesFooterMetasValid>
<modificationDateMetasValid>true</modificationDateMetasValid>
</documentsValidation>
</FrenchCafPaymentCertificate>