Guide complet pour utiliser l'API Fundreach
Fundreach est une API puissante pour générer des PDFs à partir de templates HTML. Notre API RESTful vous permet de télécharger des templates, de les gérer et de générer des PDFs personnalisés.
URL de base: https://api.fundreach.com
L'API Fundreach supporte deux méthodes d'authentification :
GET /api/pdf/template-id?api_key=YOUR_API_KEYAuthorization: Bearer YOUR_JWT_TOKENNote: Les clés API peuvent être créées depuis votre tableau de bord.
/uploadcurl -X POST https://api.fundreach.com/upload \
-H 'Authorization: Bearer YOUR_TOKEN' \
-F 'file=@template.html' \
-F 'template_name=invoice_template'Réponse:
{ "template_id": "abc123" }/pdf/:template_idcurl -X POST https://api.fundreach.com/pdf/abc123?api_key=YOUR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"client_name": "John Doe",
"invoice_number": "INV-001",
"amount": 1500.00,
"items": [
{ "description": "Service A", "price": 1000 },
{ "description": "Service B", "price": 500 }
]
}' \
--output invoice.pdfRéponse: Fichier PDF binaire ou URL du PDF
/upload/:template_idcurl https://api.fundreach.com/upload/abc123?api_key=YOUR_API_KEY/upload/:template_idcurl -X PUT https://api.fundreach.com/upload/abc123?api_key=YOUR_API_KEY \
-F 'file=@updated_template.html' \
-F 'name=Updated Invoice Template'/upload/:template_idcurl -X DELETE https://api.fundreach.com/upload/abc123?api_key=YOUR_API_KEY// Générer un PDF
const response = await fetch('https://api.fundreach.com/pdf/abc123?api_key=YOUR_API_KEY', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
client_name: 'John Doe',
invoice_number: 'INV-001',
amount: 1500.00
})
});
const pdfBlob = await response.blob();
// Sauvegarder ou afficher le PDFimport requests
# Générer un PDF
data = {
"client_name": "John Doe",
"invoice_number": "INV-001",
"amount": 1500.00
}
response = requests.post(
"https://api.fundreach.com/pdf/abc123",
params={"api_key": "YOUR_API_KEY"},
json=data
)
# Sauvegarder le PDF
with open("invoice.pdf", "wb") as f:
f.write(response.content)<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: Arial, sans-serif; }
.invoice-header { margin-bottom: 20px; }
.amount { font-size: 24px; font-weight: bold; }
</style>
</head>
<body>
<div class="invoice-header">
<h1>Facture #{{invoice_number}}</h1>
<p>Client: {{client_name}}</p>
</div>
<div class="amount">
Total: {{amount}} €
</div>
{{#if items}}
<ul>
{{#each items}}
<li>{{description}} - {{price}} €</li>
{{/each}}
</ul>
{{/if}}
</body>
</html>Les templates utilisent la syntaxe Handlebars pour les variables et la logique.
L'API retourne des codes d'erreur HTTP standards :
{
"error": "Invalid API key",
"code": "INVALID_API_KEY"
}Alerte quota : Vous recevrez un email d'alerte lorsque vous atteindrez 80% de votre quota mensuel.
Consultez notre page de tarification pour voir les différents plans et leurs quotas.