Conventions
Toutes les opérations suivent les mêmes règles. Apprenez-les une fois et chaque ressource se lit de la même façon.
Adresse et chemins
-
Un seul hôte,
https://api.myleapp.fr, et pas de version dans le chemin :GET /organizations/{id}/products. Comment l'API évolue : Versions et évolutions. -
Les segments sont en anglais américain, en minuscules séparées par
des tirets, au pluriel pour les collections :
/delivery-notes. -
Les données d'une organisation se trouvent sous
/organizations/{id};{id}est toujours l'identifiant de l'organisation. Les autres identifiants sont nommés :/organizations/{id}/products/{productId}. -
Vos propres données se trouvent sous
/me:GET /meest le compte au nom duquel la clé agit. - Pas d'extension de fichier : le format se choisit avec
Accept.
Méthodes
| Intention | Forme | Succès |
|---|---|---|
| Lister | GET /organizations/{id}/products | 200, une liste |
| Lire | GET …/products/{productId} | 200 |
| Créer | POST /organizations/{id}/products | 201, Location, la ressource |
| Modifier | PATCH …/products/{productId}, un JSON merge patch | 200, la ressource |
| Supprimer | DELETE …/products/{productId} | 204, sans corps |
| Action métier | POST …/invoices/{invoiceId}/validate | 200, la ressource |
Un GET ne modifie jamais rien.
Identifiants
-
Un identifiant est une chaîne opaque,
<sorte>_<uuid>:product_2ab4c6e8-…,organization_7f2c41d0-…,deliveryNote_9f3c…. Gardez-le comme une chaîne, sans l'analyser. -
Une référence à une autre ressource est
<sorte>Id(companyId), ou un résumé intégré{"id", "object", …}. -
Certains identifiants se sont d'abord écrits autrement dans Myle
(
organisation_…,exercice_……). L'API répond toujours avec l'orthographe anglaise et accepte les deux en entrée : un identifiant copié depuis l'application Myle fonctionne. Gardez l'orthographe que l'API répond.
object
Chaque ressource porte object, sa sorte :
"object": "product". C'est le préfixe de son
identifiant, en toutes lettres.
Montants, quantités et taux
Un montant est un objet avec une chaîne décimale, jamais un nombre à virgule flottante :
CLI
#!/usr/bin/env bash
# conventions-money: the myle CLI (key from `myle login` or MYLE_API_KEY).
# Money is a decimal string and its currency: jq keeps the string, never a float.
myle products retrieve product_2ab4c6e8-1f3d-4a5b-8c7d-9e0f1a2b3c4d \
--organization organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d \
| jq -r '.unitPrice // empty | "\(.amount) \(.currency)"' # 45.00 EUR
JSON
"unitPrice": { "amount": "45.00", "currency": "EUR" }
TypeScript
import { Myle } from '@myleapp/myle';
const myle = new Myle();
const product = await myle.organization('organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d').products.get('product_2ab4c6e8-1f3d-4a5b-8c7d-9e0f1a2b3c4d');
// Money is a decimal string and its currency: hand it to a decimal library, never to a float.
if (product.unitPrice !== null) {
console.log(product.unitPrice.amount, product.unitPrice.currency); // 45.00 EUR
}
Python
from decimal import Decimal
from myle import Myle
myle = Myle()
product = myle.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").products.get("product_2ab4c6e8-1f3d-4a5b-8c7d-9e0f1a2b3c4d")
# Money is a decimal string and its currency: read it as a Decimal, never as a float.
if product.unit_price is not None:
price = Decimal(product.unit_price.amount)
print(price * 2, product.unit_price.currency) # 90.00 EUR
Go
package main
import (
"context"
"fmt"
"log"
myle "github.com/myleapp/myle-go"
)
func main() {
client := myle.NewClient()
org := client.Organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d")
product, err := org.Products.Get(context.Background(), "product_2ab4c6e8-1f3d-4a5b-8c7d-9e0f1a2b3c4d")
if err != nil {
log.Fatal(err)
}
// Money is a decimal string and its currency: hand it to a decimal library, never to a float.
if product.UnitPrice != nil {
fmt.Println(product.UnitPrice.Amount, product.UnitPrice.Currency) // 45.00 EUR
}
}
Java
import fr.myleapp.myle.MyleClient;
import fr.myleapp.myle.Product;
import java.math.BigDecimal;
public class Example {
public static void main(String[] args) {
MyleClient client = MyleClient.builder().build();
Product product = client.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").products().get("product_2ab4c6e8-1f3d-4a5b-8c7d-9e0f1a2b3c4d");
// Money is a decimal string and its currency: read it as a BigDecimal, never as a double.
if (product.unitPrice() != null) {
BigDecimal price = new BigDecimal(product.unitPrice().amount());
System.out.println(price.multiply(BigDecimal.valueOf(2)) + " " + product.unitPrice().currency()); // 90.00 EUR
}
}
}
Scala
import fr.myleapp.myle.MyleClient
object ConventionsMoney {
def main(args: Array[String]): Unit = {
val myle = MyleClient()
val product = myle.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").products.get("product_2ab4c6e8-1f3d-4a5b-8c7d-9e0f1a2b3c4d")
// Money is a decimal string and its currency: hand it to BigDecimal, never to a Double.
for (price <- product.unitPrice) {
println(s"${price.amount} ${price.currency}") // 45.00 EUR
}
}
}
PHP
<?php
require __DIR__ . '/vendor/autoload.php';
use Myle\Client;
$myle = new Client();
$product = $myle->organization('organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d')->products->get('product_2ab4c6e8-1f3d-4a5b-8c7d-9e0f1a2b3c4d');
// Money is a decimal string and its currency: hand it to a decimal library (bcmath, brick/math), never to a float.
if ($product->unitPrice !== null) {
echo $product->unitPrice->amount, ' ', $product->unitPrice->currency, "\n"; // 45.00 EUR
}
C#
using Myle;
using var client = new MyleClient();
var product = await client.Organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").Products.GetAsync("product_2ab4c6e8-1f3d-4a5b-8c7d-9e0f1a2b3c4d");
// Money is a decimal string and its currency: hand it to decimal, never to a double.
if (product.UnitPrice is not null)
{
Console.WriteLine($"{product.UnitPrice.Amount} {product.UnitPrice.Currency}"); // 45.00 EUR
}
Les quantités et les taux sont aussi des chaînes décimales :
"quantity": "12.5", "vatRate": "5.5".
Lisez-les avec un type décimal (Decimal en Python,
BigDecimal en Java, une bibliothèque décimale en
JavaScript), jamais en flottant.
Dates et instants
- Une date du calendrier est
YYYY-MM-DD:"issueDate": "2026-11-21". -
Un instant est en RFC 3339, en UTC :
"updatedAt": "2026-11-21T09:14:03Z". Chaque ressource acreatedAtetupdatedAt.
Les énumérations s'enrichissent
Les valeurs d'énumération sont en MAJUSCULES_SOULIGNÉES
(ACTIVE, DRAFT) et listées dans la
référence. Une nouvelle valeur peut apparaître à tout moment :
acceptez une valeur que vous ne connaissez pas,
traitez-la comme « autre », n'échouez jamais à cause d'elle.
null et absent
-
Dans une réponse, un champ facultatif vide vaut
null, il n'est jamais omis : toutes les réponses d'une ressource ont les mêmes clés. - Dans une requête, un champ absent veut dire « non fourni ».
-
Dans un
PATCH,nullvide un champ et un membre absent le laisse tel quel (voir Écritures). - Les booléens se lisent comme des affirmations :
isPrimary,hasAttachments.
Champs inconnus
De nouveaux champs s'ajoutent aux réponses sans préavis. Ignorez ceux que vous ne connaissez pas ; ne rejetez pas une réponse à cause d'eux.
En-têtes
Ce que vous envoyez
| En-tête | Usage |
|---|---|
Authorization: Bearer <clé> | Votre clé d'API (Authentification). |
Myle-API-Version: YYYY-MM-DD | Le contrat sur lequel vous avez construit ; facultatif (Versions). |
Myle-Client: <nom>/<version> | Nomme votre intégration : mon-export/1.0.0, sdk-js/1.2.0. |
Idempotency-Key | Sur un POST, rend un nouvel essai sans danger (Écritures). |
If-Match | Sur un PATCH ou un DELETE, refuse d'écraser un changement que vous n'avez pas vu. |
Accept-Language: fr ou en | La langue des messages d'erreur ; l'anglais en son absence. |
Content-Type | application/json ; application/merge-patch+json pour un PATCH. |
traceparent | W3C Trace Context ; Myle poursuit votre trace. |
Ce que vous recevez
| En-tête | Quand |
|---|---|
Myle-Request-Id | Toujours : l'identifiant de la requête dans les journaux de Myle, pour l'assistance. |
RateLimit-Policy, RateLimit | Sur chaque réponse à une clé, erreurs comprises (Limites de débit). |
Retry-After | Sur 429 et 503 : les secondes à attendre. |
ETag | Sur une ressource seule. |
Location | Sur 201 : le chemin de la nouvelle ressource. |
Content-Language | Sur une erreur : la langue de son message. |
Myle-Idempotent-Replayed: true | Quand une réponse est rejouée pour une Idempotency-Key. |
Myle-API-Version, Deprecation, Sunset, Link | Quand un ancien comportement a été servi (Versions). |
Les en-têtes propres à Myle commencent par Myle- ; les en-têtes standard gardent leur nom.