SlideShare ist ein Scribd-Unternehmen logo
1 von 41
Downloaden Sie, um offline zu lesen
API Platform
Die ultimative API-Plattform
Hello, I am
Stefan Adolf
Developer Ambassador
Turbine Kreuzberg
@stadolf
#reactjs #mongodb #blockchain #codingberlin
#elastic #symfony #turbinejetzt #microservices
REST
Representational state transfer

© Roy Fielding ~2000

CRUD Operationen auf “Resourcen”
❏ HTTP Verben: GET, POST, DELETE, PUT, PATCH
❏ URIs
❏ Unabhängig vom mediatype: json, xml, html, image/png

Definiert Operationen auf
❏ Collections /products
❏ Members /products/314

Statusloses Protokoll
❏ Ein Request muss alles enthalten, was für
die Antwort erforderlich ist.
Roy
HATEOAS
Hypermedia as the engine of application state

Responses enthalten “Links” auf verwandte Resourcen
❏ Welche Links angeboten werden, hängt vom Status der Resource ab

Clients entscheiden, ob / was sie daraus machen
❏ “code on demand”
Product
Offer
Supplier
Reservation
1
0..n
0..n
0..n
+ quantity
+ price
+ sku
+ name
+ customer : string[]
GenericRESTAPIsinSymfony
DIY
Doctrine Annotations!
Reicht das nicht ??
API Platform is a set of tools to
build and consume web APIs
Kevin
API Platform generiert APIs aus
bereits existierenden Entitäten
Stefan
@ApiResource
Exponiert Entitäten als Resource (CRUD)
@ApiFilter

SearchFilter
❏ partial, start, end, word_start

DateFilter
❏ (strictly_) after, before

BooleanFilter

RangeFilter
❏ lt,gt, lte, gte, between

Unterstützt auch nested properties!
❏ @ApiFilter(RangeFilter::class, properties={"offers.price"})
@Assert

API Platform erkennt
Symfony Constraints

Fehlermeldungen
erscheinen in der
Ausgabe
OpenAPI support (“swagger”)

Version 2 & 3
 /docs.json?<spec_version=3>

Schema-Definition von
❏ Interaktionen
❏ Datenmodell
❏ Relationen
bin/console api:swagger:export --spec-version=2 --output=swagger.json

Automatische Dokumentation
❏ + interaktiver Playground

Client-Codegeneration (!)

Stub-Generation für Server-
Implementierungen

Test-Automation
Interaktive Dokumentation
(nelmio/api-doc-bundle & redoc)
application/json
JSON-LD
JSON for linking data
Data is messy and disconnected.
JSON-LD organizes and connects it,
creating a better Web. Hydra is a lightweight vocabulary to create
hypermedia-driven Web APIs.
By specifying a number of concepts commonly used in
Web APIs it enables the creation of generic API clients
Markus
Hydra Core Vocabulary
Relationen, Links & Operationen
Markus Lanthaler
application/ld+json
+ hydra core
application/hal+json
(Hypertext Application language)
The JSON Hypertext Application Language (HAL)
is a standard which establishes conventions for
expressing hypermedia controls, such as links,
with JSON
application/vnd.api+json
JSON:API
A SPECIFICATION FOR BUILDING APIS IN JSON
If you’ve ever argued with your team about the way
your JSON responses should be formatted,
JSON:API can be your anti-bikeshedding tool.
Generierung von (backend) Client Code
via swagger-codegen
Automatisch generierte Frontends
react/redux, vue, (next, quasar, react native)
yarn global add @api-platform/client-generator
Validation
Fork von react-admin: keinerlei Frontend-Code notwendig!
API Platform Admin
Custom endpoints: Deklaration
Custom endpoints: Controller
Behat-Tests: Konfiguration
Behat-Tests: Behatch-Kontext
Der Agenturler hatte eine verrückte Idee.
Der wollte mal GraphQL einsetzen.
GraphQL
Done.
composer req webonyx/graphql-php
GraphQL - Playground
Realtime updates
composer require mercure

Installiere einen Mercure Hub
❏ z.B. Docker oder Binary
❏ Plaintext-Secret
❏ JWT mit publish-Eintrag
❏ Bestandteil der offiziellen Distribution
@ApiResource(mercure=true)
Realtime updates
GET /products/1 HTTP/1.1
Host: sfliveapi.herokuapp.com
Accept: application/ld+json
Content-Type: application/json
HTTP/1.1 200 OK
Link: <https://sfliveapi.herokuapp.com/docs.jsonld>;
rel="http://www.w3.org/ns/hydra/core#apiDocumentation"
,<https://mercuresflive.stadolf.de/hub>; rel="mercure"

Clients wissen jetzt, dass der Hub sie bei
Änderungen benachrichtigen wird.
Realtime updates: client

EventSource = native JS API für Server Sent Events
❏ In allen Browsern verfügbar
❏ Keine externen Dependencies!
SSE: Browser support
Putting it all together
Performance
sfl.stadolf.de
Dinge ohne Demo.

docker / docker-compose dev env

Helm Charts für K8S deployment

http/2 push
❏ Der Server sendet verwandte Resourcen selbst an den Client

RDFa-Support / Schema Generator
❏ DRtW: Erzeuge neue Entitäten aus öffentlichen Schemas
❏ YAML-Konfiguration
❏ Schema.org
Wrapup

Perfekt für entitätenbasierte APIs

JSON-LD out of the box

Automatische Dokumentation & Clients

Perfekt in Symfony integriert

Killerfeatures per Annotation aktivierbar

GraphQL!
Thank you o/
Stefan Adolf
Turbine Kreuzberg
@stadolf
@elmariachi111
https://github.com/elmariachi111/apiplatform-demo/

Weitere ähnliche Inhalte

Ähnlich wie Api Platform: the ultimate API Platform

DACHNUG50 Domino REST API - Konzepte und Hintergruende.pdf
DACHNUG50 Domino REST API - Konzepte und Hintergruende.pdfDACHNUG50 Domino REST API - Konzepte und Hintergruende.pdf
DACHNUG50 Domino REST API - Konzepte und Hintergruende.pdfDNUG e.V.
 
Ist GraphQL das bessere REST
Ist GraphQL das bessere RESTIst GraphQL das bessere REST
Ist GraphQL das bessere RESTMartin Abraham
 
BASTA! Spring 2017 - Warum warten auf die IDE? Direct Coding in der eigenen A...
BASTA! Spring 2017 - Warum warten auf die IDE? Direct Coding in der eigenen A...BASTA! Spring 2017 - Warum warten auf die IDE? Direct Coding in der eigenen A...
BASTA! Spring 2017 - Warum warten auf die IDE? Direct Coding in der eigenen A...Robin Sedlaczek
 
Gewinnung von OPEN SOURCE Techniken für junge Unternehmen
Gewinnung von OPEN SOURCE Techniken für junge UnternehmenGewinnung von OPEN SOURCE Techniken für junge Unternehmen
Gewinnung von OPEN SOURCE Techniken für junge UnternehmenBjoern Reinhold
 
2008 - Gewinnung von OPEN SOURCE Techniken für junge Unternehmen
2008 - Gewinnung von OPEN SOURCE Techniken für junge Unternehmen2008 - Gewinnung von OPEN SOURCE Techniken für junge Unternehmen
2008 - Gewinnung von OPEN SOURCE Techniken für junge UnternehmenBjoern Reinhold
 
Apache DeviceMap - Web-Dev-BBQ Stuttgart
Apache DeviceMap - Web-Dev-BBQ StuttgartApache DeviceMap - Web-Dev-BBQ Stuttgart
Apache DeviceMap - Web-Dev-BBQ StuttgartWerner Keil
 
B3 Lotus Expeditor Und Composite Applications
B3 Lotus Expeditor Und Composite ApplicationsB3 Lotus Expeditor Und Composite Applications
B3 Lotus Expeditor Und Composite ApplicationsAndreas Schulte
 
REST: Versprechen, Wirklichkeit & Alternativen: GraphQL, GRPC, JSON RPC...
REST: Versprechen, Wirklichkeit & Alternativen: GraphQL, GRPC, JSON RPC...REST: Versprechen, Wirklichkeit & Alternativen: GraphQL, GRPC, JSON RPC...
REST: Versprechen, Wirklichkeit & Alternativen: GraphQL, GRPC, JSON RPC...predic8
 
Slides (2) zu Teil 2 der Veranstaltungsreihe Anwendungsentwicklung mit Volt M...
Slides (2) zu Teil 2 der Veranstaltungsreihe Anwendungsentwicklung mit Volt M...Slides (2) zu Teil 2 der Veranstaltungsreihe Anwendungsentwicklung mit Volt M...
Slides (2) zu Teil 2 der Veranstaltungsreihe Anwendungsentwicklung mit Volt M...DNUG e.V.
 
Slides zum Impulsreferat: HCL UDP - DNUG Stammtisch Salzburg
Slides zum Impulsreferat: HCL UDP - DNUG Stammtisch SalzburgSlides zum Impulsreferat: HCL UDP - DNUG Stammtisch Salzburg
Slides zum Impulsreferat: HCL UDP - DNUG Stammtisch SalzburgDNUG e.V.
 
BASTA! Spring 2017 - C# Script in Action
BASTA! Spring 2017 - C# Script in ActionBASTA! Spring 2017 - C# Script in Action
BASTA! Spring 2017 - C# Script in ActionRobin Sedlaczek
 
Entwicklung mit Volt MX und Co. | Teil 1
Entwicklung mit Volt MX und Co. | Teil 1Entwicklung mit Volt MX und Co. | Teil 1
Entwicklung mit Volt MX und Co. | Teil 1DNUG e.V.
 
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.Torsten Kleiber
 
Mehrserver Lösungen
Mehrserver LösungenMehrserver Lösungen
Mehrserver LösungenAvarteq
 
REST Problems
REST ProblemsREST Problems
REST Problemspredic8
 
Fische im Rechenzentrum – Was genau ist eigentlich dieses Redfish und wozu br...
Fische im Rechenzentrum – Was genau ist eigentlich dieses Redfish und wozu br...Fische im Rechenzentrum – Was genau ist eigentlich dieses Redfish und wozu br...
Fische im Rechenzentrum – Was genau ist eigentlich dieses Redfish und wozu br...BOSTON Server & Storage Solutions GmbH
 
new Html5 features and browser compatibility, Stand der Standardisierung, Übe...
new Html5 features and browser compatibility, Stand der Standardisierung, Übe...new Html5 features and browser compatibility, Stand der Standardisierung, Übe...
new Html5 features and browser compatibility, Stand der Standardisierung, Übe...Sinan Akalın
 

Ähnlich wie Api Platform: the ultimate API Platform (20)

PHP auf IBM Plattformen
PHP auf IBM PlattformenPHP auf IBM Plattformen
PHP auf IBM Plattformen
 
DACHNUG50 Domino REST API - Konzepte und Hintergruende.pdf
DACHNUG50 Domino REST API - Konzepte und Hintergruende.pdfDACHNUG50 Domino REST API - Konzepte und Hintergruende.pdf
DACHNUG50 Domino REST API - Konzepte und Hintergruende.pdf
 
Ist GraphQL das bessere REST
Ist GraphQL das bessere RESTIst GraphQL das bessere REST
Ist GraphQL das bessere REST
 
BASTA! Spring 2017 - Warum warten auf die IDE? Direct Coding in der eigenen A...
BASTA! Spring 2017 - Warum warten auf die IDE? Direct Coding in der eigenen A...BASTA! Spring 2017 - Warum warten auf die IDE? Direct Coding in der eigenen A...
BASTA! Spring 2017 - Warum warten auf die IDE? Direct Coding in der eigenen A...
 
Gewinnung von OPEN SOURCE Techniken für junge Unternehmen
Gewinnung von OPEN SOURCE Techniken für junge UnternehmenGewinnung von OPEN SOURCE Techniken für junge Unternehmen
Gewinnung von OPEN SOURCE Techniken für junge Unternehmen
 
PHPblue LOS!NRW
PHPblue LOS!NRWPHPblue LOS!NRW
PHPblue LOS!NRW
 
2008 - Gewinnung von OPEN SOURCE Techniken für junge Unternehmen
2008 - Gewinnung von OPEN SOURCE Techniken für junge Unternehmen2008 - Gewinnung von OPEN SOURCE Techniken für junge Unternehmen
2008 - Gewinnung von OPEN SOURCE Techniken für junge Unternehmen
 
Apache DeviceMap - Web-Dev-BBQ Stuttgart
Apache DeviceMap - Web-Dev-BBQ StuttgartApache DeviceMap - Web-Dev-BBQ Stuttgart
Apache DeviceMap - Web-Dev-BBQ Stuttgart
 
B3 Lotus Expeditor Und Composite Applications
B3 Lotus Expeditor Und Composite ApplicationsB3 Lotus Expeditor Und Composite Applications
B3 Lotus Expeditor Und Composite Applications
 
REST: Versprechen, Wirklichkeit & Alternativen: GraphQL, GRPC, JSON RPC...
REST: Versprechen, Wirklichkeit & Alternativen: GraphQL, GRPC, JSON RPC...REST: Versprechen, Wirklichkeit & Alternativen: GraphQL, GRPC, JSON RPC...
REST: Versprechen, Wirklichkeit & Alternativen: GraphQL, GRPC, JSON RPC...
 
Slides (2) zu Teil 2 der Veranstaltungsreihe Anwendungsentwicklung mit Volt M...
Slides (2) zu Teil 2 der Veranstaltungsreihe Anwendungsentwicklung mit Volt M...Slides (2) zu Teil 2 der Veranstaltungsreihe Anwendungsentwicklung mit Volt M...
Slides (2) zu Teil 2 der Veranstaltungsreihe Anwendungsentwicklung mit Volt M...
 
Web-API Design in Java
Web-API Design in JavaWeb-API Design in Java
Web-API Design in Java
 
Slides zum Impulsreferat: HCL UDP - DNUG Stammtisch Salzburg
Slides zum Impulsreferat: HCL UDP - DNUG Stammtisch SalzburgSlides zum Impulsreferat: HCL UDP - DNUG Stammtisch Salzburg
Slides zum Impulsreferat: HCL UDP - DNUG Stammtisch Salzburg
 
BASTA! Spring 2017 - C# Script in Action
BASTA! Spring 2017 - C# Script in ActionBASTA! Spring 2017 - C# Script in Action
BASTA! Spring 2017 - C# Script in Action
 
Entwicklung mit Volt MX und Co. | Teil 1
Entwicklung mit Volt MX und Co. | Teil 1Entwicklung mit Volt MX und Co. | Teil 1
Entwicklung mit Volt MX und Co. | Teil 1
 
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
 
Mehrserver Lösungen
Mehrserver LösungenMehrserver Lösungen
Mehrserver Lösungen
 
REST Problems
REST ProblemsREST Problems
REST Problems
 
Fische im Rechenzentrum – Was genau ist eigentlich dieses Redfish und wozu br...
Fische im Rechenzentrum – Was genau ist eigentlich dieses Redfish und wozu br...Fische im Rechenzentrum – Was genau ist eigentlich dieses Redfish und wozu br...
Fische im Rechenzentrum – Was genau ist eigentlich dieses Redfish und wozu br...
 
new Html5 features and browser compatibility, Stand der Standardisierung, Übe...
new Html5 features and browser compatibility, Stand der Standardisierung, Übe...new Html5 features and browser compatibility, Stand der Standardisierung, Übe...
new Html5 features and browser compatibility, Stand der Standardisierung, Übe...
 

Mehr von Stefan Adolf

Blockchains - Technical foundations
Blockchains - Technical foundationsBlockchains - Technical foundations
Blockchains - Technical foundationsStefan Adolf
 
HOW TO SURVIVE A 2DAY HACKATHON?
HOW TO SURVIVE A 2DAY HACKATHON?HOW TO SURVIVE A 2DAY HACKATHON?
HOW TO SURVIVE A 2DAY HACKATHON?Stefan Adolf
 
Digitale Selbstbestimmung mit Hilfe dezentraler Technologien
Digitale Selbstbestimmung mit Hilfe dezentraler TechnologienDigitale Selbstbestimmung mit Hilfe dezentraler Technologien
Digitale Selbstbestimmung mit Hilfe dezentraler TechnologienStefan Adolf
 
Digitale Selbstbestimmung | Anwendungsfälle der Dezentralität
Digitale Selbstbestimmung | Anwendungsfälle der DezentralitätDigitale Selbstbestimmung | Anwendungsfälle der Dezentralität
Digitale Selbstbestimmung | Anwendungsfälle der DezentralitätStefan Adolf
 
Decentralized technology: a (short) survey
Decentralized technology: a (short) surveyDecentralized technology: a (short) survey
Decentralized technology: a (short) surveyStefan Adolf
 
Productive web applications that run only on the frontend
Productive web applications that run only on the frontendProductive web applications that run only on the frontend
Productive web applications that run only on the frontendStefan Adolf
 
DePA - die dezentrale Patientenakte (29.1. FU Berlin)
DePA - die dezentrale Patientenakte (29.1. FU Berlin)DePA - die dezentrale Patientenakte (29.1. FU Berlin)
DePA - die dezentrale Patientenakte (29.1. FU Berlin)Stefan Adolf
 
DePA - die dezentrale Patientenakte
DePA - die dezentrale PatientenakteDePA - die dezentrale Patientenakte
DePA - die dezentrale PatientenakteStefan Adolf
 
Was ist eine Datenbank - und was hat Blockchain damit zu tun?
Was ist eine Datenbank - und was hat Blockchain damit zu tun?Was ist eine Datenbank - und was hat Blockchain damit zu tun?
Was ist eine Datenbank - und was hat Blockchain damit zu tun?Stefan Adolf
 
Never Code Alone: Von Symfony Forms zu einer SPA auf APIs
Never Code Alone: Von Symfony Forms zu einer SPA auf APIsNever Code Alone: Von Symfony Forms zu einer SPA auf APIs
Never Code Alone: Von Symfony Forms zu einer SPA auf APIsStefan Adolf
 
Decentralize all the things
Decentralize all the thingsDecentralize all the things
Decentralize all the thingsStefan Adolf
 
Indexing Decentralized Data with Ethereum, IPFS & The Graph
Indexing Decentralized Data with Ethereum, IPFS & The GraphIndexing Decentralized Data with Ethereum, IPFS & The Graph
Indexing Decentralized Data with Ethereum, IPFS & The GraphStefan Adolf
 
Gatsby (Code.Talks) 2019
Gatsby (Code.Talks) 2019Gatsby (Code.Talks) 2019
Gatsby (Code.Talks) 2019Stefan Adolf
 
A micro service story
 A micro service story A micro service story
A micro service storyStefan Adolf
 
Pump up the JAM with Gatsby (2019)
Pump up the JAM with Gatsby (2019)Pump up the JAM with Gatsby (2019)
Pump up the JAM with Gatsby (2019)Stefan Adolf
 
Testing API platform with Behat BDD tests
Testing API platform with Behat BDD testsTesting API platform with Behat BDD tests
Testing API platform with Behat BDD testsStefan Adolf
 
Hack it like its hot!
Hack it like its hot!Hack it like its hot!
Hack it like its hot!Stefan Adolf
 
api-platform: the ultimate API platform
api-platform: the ultimate API platformapi-platform: the ultimate API platform
api-platform: the ultimate API platformStefan Adolf
 
Webpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usWebpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usStefan Adolf
 
(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of us(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of usStefan Adolf
 

Mehr von Stefan Adolf (20)

Blockchains - Technical foundations
Blockchains - Technical foundationsBlockchains - Technical foundations
Blockchains - Technical foundations
 
HOW TO SURVIVE A 2DAY HACKATHON?
HOW TO SURVIVE A 2DAY HACKATHON?HOW TO SURVIVE A 2DAY HACKATHON?
HOW TO SURVIVE A 2DAY HACKATHON?
 
Digitale Selbstbestimmung mit Hilfe dezentraler Technologien
Digitale Selbstbestimmung mit Hilfe dezentraler TechnologienDigitale Selbstbestimmung mit Hilfe dezentraler Technologien
Digitale Selbstbestimmung mit Hilfe dezentraler Technologien
 
Digitale Selbstbestimmung | Anwendungsfälle der Dezentralität
Digitale Selbstbestimmung | Anwendungsfälle der DezentralitätDigitale Selbstbestimmung | Anwendungsfälle der Dezentralität
Digitale Selbstbestimmung | Anwendungsfälle der Dezentralität
 
Decentralized technology: a (short) survey
Decentralized technology: a (short) surveyDecentralized technology: a (short) survey
Decentralized technology: a (short) survey
 
Productive web applications that run only on the frontend
Productive web applications that run only on the frontendProductive web applications that run only on the frontend
Productive web applications that run only on the frontend
 
DePA - die dezentrale Patientenakte (29.1. FU Berlin)
DePA - die dezentrale Patientenakte (29.1. FU Berlin)DePA - die dezentrale Patientenakte (29.1. FU Berlin)
DePA - die dezentrale Patientenakte (29.1. FU Berlin)
 
DePA - die dezentrale Patientenakte
DePA - die dezentrale PatientenakteDePA - die dezentrale Patientenakte
DePA - die dezentrale Patientenakte
 
Was ist eine Datenbank - und was hat Blockchain damit zu tun?
Was ist eine Datenbank - und was hat Blockchain damit zu tun?Was ist eine Datenbank - und was hat Blockchain damit zu tun?
Was ist eine Datenbank - und was hat Blockchain damit zu tun?
 
Never Code Alone: Von Symfony Forms zu einer SPA auf APIs
Never Code Alone: Von Symfony Forms zu einer SPA auf APIsNever Code Alone: Von Symfony Forms zu einer SPA auf APIs
Never Code Alone: Von Symfony Forms zu einer SPA auf APIs
 
Decentralize all the things
Decentralize all the thingsDecentralize all the things
Decentralize all the things
 
Indexing Decentralized Data with Ethereum, IPFS & The Graph
Indexing Decentralized Data with Ethereum, IPFS & The GraphIndexing Decentralized Data with Ethereum, IPFS & The Graph
Indexing Decentralized Data with Ethereum, IPFS & The Graph
 
Gatsby (Code.Talks) 2019
Gatsby (Code.Talks) 2019Gatsby (Code.Talks) 2019
Gatsby (Code.Talks) 2019
 
A micro service story
 A micro service story A micro service story
A micro service story
 
Pump up the JAM with Gatsby (2019)
Pump up the JAM with Gatsby (2019)Pump up the JAM with Gatsby (2019)
Pump up the JAM with Gatsby (2019)
 
Testing API platform with Behat BDD tests
Testing API platform with Behat BDD testsTesting API platform with Behat BDD tests
Testing API platform with Behat BDD tests
 
Hack it like its hot!
Hack it like its hot!Hack it like its hot!
Hack it like its hot!
 
api-platform: the ultimate API platform
api-platform: the ultimate API platformapi-platform: the ultimate API platform
api-platform: the ultimate API platform
 
Webpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usWebpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of us
 
(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of us(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of us
 

Api Platform: the ultimate API Platform