SlideShare a Scribd company logo
Robust APIs
Nejc Zupan / @nzupan /
Why → What →
How
Robust APIs:
Why → What →
How
Robust APIs:
The plone.api story
Get the site URL?
Get the site URL?
Move an object?
Move an object?
Display the review state?
Lessons Learned
• Write API spec before you write code
• Write narrative docs before you write code
• Both need to be runnable/testable
=>
=>
Why → What →
How
Robust APIs:
django-rest-swagger
drf-swagger
flask-swagger-ui
flask-swagger
cornice-swagger
pyramid-swagger-router
pyramid-swagger
flask-restplus
flasgger
pyramid-jsonapi
pecan-swagger
falsy
https://swagger.io/tools/open-source/open-source-
integrations/:
pyramid-apispec
pyramid-oas3 FastAPI
connexion
cornice-swagger
pyramid-swagger-router
pyramid-swagger
pyramid-jsonapi
pyramid-apispec
pyramid-oas3
source: discovery.com
Generation
vs
Validation
Generation Validation
1. Define views and
models in Python
2. Generate
openapi.yaml by
introspecting Python
code
1. Write opeanapi.yaml
2. Define views and
models in Python
3. Validate against
openapi.yaml
“API-first”
vs
“cool” “precise”
Validation approach or “API-
first”
1. [API-first] incentivizes you to write the specification
so that all of your developers can understand what
your API does, even before you write a single line
of code. (source: zalando/connexion)
2. Provides a clear separation between the intent and
the implementation.
Validation approach or “API-
first”
3. Generation/Validation is imperfect. Much easier
escape hatch with Validation approach.
4. Several services running the same API is easy with
API-first approach.
Validation approach or “API-
first”
3. Generation/Validation is imperfect. Much easier
escape hatch with Validation approach.
4. Several services running the same API is easy with
API-first approach
–Adam Savage
“Use more cooling liquid”
django-rest-swagger
drf-swagger
flask-swagger-ui
flask-swagger
cornice-swagger
pyramid-swagger-router
pyramid-swagger
flask-restplus
flasgger
pyramid-jsonapi
pecan-swagger
falsy
https://swagger.io/tools/open-source/open-source-
integrations/:
pyramid-apispec
pyramid-oas3 FastAPI
connexion
pyramid-swagger
flasgger
pyramid-oas3
falsy
connexion
pyramid-swagger
pyramid-oas3
pyramid_openapi3
pyramid_openapi3
• API documentation never
out-of-date
• Try-it-out examples
• API spec is always valid
• Payload validation &
sanitation
• Responses must match
schema
• A single source of truth
Bonus karma points:
https://github.com/Pylons/pyramid_openapi3/blob/master/examples/singlefile/app.p
y
https://github.com/Pylons/pyramid_openapi3/blob/master/examples/singlefile/app.p
y
https://github.com/Pylons/pyramid_openapi3/blob/master/examples/singlefile/app.p
y
https://github.com/Pylons/pyramid_openapi3/blob/master/examples/singlefile/app.p
y
https://github.com/Pylons/pyramid_openapi3/blob/master/examples/singlefile/app.p
y
https://github.com/Pylons/pyramid_openapi3/blob/master/examples/singlefile/app.p
y
“See how the exact same Medium.com clone (called Conduit) is
built using any of our “supported frontends and backends. Yes,
you can mix and match them, because they all adhere to the
same API spec 😮😎”
"The mother of all demo apps"
github.com/niteoweb/pyramid-realworld-example-app:
• Pyramid
• PostgreSQL
• OpenAPI 3.0
• Heroku
• Tests
• Type Hints
• Linters
• DB migrations
Why → What →
How
Robust APIs:
Nejc Zupan / @nzupan /
github.com/pylons/pyramid_openapi3

More Related Content

What's hot

[BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgR...
[BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgR...[BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgR...
[BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgR...François-Guillaume Ribreau
 
Continuous integration with Git & CI Joe
Continuous integration with Git & CI JoeContinuous integration with Git & CI Joe
Continuous integration with Git & CI JoeShawn Price
 
OpenAPI development with Python
OpenAPI development with PythonOpenAPI development with Python
OpenAPI development with PythonTakuro Wada
 
GREAT STEP 2. TDD & MockMVC
GREAT STEP 2. TDD & MockMVCGREAT STEP 2. TDD & MockMVC
GREAT STEP 2. TDD & MockMVCCovenant Ko
 
Ať se z kódu nepráší! 2013
Ať se z kódu nepráší! 2013Ať se z kódu nepráší! 2013
Ať se z kódu nepráší! 2013Juraj Michálek
 
JPA 스터디 Week1 - 하이버네이트, 캐시
JPA 스터디 Week1 - 하이버네이트, 캐시JPA 스터디 Week1 - 하이버네이트, 캐시
JPA 스터디 Week1 - 하이버네이트, 캐시Covenant Ko
 
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...Pôle Systematic Paris-Region
 
Python for IoT, A return of experience
Python for IoT, A return of experiencePython for IoT, A return of experience
Python for IoT, A return of experienceAlexandre Abadie
 
Rails Vs CakePHP
Rails Vs CakePHPRails Vs CakePHP
Rails Vs CakePHPGautam Rege
 
Web frameworks don't matter
Web frameworks don't matterWeb frameworks don't matter
Web frameworks don't matterTomas Doran
 
GREAT STEP 1. 테스트 코드를 향한 위대한 발걸음
GREAT STEP 1. 테스트 코드를 향한 위대한 발걸음GREAT STEP 1. 테스트 코드를 향한 위대한 발걸음
GREAT STEP 1. 테스트 코드를 향한 위대한 발걸음Covenant Ko
 
JPA Week3 Entity Mapping / Hexagonal Architecture
JPA Week3 Entity Mapping / Hexagonal ArchitectureJPA Week3 Entity Mapping / Hexagonal Architecture
JPA Week3 Entity Mapping / Hexagonal ArchitectureCovenant Ko
 
gRPC 프레임워크를 만들며 알아보는 파이썬 - 파이콘2020
gRPC 프레임워크를 만들며 알아보는 파이썬  - 파이콘2020gRPC 프레임워크를 만들며 알아보는 파이썬  - 파이콘2020
gRPC 프레임워크를 만들며 알아보는 파이썬 - 파이콘2020재현 신
 
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
 
eXo EC - Groovy Programming Language
eXo EC - Groovy Programming LanguageeXo EC - Groovy Programming Language
eXo EC - Groovy Programming LanguageHoat Le
 
Type Annotations in Python: Whats, Whys and Wows!
Type Annotations in Python: Whats, Whys and Wows!Type Annotations in Python: Whats, Whys and Wows!
Type Annotations in Python: Whats, Whys and Wows!Andreas Dewes
 
gRPC:更高效的微服務介面
gRPC:更高效的微服務介面gRPC:更高效的微服務介面
gRPC:更高效的微服務介面William Yeh
 

What's hot (20)

Development Principles & Philosophy
Development Principles & PhilosophyDevelopment Principles & Philosophy
Development Principles & Philosophy
 
[BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgR...
[BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgR...[BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgR...
[BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgR...
 
Continuous integration with Git & CI Joe
Continuous integration with Git & CI JoeContinuous integration with Git & CI Joe
Continuous integration with Git & CI Joe
 
OpenAPI development with Python
OpenAPI development with PythonOpenAPI development with Python
OpenAPI development with Python
 
GREAT STEP 2. TDD & MockMVC
GREAT STEP 2. TDD & MockMVCGREAT STEP 2. TDD & MockMVC
GREAT STEP 2. TDD & MockMVC
 
Ať se z kódu nepráší! 2013
Ať se z kódu nepráší! 2013Ať se z kódu nepráší! 2013
Ať se z kódu nepráší! 2013
 
JPA 스터디 Week1 - 하이버네이트, 캐시
JPA 스터디 Week1 - 하이버네이트, 캐시JPA 스터디 Week1 - 하이버네이트, 캐시
JPA 스터디 Week1 - 하이버네이트, 캐시
 
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
Open-Source Analytics Stack on MongoDB, with Schema, Pierre-Alain Jachiet and...
 
Groovy & Grails
Groovy & GrailsGroovy & Grails
Groovy & Grails
 
Python for IoT, A return of experience
Python for IoT, A return of experiencePython for IoT, A return of experience
Python for IoT, A return of experience
 
Rails Vs CakePHP
Rails Vs CakePHPRails Vs CakePHP
Rails Vs CakePHP
 
Web frameworks don't matter
Web frameworks don't matterWeb frameworks don't matter
Web frameworks don't matter
 
GREAT STEP 1. 테스트 코드를 향한 위대한 발걸음
GREAT STEP 1. 테스트 코드를 향한 위대한 발걸음GREAT STEP 1. 테스트 코드를 향한 위대한 발걸음
GREAT STEP 1. 테스트 코드를 향한 위대한 발걸음
 
JPA Week3 Entity Mapping / Hexagonal Architecture
JPA Week3 Entity Mapping / Hexagonal ArchitectureJPA Week3 Entity Mapping / Hexagonal Architecture
JPA Week3 Entity Mapping / Hexagonal Architecture
 
gRPC 프레임워크를 만들며 알아보는 파이썬 - 파이콘2020
gRPC 프레임워크를 만들며 알아보는 파이썬  - 파이콘2020gRPC 프레임워크를 만들며 알아보는 파이썬  - 파이콘2020
gRPC 프레임워크를 만들며 알아보는 파이썬 - 파이콘2020
 
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
 
eXo EC - Groovy Programming Language
eXo EC - Groovy Programming LanguageeXo EC - Groovy Programming Language
eXo EC - Groovy Programming Language
 
Type Annotations in Python: Whats, Whys and Wows!
Type Annotations in Python: Whats, Whys and Wows!Type Annotations in Python: Whats, Whys and Wows!
Type Annotations in Python: Whats, Whys and Wows!
 
Ruby - The Hard Bits
Ruby - The Hard BitsRuby - The Hard Bits
Ruby - The Hard Bits
 
gRPC:更高效的微服務介面
gRPC:更高效的微服務介面gRPC:更高效的微服務介面
gRPC:更高效的微服務介面
 

Similar to Building robust REST APIs

Developing Brilliant and Powerful APIs in Ruby & Python
Developing Brilliant and Powerful APIs in Ruby & PythonDeveloping Brilliant and Powerful APIs in Ruby & Python
Developing Brilliant and Powerful APIs in Ruby & PythonSmartBear
 
Panoramic view of web APIs
Panoramic view of web APIsPanoramic view of web APIs
Panoramic view of web APIsKaren Immanuel
 
Apidays New York 2024 - API Discovery - From Crawl to Run by Rob Dickinson, G...
Apidays New York 2024 - API Discovery - From Crawl to Run by Rob Dickinson, G...Apidays New York 2024 - API Discovery - From Crawl to Run by Rob Dickinson, G...
Apidays New York 2024 - API Discovery - From Crawl to Run by Rob Dickinson, G...apidays
 
API Discovery from Crawl to Run - Rob Dickinson, Graylog
API Discovery from Crawl to Run - Rob Dickinson, GraylogAPI Discovery from Crawl to Run - Rob Dickinson, Graylog
API Discovery from Crawl to Run - Rob Dickinson, GraylogNordic APIs
 
Building Better Web APIs with Rails
Building Better Web APIs with RailsBuilding Better Web APIs with Rails
Building Better Web APIs with RailsAll Things Open
 
SXSW 2012 JavaScript MythBusters
SXSW 2012 JavaScript MythBustersSXSW 2012 JavaScript MythBusters
SXSW 2012 JavaScript MythBustersElena-Oana Tabaranu
 
Silent web app testing by example - BerlinSides 2011
Silent web app testing by example - BerlinSides 2011Silent web app testing by example - BerlinSides 2011
Silent web app testing by example - BerlinSides 2011Abraham Aranguren
 
API Proxy Auto Discovery
API Proxy Auto DiscoveryAPI Proxy Auto Discovery
API Proxy Auto DiscoveryVince Soliza
 
Zen and the Art of REST API documentation - MuCon London 2015
Zen and the Art of REST API documentation - MuCon London 2015Zen and the Art of REST API documentation - MuCon London 2015
Zen and the Art of REST API documentation - MuCon London 2015Steve Judd
 
2022 APIsecure_Securing APIs with Open Standards
2022 APIsecure_Securing APIs with Open Standards2022 APIsecure_Securing APIs with Open Standards
2022 APIsecure_Securing APIs with Open StandardsAPIsecure_ Official
 
Backend as a Service
Backend as a ServiceBackend as a Service
Backend as a Serviceapiomat
 
2022 apidays LIVE Helsinki & North_Using OpenAPI to configure your API Gateway
2022 apidays LIVE Helsinki & North_Using OpenAPI to configure your API Gateway2022 apidays LIVE Helsinki & North_Using OpenAPI to configure your API Gateway
2022 apidays LIVE Helsinki & North_Using OpenAPI to configure your API Gatewayapidays
 
Spark Uber Development Kit
Spark Uber Development KitSpark Uber Development Kit
Spark Uber Development KitJen Aman
 
Use drupal 8 as a framework the romance recalibration
Use drupal 8 as a framework   the romance recalibrationUse drupal 8 as a framework   the romance recalibration
Use drupal 8 as a framework the romance recalibrationKevin Wenger
 
Building a REST API Microservice for the DevNet API Scavenger Hunt
Building a REST API Microservice for the DevNet API Scavenger HuntBuilding a REST API Microservice for the DevNet API Scavenger Hunt
Building a REST API Microservice for the DevNet API Scavenger HuntAshley Roach
 
Selenium 2 - PyCon 2011
Selenium 2 - PyCon 2011Selenium 2 - PyCon 2011
Selenium 2 - PyCon 2011hugs
 
we45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with Pythonwe45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with PythonAbhay Bhargav
 

Similar to Building robust REST APIs (20)

Developing Brilliant and Powerful APIs in Ruby & Python
Developing Brilliant and Powerful APIs in Ruby & PythonDeveloping Brilliant and Powerful APIs in Ruby & Python
Developing Brilliant and Powerful APIs in Ruby & Python
 
Panoramic view of web APIs
Panoramic view of web APIsPanoramic view of web APIs
Panoramic view of web APIs
 
Apidays New York 2024 - API Discovery - From Crawl to Run by Rob Dickinson, G...
Apidays New York 2024 - API Discovery - From Crawl to Run by Rob Dickinson, G...Apidays New York 2024 - API Discovery - From Crawl to Run by Rob Dickinson, G...
Apidays New York 2024 - API Discovery - From Crawl to Run by Rob Dickinson, G...
 
API Discovery from Crawl to Run - Rob Dickinson, Graylog
API Discovery from Crawl to Run - Rob Dickinson, GraylogAPI Discovery from Crawl to Run - Rob Dickinson, Graylog
API Discovery from Crawl to Run - Rob Dickinson, Graylog
 
Building Better Web APIs with Rails
Building Better Web APIs with RailsBuilding Better Web APIs with Rails
Building Better Web APIs with Rails
 
SXSW 2012 JavaScript MythBusters
SXSW 2012 JavaScript MythBustersSXSW 2012 JavaScript MythBusters
SXSW 2012 JavaScript MythBusters
 
Silent web app testing by example - BerlinSides 2011
Silent web app testing by example - BerlinSides 2011Silent web app testing by example - BerlinSides 2011
Silent web app testing by example - BerlinSides 2011
 
API Proxy Auto Discovery
API Proxy Auto DiscoveryAPI Proxy Auto Discovery
API Proxy Auto Discovery
 
Zen and the Art of REST API documentation - MuCon London 2015
Zen and the Art of REST API documentation - MuCon London 2015Zen and the Art of REST API documentation - MuCon London 2015
Zen and the Art of REST API documentation - MuCon London 2015
 
2022 APIsecure_Securing APIs with Open Standards
2022 APIsecure_Securing APIs with Open Standards2022 APIsecure_Securing APIs with Open Standards
2022 APIsecure_Securing APIs with Open Standards
 
SCIO : Apache Beam API
SCIO : Apache Beam APISCIO : Apache Beam API
SCIO : Apache Beam API
 
Backend as a Service
Backend as a ServiceBackend as a Service
Backend as a Service
 
2022 apidays LIVE Helsinki & North_Using OpenAPI to configure your API Gateway
2022 apidays LIVE Helsinki & North_Using OpenAPI to configure your API Gateway2022 apidays LIVE Helsinki & North_Using OpenAPI to configure your API Gateway
2022 apidays LIVE Helsinki & North_Using OpenAPI to configure your API Gateway
 
Spark Uber Development Kit
Spark Uber Development KitSpark Uber Development Kit
Spark Uber Development Kit
 
Use drupal 8 as a framework the romance recalibration
Use drupal 8 as a framework   the romance recalibrationUse drupal 8 as a framework   the romance recalibration
Use drupal 8 as a framework the romance recalibration
 
Building a REST API Microservice for the DevNet API Scavenger Hunt
Building a REST API Microservice for the DevNet API Scavenger HuntBuilding a REST API Microservice for the DevNet API Scavenger Hunt
Building a REST API Microservice for the DevNet API Scavenger Hunt
 
Plack at OSCON 2010
Plack at OSCON 2010Plack at OSCON 2010
Plack at OSCON 2010
 
Selenium 2 - PyCon 2011
Selenium 2 - PyCon 2011Selenium 2 - PyCon 2011
Selenium 2 - PyCon 2011
 
PSGI/Plack OSDC.TW
PSGI/Plack OSDC.TWPSGI/Plack OSDC.TW
PSGI/Plack OSDC.TW
 
we45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with Pythonwe45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with Python
 

More from Nejc Zupan

Don't Rely On Discipline
Don't Rely On DisciplineDon't Rely On Discipline
Don't Rely On DisciplineNejc Zupan
 
Don't rely on discipline
Don't rely on disciplineDon't rely on discipline
Don't rely on disciplineNejc Zupan
 
Beyond 100% test coverage
Beyond 100% test coverageBeyond 100% test coverage
Beyond 100% test coverageNejc Zupan
 
Pipenv: Python Dev Workflow for Humans
Pipenv: Python Dev Workflow for HumansPipenv: Python Dev Workflow for Humans
Pipenv: Python Dev Workflow for HumansNejc Zupan
 
State of the art image recognition in 7 lines of Python
State of the art image recognition in 7 lines of PythonState of the art image recognition in 7 lines of Python
State of the art image recognition in 7 lines of PythonNejc Zupan
 
State Of The Art Image Recognition In 7 Lines Of Python
State Of The Art Image Recognition In 7 Lines Of PythonState Of The Art Image Recognition In 7 Lines Of Python
State Of The Art Image Recognition In 7 Lines Of PythonNejc Zupan
 
Bootstrapping Your Python Career
Bootstrapping Your Python CareerBootstrapping Your Python Career
Bootstrapping Your Python CareerNejc Zupan
 
Turbo boosting your python development
Turbo boosting your python developmentTurbo boosting your python development
Turbo boosting your python developmentNejc Zupan
 
Travis CI: Fun and easy CI for your Plone packages
Travis CI: Fun and easy CI for your Plone packagesTravis CI: Fun and easy CI for your Plone packages
Travis CI: Fun and easy CI for your Plone packagesNejc Zupan
 

More from Nejc Zupan (10)

Don't Rely On Discipline
Don't Rely On DisciplineDon't Rely On Discipline
Don't Rely On Discipline
 
Don't rely on discipline
Don't rely on disciplineDon't rely on discipline
Don't rely on discipline
 
Beyond 100% test coverage
Beyond 100% test coverageBeyond 100% test coverage
Beyond 100% test coverage
 
Pipenv: Python Dev Workflow for Humans
Pipenv: Python Dev Workflow for HumansPipenv: Python Dev Workflow for Humans
Pipenv: Python Dev Workflow for Humans
 
State of the art image recognition in 7 lines of Python
State of the art image recognition in 7 lines of PythonState of the art image recognition in 7 lines of Python
State of the art image recognition in 7 lines of Python
 
State Of The Art Image Recognition In 7 Lines Of Python
State Of The Art Image Recognition In 7 Lines Of PythonState Of The Art Image Recognition In 7 Lines Of Python
State Of The Art Image Recognition In 7 Lines Of Python
 
Bootstrapping Your Python Career
Bootstrapping Your Python CareerBootstrapping Your Python Career
Bootstrapping Your Python Career
 
Turbo boosting your python development
Turbo boosting your python developmentTurbo boosting your python development
Turbo boosting your python development
 
Travis CI: Fun and easy CI for your Plone packages
Travis CI: Fun and easy CI for your Plone packagesTravis CI: Fun and easy CI for your Plone packages
Travis CI: Fun and easy CI for your Plone packages
 
Plone api
Plone apiPlone api
Plone api
 

Recently uploaded

AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAlluxio, Inc.
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageGlobus
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessWSO2
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfkalichargn70th171
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsGlobus
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?XfilesPro
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfOrtus Solutions, Corp
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobus
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Globus
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAlluxio, Inc.
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesKrzysztofKkol1
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfGlobus
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfkalichargn70th171
 

Recently uploaded (20)

AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 

Building robust REST APIs

Editor's Notes

  1. This talk is about building Robust APIs with Python.
  2. We’re gonna look at what drives me to spend so much time and energy on designing and building robust APIs. What Robust APIs even are And how you can do them as well
  3. It all started back when I was in college and Niteo was a young consulting agency. I read about a famous slovenian businessman, how he spends half a year in Slovenia, working, and the remaining half a year kitesurfing in Brasil. One day, I thought to myself, one day … I couldn’t get that thought out of my head for months. Then I came to a realization: There is not really anything preventing me to do it! We have international clients in Niteo, they don’t care where I am located as long as work gets done!
  4. And so I did. I spent my first winter in Spain. Sorry, I meant Catalonia :) It was a total blast, spending my mornings working from a sailing club in Barcelona and afternoons on the water. When it was time to go home I was convinced I need to do this again.
  5. And sure enough, when it got properly depressing in the coming winter, as it does in our part of Europe (I don’t mind cold and snow, but I hate it when it’s cloudy, foggy and slush instead of snow), well I packed up my car and headed South.
  6. This time to Valencia.
  7. And I have been escaping winter ever since. You know what sucks though? You come to the beach, the waves are pumping, the wind is howling, and then THIS
  8. Getting called in because we have a production issue: One of our VIP customers is claiming that our API suddenly started returning different results. Or the app is crashing because the view code is trying to process invalid data. AARGHHH This is my WHY. I hate “stupid” bugs. Preventable bugs. Sure, some bugs will happen, nothing is perfect. But I hate it when they are of the kind that is totally preventable. This is why I want to build Robust APIs.
  9. Now you know WHY. So people don’t break your schedule.
  10. My first proper dive into the world of APIs was 7 years ago, on a PloneKonferenz. We started the “plone.api” project during the after-conference sprints. I got to experience first-hand everything that is hard about designing APIs.
  11. The plone.api project started because back then, Plone was already 10 years old working with Plone required memorizing a buuuunch of boilerplate code. For example,
  12. What we did, essentially, is survey a bunch of Plone code and identified 20% the tasks that people did 80% of the time. Then we put them down on a piece of paper and asked ourselves how would it make the most sense to name them. We wanted the API to be easy to remember, and easy to guess.
  13. Then we wrote documentation on how people will use the API. By writing the docs we really polished the naming of API methods. It might sound trivial, but naming things is one of the hardest things in programming. Especially when designing APIs, it’s really hard to change your API once you have users, without causing pain and suffering among your users. BTW: these snippets were (and still are) tests. These bits of code are being run on every commit and asserted that they do what they claim. Fantastic for preventing regressions in a project with a great number of contributors.
  14. the API can’t change without also changing the docs over 60 contributors, people have given talks about it nowadays ships with Plone by default I haven’t touched it in years, completely taken over by the community
  15. It turns out, if you’re building RESTful webservices API these days, you don’t have to look far. Use Swagger.
  16. The defacto tool for describing and documenting REST APIs is Swagger. It’s a YAML specification for your API, that generates into nice HTML documentation with an integrated test client. And the ecosystem around it built a number of tools such as client generation tools. I.e. you can generate a React client for your API, no need to manually write API connectors.
  17. Actually, Swagger was recently renamed to OpenAPI. If you are used to Swagger, from now on when I say OpenAPI, you translater to Swagger in your heads :)
  18. Swagger/OpenAPI has been in in refinement for almost a decade so it’s pretty solid and not something that’s just fashionable this month.
  19. Now you know What makes an API robust: automatically up-to-date documentation signature that does not change without intent
  20. Last summer we started working on our new project WooCart. It’s a complete-autopilot hosting for webshops built on Wordpress and WooCommerce. I was in charge of building the API that will glue together the client-facing control panel built in React (first time!) and the deployment machinery on Kubernetes. I.e. when a client wants to create a new store, they click a button, wait about a minute, and see the new store in their WooCart Control Panel. I knew I want to use OpenAPI specification to declare how the API will work and to have runnable documentation. So I went to swagger’s website to check what Python integration are available. And found this:
  21. Ugh. Almost like looking for a JavaScript packages. A bunch of overlapping packages, hard to decide which to choose.
  22. But not really. I was quite sure I want to use Pyramid. I want to build a robust API, remember? So I can go surfing? Yes, and Pyramid is a really mature web framework. It allows me to start small, even in a single file, and scale easily from there. Moreover, the people that rewrote and launched the new PyPI.org last year, used Pyramid to do it. They are one of the most knowledgeable people in our community, and if Pyramid is their choice, it’s probably a good choice for me too. Still, six packages.
  23. Growing up, I was a huge fan of Mythbusters. I loved watching Adam and Jamie bust one myth after the other. I consider myself a tinkerer and a maker, just dying to find time to do some DIY projects. You can imagine my joy when Adam’s first book came out recently: Every Tool’s A Hammer. Sort of an autobiography, mixed with a collection of tips on how to be a maker, how to be creative. One of the main chapters of the book is called “Use More Cooling Liquid”. It’s also an answer to “what would you tell to 25 year old self“ that Adam gave during a recent interview. Use More Cooling Liquid. Such a strange advice, isn’t it? Use More Cooling Liquid. Why would Adam tell his 25-year-old self that? It’s not about the act of cutting or drilling, it’s about preparation. About using the right tools for the job and not risking damaging the tool or the piece. Of cutting in the right place, at correct dimension. I realized that advice (next slide) applies to my use case as well.
  24. next slide
  25. There are two distinct approaches to doing OpenAPI with web frameworks.
  26. 2. -> code reviews are MUCH easier -> if openapi.yaml did not change, API did not change
  27. 3. NEXT SLIDE
  28. basically the same problem, but if you are generating openapi spec from code you need to monkeypatch or fork the framework to wrestle it to produce the api spec that you want with validation, you make a big # TODO: fix this upstream, and write your own validation in your view code, and move on
  29. 4. In WooCart we had to rewrite some of our endpoints in GoLang to get better performance & concurrency. If we would generate openapi spec with python code we would have to keep “dead” python code around, just to generate and server the spec that we need.
  30. Going back to list of python integrations for swagger, and removing those that are not written in API-first approach I get …
  31. … these five, three done on top of flask and two done on top of pyramid and since I prefer Pyramid, I’m down to two
  32. One with documentation in Japanese, the other only supporting the old Swagger 2.0, not OpenAPIv3 spec.
  33. So I was only left with one solution
  34. Slide text Use as a scaffold!
  35. And remember: Use More Cooling Liquid!