Ces exemples montrent des flux complets en Python, Node.js, Go et Rust. Copiez‑les, remplacez vos ID et vous aurez une intégration fonctionnelle.
1) Obtenir un jeton d'accès
Utilisez OAuth2 Client Credentials pour demander un jeton de courte durée avant d’appeler une API.
import os
import requests
token_resp = requests.post(
"https://api.zimun.online/oauth/token",
auth=(os.getenv("ZIMUN_CLIENT_ID"), os.getenv("ZIMUN_CLIENT_SECRET")),
data={"grant_type": "client_credentials"},
)
token = token_resp.json()["access_token"]
headers = {"Authorization": f"Bearer {token}"}
import axios from "axios";
const tokenResp = await axios.post(
"https://api.zimun.online/oauth/token",
new URLSearchParams({ grant_type: "client_credentials" }),
{
auth: {
username: process.env.ZIMUN_CLIENT_ID,
password: process.env.ZIMUN_CLIENT_SECRET,
},
}
);
const token = tokenResp.data.access_token;
const headers = { Authorization: `Bearer ${token}` };
client := &http.Client{}
req, _ := http.NewRequest("POST", "https://api.zimun.online/oauth/token", strings.NewReader("grant_type=client_credentials"))
req.SetBasicAuth(os.Getenv("ZIMUN_CLIENT_ID"), os.Getenv("ZIMUN_CLIENT_SECRET"))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, _ := client.Do(req)
defer resp.Body.Close()
let client = reqwest::Client::new();
let resp = client
.post("https://api.zimun.online/oauth/token")
.basic_auth(std::env::var("ZIMUN_CLIENT_ID")?, Some(std::env::var("ZIMUN_CLIENT_SECRET")?))
.form(&[("grant_type", "client_credentials")])
.send()
.await?;
let json: serde_json::Value = resp.json().await?;
let token = json["access_token"].as_str().unwrap();
2) Lister les services
Récupérez d'abord les services de l'organisation, puis utilisez un service_id sélectionné dans les appels de disponibilité et de réservation.
services = requests.get(
"https://api.zimun.online/api/v1/services?page_size=50",
headers=headers,
).json()
first_service_id = services["items"][0]["id"] if services.get("items") else None
const services = await axios.get(
"https://api.zimun.online/api/v1/services?page_size=50",
{ headers }
);
const firstServiceId = services.data.items?.[0]?.id || null;
servicesReq, _ := http.NewRequest("GET", "https://api.zimun.online/api/v1/services?page_size=50", nil)
servicesReq.Header.Set("Authorization", "Bearer "+token)
servicesResp, _ := client.Do(servicesReq)
defer servicesResp.Body.Close()
let services = client
.get("https://api.zimun.online/api/v1/services?page_size=50")
.bearer_auth(token)
.send()
.await?;
let body: serde_json::Value = services.json().await?;
3) Obtenir la disponibilité
Lisez les créneaux ouverts pour un service sélectionné à une date spécifique.
single_day = requests.get(
"https://api.zimun.online/api/v1/availability?service_id=s_123&date=2026-02-20",
headers=headers,
).json()
const singleDay = await axios.get(
"https://api.zimun.online/api/v1/availability?service_id=s_123&date=2026-02-20",
{ headers }
);
availReq, _ := http.NewRequest("GET", "https://api.zimun.online/api/v1/availability?service_id=s_123&date=2026-02-20", nil)
availReq.Header.Set("Authorization", "Bearer "+token)
availResp, _ := client.Do(availReq)
defer availResp.Body.Close()
let availability = client
.get("https://api.zimun.online/api/v1/availability?service_id=s_123&date=2026-02-20")
.bearer_auth(token)
.send()
.await?;
4) Hold → Confirmer
Ceci est le flux de validation de réservation après avoir déjà sélectionné un service et un horaire valides.
# create hold
hold = requests.post(
"https://api.zimun.online/api/v1/appointments/hold",
headers=headers,
json={
"service_id": "s_123",
"appointment_time": "2025-12-01T10:00:00Z",
},
).json()
# 3) confirm
confirm = requests.post(
"https://api.zimun.online/api/v1/appointments/confirm",
headers=headers,
json={
"hold_id": hold["hold_id"],
"contact_name": "Dana Lee",
"contact_email": "dana@example.com",
},
).json()
const hold = await axios.post(
"https://api.zimun.online/api/v1/appointments/hold",
{
service_id: "s_123",
appointment_time: "2025-12-01T10:00:00Z",
},
{ headers }
);
const confirm = await axios.post(
"https://api.zimun.online/api/v1/appointments/confirm",
{
hold_id: hold.data.hold_id,
contact_name: "Dana Lee",
contact_email: "dana@example.com",
},
{ headers }
);
// hold
holdBody := `{"service_id":"s_123","appointment_time":"2025-12-01T10:00:00Z"}`
holdReq, _ := http.NewRequest("POST", "https://api.zimun.online/api/v1/appointments/hold", strings.NewReader(holdBody))
holdReq.Header.Set("Authorization", "Bearer "+token)
holdReq.Header.Set("Content-Type", "application/json")
holdResp, _ := client.Do(holdReq)
let hold = client
.post("https://api.zimun.online/api/v1/appointments/hold")
.bearer_auth(token)
.json(&serde_json::json!({
"service_id": "s_123",
"appointment_time": "2025-12-01T10:00:00Z"
}))
.send()
.await?;
5) Reprogrammer ou annuler un rendez-vous
Utilisez les points de terminaison /api/v1 avec votre jeton de porteur pour mettre à jour un rendez-vous existant par rendez-vous_id.
rescheduled = requests.post(
"https://api.zimun.online/api/v1/appointments/reschedule",
headers=headers,
json={
"appointment_id": "a_123",
"start_time": "2026-02-20T13:00:00Z",
},
).json()
cancelled = requests.post(
"https://api.zimun.online/api/v1/appointments/cancel",
headers=headers,
json={"appointment_id": "a_123"},
).json()
const rescheduled = await axios.post(
"https://api.zimun.online/api/v1/appointments/reschedule",
{ appointment_id: "a_123", start_time: "2026-02-20T13:00:00Z" },
{ headers }
);
const cancelled = await axios.post(
"https://api.zimun.online/api/v1/appointments/cancel",
{ appointment_id: "a_123" },
{ headers }
);
rescheduleBody := `{"appointment_id":"a_123","start_time":"2026-02-20T13:00:00Z"}`
rescheduleReq, _ := http.NewRequest("POST", "https://api.zimun.online/api/v1/appointments/reschedule", strings.NewReader(rescheduleBody))
rescheduleReq.Header.Set("Authorization", "Bearer "+token)
rescheduleReq.Header.Set("Content-Type", "application/json")
rescheduleResp, _ := client.Do(rescheduleReq)
defer rescheduleResp.Body.Close()
cancelBody := `{"appointment_id":"a_123"}`
cancelReq, _ := http.NewRequest("POST", "https://api.zimun.online/api/v1/appointments/cancel", strings.NewReader(cancelBody))
cancelReq.Header.Set("Authorization", "Bearer "+token)
cancelReq.Header.Set("Content-Type", "application/json")
cancelResp, _ := client.Do(cancelReq)
defer cancelResp.Body.Close()
let rescheduled = client
.post("https://api.zimun.online/api/v1/appointments/reschedule")
.bearer_auth(token)
.json(&serde_json::json!({
"appointment_id": "a_123",
"start_time": "2026-02-20T13:00:00Z"
}))
.send()
.await?;
let cancelled = client
.post("https://api.zimun.online/api/v1/appointments/cancel")
.bearer_auth(token)
.json(&serde_json::json!({ "appointment_id": "a_123" }))
.send()
.await?;