Guide complet pour intégrer InoPDF dans vos applications
L'API InoPDF vous permet de générer des factures PDF professionnelles en quelques lignes de code. Simple, rapide, et fiable.
Base URL: http://localhost:8080/api
Format: JSON
Authentification: API Key (header X-API-Key)
Toutes les requĂȘtes protĂ©gĂ©es nĂ©cessitent une clĂ© API dans le header:
curl -X POST https://api.inopdf.dz/api/generate \ -H "X-API-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d @request.json
Vérifier l'état du service (pas d'authentification requise)
Obtenir les informations de tarification
Générer une facture de démonstration (pas d'authentification requise)
Générer une facture PDF (authentification requise)
| ParamĂštre | Type | Requis | Description |
|---|---|---|---|
language |
string | Optionnel | Langue de la facture: fr, ar, en (défaut: fr) |
company_info |
object | Requis | Informations de l'entreprise |
client_info |
object | Requis | Informations du client |
invoice_details |
object | Requis | Détails de la facture |
items |
array | Requis | Liste des articles (au moins 1) |
notes |
string | Optionnel | Notes additionnelles |
curl -X POST http://localhost:8080/api/generate \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"language": "fr",
"company_info": {
"name": "Freelance Services DZ",
"email": "contact@example.dz",
"address": "123 Rue Example, Alger",
"phone": "+213 555 123 456",
"nif": "123456789012345"
},
"client_info": {
"name": "Client Name",
"address": "456 Avenue Client, Oran"
},
"invoice_details": {
"invoice_number": "INV-2026-001",
"date": "2026-01-15T00:00:00Z",
"currency": "DZD"
},
"items": [
{
"description": "Développement web",
"quantity": 10,
"unit_price": 5000,
"tax": 19
}
],
"notes": "Merci pour votre confiance"
}' \
--output invoice.pdf
const response = await fetch('http://localhost:8080/api/generate', {
method: 'POST',
headers: {
'X-API-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
language: 'fr',
company_info: {
name: 'Freelance Services DZ',
email: 'contact@example.dz',
address: '123 Rue Example, Alger',
phone: '+213 555 123 456',
nif: '123456789012345'
},
client_info: {
name: 'Client Name',
address: '456 Avenue Client, Oran'
},
invoice_details: {
invoice_number: 'INV-2026-001',
date: new Date().toISOString(),
currency: 'DZD'
},
items: [{
description: 'Développement web',
quantity: 10,
unit_price: 5000,
tax: 19
}],
notes: 'Merci pour votre confiance'
})
});
const blob = await response.blob();
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'invoice.pdf';
a.click();
import requests
from datetime import datetime
response = requests.post(
'http://localhost:8080/api/generate',
headers={
'X-API-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'language': 'fr',
'company_info': {
'name': 'Freelance Services DZ',
'email': 'contact@example.dz',
'address': '123 Rue Example, Alger',
'phone': '+213 555 123 456',
'nif': '123456789012345'
},
'client_info': {
'name': 'Client Name',
'address': '456 Avenue Client, Oran'
},
'invoice_details': {
'invoice_number': 'INV-2026-001',
'date': datetime.now().isoformat() + 'Z',
'currency': 'DZD'
},
'items': [{
'description': 'Développement web',
'quantity': 10,
'unit_price': 5000,
'tax': 19
}],
'notes': 'Merci pour votre confiance'
}
)
with open('invoice.pdf', 'wb') as f:
f.write(response.content)
package main
import (
"bytes"
"encoding/json"
"io"
"net/http"
"os"
"time"
)
func generateInvoice() error {
request := map[string]interface{}{
"language": "fr",
"company_info": map[string]string{
"name": "Freelance Services DZ",
"email": "contact@example.dz",
},
"client_info": map[string]string{
"name": "Client Name",
},
"invoice_details": map[string]interface{}{
"invoice_number": "INV-2026-001",
"date": time.Now().Format(time.RFC3339),
"currency": "DZD",
},
"items": []map[string]interface{}{{
"description": "Développement web",
"quantity": 10,
"unit_price": 5000,
"tax": 19,
}},
}
body, _ := json.Marshal(request)
req, _ := http.NewRequest("POST",
"http://localhost:8080/api/generate",
bytes.NewBuffer(body))
req.Header.Set("X-API-Key", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
out, _ := os.Create("invoice.pdf")
defer out.Close()
io.Copy(out, resp.Body)
return nil
}
SuccĂšs (200): Fichier PDF en binaire
Erreur (4xx/5xx): JSON avec détails de l'erreur
{
"error": "validation_error",
"message": "company name is required"
}