Les APIs REST du futur

Presenter Notes

Le livre RESTful Web APIs

Smeuh.Org

2007: RESTful Web Services, 2013: RESTful Web APIs

Presenter Notes

Hypermedia

  • Le ST dans REST
  • Un mouvement, pas un état de l'art
  • Des APIs découvrables
  • Des formats réutilisables
  • Des vocabulaires réutilisables
  • Des lib clientes réutilisables

Presenter Notes

Types de media existants

Presenter Notes

Presenter Notes

Méthode de conception

  1. Lister les descripteurs sémantiques
  2. Tracer un diagramme d'état
  3. Réutiliser des descripteurs sémantiques existants
  4. Choisir un type de media
  5. Écrire un profil
  6. Coder
  7. Publier

Presenter Notes

Libs clientes

Presenter Notes

Examples d'utilisation de JSON-LD

Presenter Notes

Exemple : API pour Humantalks

Version JSON de base

GET http://api.example.com/sessions/a1b2c2

{
  "title": "Humancoders Talk Toulouse",
  "date": "12/01/2015 19:00",
  "place": {
    "name": "La Cantine Toulouse",
    "address": "27 Rue d'Aubuisson",
    "postCode": "31000",
    "city": "Toulouse"
  }
}

Presenter Notes

Version JSON-LD

GET http://api.example.com/sessions/a1b2c2

{
  "@context": "http://schema.org",
  "@type": "Event",
  "@id": "http://api.example.com/sessions/a1b2c2",
  "name": "Humancoders Talk Toulouse",
  "location": {
    "@type": "PostalAddress",
    "name": "La Cantine Toulouse",
    "addressLocality": "Toulouse",
    "postalCode": "31000",
    "streetAddress": "27 Rue d'Aubuisson",
    "url": "http://lacantine-toulouse.org/"
  },
  "startDate": "2015-01-12T19:00",
  "url": "http://humantalks.com/cities/toulouse/events/190"
}

Presenter Notes

Ajouter la liste de présentations

GET http://api.example.com/sessions/a1b2c2

{
  "@context": "http://schema.org",
  "@type": "Event",
  "@id": "http://api.example.com/sessions/a1b2c2",
  "name": "Humancoders Talk Toulouse",
  "location": { "..." },
  "startDate": "2015-01-12T19:00",
  "url": "http://humantalks.com/cities/toulouse/events/190",
  "subEvent": [
    {
       "@id": "http://api.example.com/sessions/a1b2c2/talks/9093",
       "name": "Les personnes les plus dangereuses d'Internet"
    },
    {
       "@id": "http://api.example.com/sessions/a1b2c2/talks/9094",
       "name": "Les APIs REST du futur"
    },
    "..."
  ]
}

Presenter Notes

Récuperer une présentation

GET http://api.example.com/sessions/a1b2c2/talks/9094

{
  "@context": "http://schema.org",
  "@type": "Event",
  "@id": "http://api.example.com/sessions/a1b2c2/talks/9094",
  "name": "Les APIs REST du futur",
  "performer": {
    "@type": "Person",
    "name": "Alex Marandon",
    "worksFor": [
       {
         "@type": "Corporation",
         "name": "Makina Corpus",
         "url": "http://makina-corpus.com"
       },
       {
         "@type": "GovernmentOrganization",
         "name": "Météo France",
         "url": "http://meteo.fr"
       }
    ]
  }
}

Presenter Notes