Toutes les requêtes de l'API doivent être authentifiées à l'aide du token d'API généré via l'interface utilisateur. L'authentification doit être effectuée en incluant le header Authorization: Bearer YOUR_API_TOKEN
dans chaque requête.
YOUR_API_TOKEN est une clé unique qui te permettra d'accéder à l'API ( Générer un token )
Les plannings sont la ressource centrale de l'API. Tu peux lister tous les plannings disponibles et filtrer par type.
- Lister les plannings
GET /api/v1/plannings
Endpoint : GET /api/v1/plannings
Requête (sans filtre) :
curl -X GET "https://shiftheroes.fr/api/v1/plannings" -H "Authorization: Bearer YOUR_API_TOKEN"
OR
$headers = @{
"Authorization" = "Bearer YOUR_API_TOKEN"
}
$response = Invoke-WebRequest -Uri "https://shiftheroes.fr/api/v1/plannings" -Headers $headers
Requête (avec filtre de type) :
curl -X GET "https://shiftheroes.fr/api/v1/plannings?type=TYPE" -H "Authorization: Bearer YOUR_API_TOKEN"
OR
$headers = @{
"Authorization" = "Bearer YOUR_API_TOKEN"
}
$response = Invoke-WebRequest -Uri "https://shiftheroes.fr/api/v1/plannings?type=TYPE" -Headers $headers
Réponse :
[ { "id": "X05fNV", "planning_type": "daily", "state": "available", "published_at": "2023-07-07T08:46:45.215Z" }, { "id": "e6bdK2", "planning_type": "permanent", "state": "available", "published_at": "2023-07-07T08:37:54.353Z" }, { "id": "j9KDf4", "planning_type": "weekly", "state": "available", "published_at": "2023-07-07T08:47:58.611Z" } ]
Astuce :
Utilisez le paramètre ?type=TYPE pour filtrer les plannings selon leur type (permanent, daily, weekly).
- Lister les créneaux d'un planning
GET /api/v1/plannings/:planning_id/shifts
Endpoint : GET /api/v1/plannings/:planning_id/shifts
Requête :
curl -X GET "https://shiftheroes.fr/api/v1/plannings/:planning_id/shifts" -H "Authorization: Bearer YOUR_API_TOKEN"
OR
$headers = @{
"Authorization" = "Bearer YOUR_API_TOKEN"
}
$response = Invoke-WebRequest -Uri "https://shiftheroes.fr/api/v1/plannings/:planning_id/shifts" -Headers $headers
Réponse :
[ { "id": "lqQFnY", "day": "mardi", "start_hour": "2000-01-01T08:00:00.000Z", "end_hour": "2000-01-01T14:00:00.000Z", "seats": 10, "seats_taken": 1 }, { "id": "x2OFW1", "day": "lundi", "start_hour": "2000-01-01T08:00:00.000Z", "end_hour": "2000-01-01T14:00:00.000Z", "seats": 12, "seats_taken": 0 } ]
Astuce :
Dans l'exemple j'utilise dans l'url :planning_id , ce qu'il faut faire c'est modifier cette valeur par la valeur de l'identifiant du planning souhaité.
- Lister ses réservations sur un planning
GET /api/v1/plannings/:planning_id/reservations
Endpoint : GET /api/v1/plannings/:planning_id/reservation
Requête :
curl -X GET "https://shiftheroes.fr/api/v1/plannings/:planning_id/reservations" -H "Authorization: Bearer YOUR_API_TOKEN"
OR
$headers = @{
"Authorization" = "Bearer YOUR_API_TOKEN"
}
$response = Invoke-WebRequest -Uri "https://shiftheroes.fr/api/v1/plannings/:planning_id/reservations" -Headers $headers
Réponse :
[ { "id": 103, "user_id": 5, "shift_id": "lqQFnY" }, { "id": 104, "user_id": 5, "shift_id": "x2OFW1" } ]
- Créer une réservation sur un shift
POST /api/v1/plannings/:planning_id/shifts/:shift_id/reservations
Endpoint : POST /api/v1/plannings/:planning_id/shifts/:shift_id/reservations
Requête :
curl -X POST "https://shiftheroes.fr/api/v1/plannings/:planning_id/shifts/:shift_id/reservations" -H "Authorization: Bearer YOUR_API_TOKEN"
OR
$headers = @{
"Authorization" = "Bearer YOUR_API_TOKEN"
}
$response = Invoke-WebRequest -Uri "https://shiftheroes.fr/api/v1/plannings/:planning_id/shifts/:shift_id/reservations" -Method Post -Headers $headers
Réponse :
La réservation est crée avec succès.
- Supprimer une réservation
DELETE /api/v1/plannings/:planning_id/shifts/:shift_id/reservations/:reservation_id
Endpoint : DELETE /api/v1/plannings/:planning_id/shifts/:shift_id/reservations/:reservation_id
Requête :
curl -X DELETE "https://shiftheroes.fr/api/v1/plannings/:planning_id/shifts/:shift_id/reservations/:reservation_id" -H "Authorization: Bearer YOUR_API_TOKEN"
OR
$headers = @{
"Authorization" = "Bearer YOUR_API_TOKEN"
}
$response = Invoke-WebRequest -Uri "https://shiftheroes.fr/api/v1/plannings/:planning_id/shifts/:shift_id/reservations/:reservation_id" -Method Delete -Headers $headers
Réponse :
La réservation est supprimée avec succès.
I've used this to convert Curl requests to Python
Curl Converter