Documents

Zimun: Appointment Scheduling & Booking Software: Exemples d’utilisation de l’API

API

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.

Python
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}"}
Node.js
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}` };
Go
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()
Rust
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) Disponibilité → Hold → Confirmer

C’est le flux de réservation standard : vous récupérez la disponibilité, placez un hold de 10 minutes, puis confirmez avec les informations client.

Python
# 1) availability (holiday map / days ahead)
avail = requests.get(
    "https://api.zimun.online/api/v1/availability?service_id=s_123&days_ahead=7",
    headers=headers,
).json()

# 2) create hold
hold = requests.post(
    "https://api.zimun.online/api/v1/appointments/hold",
    headers=headers,
    json={
        "organization_id": "o_123",
        "service_id": "s_123",
        "appointment_time": "2025-12-01T10:00:00Z",
        "appointment_duration": 30,
    },
).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()
Node.js
const avail = await axios.get(
  "https://api.zimun.online/api/v1/availability?service_id=s_123&days_ahead=7",
  { headers }
);

const hold = await axios.post(
  "https://api.zimun.online/api/v1/appointments/hold",
  {
    organization_id: "o_123",
    service_id: "s_123",
    appointment_time: "2025-12-01T10:00:00Z",
    appointment_duration: 30,
  },
  { 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 }
);
Go
// availability
availReq, _ := http.NewRequest("GET", "https://api.zimun.online/api/v1/availability?service_id=s_123&days_ahead=7", nil)
availReq.Header.Set("Authorization", "Bearer "+token)
availResp, _ := client.Do(availReq)

// hold
holdBody := `{"organization_id":"o_123","service_id":"s_123","appointment_time":"2025-12-01T10:00:00Z","appointment_duration":30}`
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)
Rust
let avail = client
  .get("https://api.zimun.online/api/v1/availability?service_id=s_123&days_ahead=7")
  .bearer_auth(token)
  .send()
  .await?;

let hold = client
  .post("https://api.zimun.online/api/v1/appointments/hold")
  .bearer_auth(token)
  .json(&serde_json::json!({
      "organization_id": "o_123",
      "service_id": "s_123",
      "appointment_time": "2025-12-01T10:00:00Z",
      "appointment_duration": 30
  }))
  .send()
  .await?;

3) Replanifier ou annuler

Utilisez PATCH /appointments/{appointment_id} pour modifier l’heure ou annuler. Le client recevra l’email de mise à jour approprié.

Python
reschedule = requests.patch(
    "https://api.zimun.online/api/v1/appointments/a_123",
    headers=headers,
    json={"appointment_time": "2025-12-02T11:00:00Z"},
).json()

cancel = requests.patch(
    "https://api.zimun.online/api/v1/appointments/a_123",
    headers=headers,
    json={"status": "cancelled"},
).json()
Node.js
const reschedule = await axios.patch(
  "https://api.zimun.online/api/v1/appointments/a_123",
  { appointment_time: "2025-12-02T11:00:00Z" },
  { headers }
);

const cancel = await axios.patch(
  "https://api.zimun.online/api/v1/appointments/a_123",
  { status: "cancelled" },
  { headers }
);
Go
rescheduleBody := `{"appointment_time":"2025-12-02T11:00:00Z"}`
rescheduleReq, _ := http.NewRequest("PATCH", "https://api.zimun.online/api/v1/appointments/a_123", strings.NewReader(rescheduleBody))
rescheduleReq.Header.Set("Authorization", "Bearer "+token)
rescheduleReq.Header.Set("Content-Type", "application/json")
rescheduleResp, _ := client.Do(rescheduleReq)

cancelBody := `{"status":"cancelled"}`
cancelReq, _ := http.NewRequest("PATCH", "https://api.zimun.online/api/v1/appointments/a_123", strings.NewReader(cancelBody))
cancelReq.Header.Set("Authorization", "Bearer "+token)
cancelReq.Header.Set("Content-Type", "application/json")
cancelResp, _ := client.Do(cancelReq)
Rust
let reschedule = client
  .patch("https://api.zimun.online/api/v1/appointments/a_123")
  .bearer_auth(token)
  .json(&serde_json::json!({ "appointment_time": "2025-12-02T11:00:00Z" }))
  .send()
  .await?;

let cancel = client
  .patch("https://api.zimun.online/api/v1/appointments/a_123")
  .bearer_auth(token)
  .json(&serde_json::json!({ "status": "cancelled" }))
  .send()
  .await?;