SlideShare a Scribd company logo
1 of 34
Download to read offline
API-First Design
and Django
The tale of caring for your fellow developer
Olá! 🇧🇷
I am Klaus Laube
In ❤ with Django since version 0.96
Back-end developer at Son of a Tailor
klauslaube.com.br
github.com/kplaube
What’s an API again?
“(...) a set of dedicated URLs that return pure
data responses — meaning the responses
won’t contain the kind of presentational
overhead that you would expect in a
graphical user interface like a website.
Petr Gazarov
https://www.freecodecamp.org/news/what-is-an-api-in-english-please-b880a3214a82/
Let's build a
product! 🚀
The Code-First approach
Install Django
It’s not up to decision
picking a different
framework ❤
The Code-First approach
Install Django
It’s not up to decision
picking a different
framework ❤
Design the
database
Come up with
diagrams, define the
indexes, describe
relationships 💾
The Code-First approach
Install Django
It’s not up to decision
picking a different
framework ❤
Design the
database
Come up with
diagrams, define the
indexes, describe
relationships 💾
Write the code
Organize the packages,
do some TDD, write the
models, the views,
perhaps some API 👨‍💻
The Code-First approach
Install Django
It’s not up to decision
picking a different
framework ❤
Design the
database
Come up with
diagrams, define the
indexes, describe
relationships 💾
Write the code
Organize the packages,
do some TDD, write the
models, the views,
perhaps some API 👨‍💻
Deploy &
release
Deal with CI, CD, PaaS,
provisioning,
monitoring, caching,
etc 🖥
The Code-First approach
Install Django
It’s not up to decision
picking a different
framework ❤
Design the
database
Come up with
diagrams, define the
indexes, describe
relationships 💾
Write the code
Organize the packages,
do some TDD, write the
models, the views,
perhaps some API 👨‍💻
Expose
Let other stakeholders
know about your
release 🎉
☝
Here is where we’ll
start to integrate with
other developers
Deploy &
release
Deal with CI, CD, PaaS,
provisioning,
monitoring, caching,
etc 🖥
“Today Django is arguably used more often as
just a back-end API rather than a full
monolithic website solution at large
companies!
William S. Vincent
Django for APIs
What’s API-First?
“(...) the first, most waterfall aspect of
application development is the design of the
API’s.
Casey Lutz
https://medium.com/trimble-maps-engineering-blog/api-first-development-and-openapi-83
5afb46b7f1
3 principles of
API-First Design
#1
Your API is the first user interface of your application
#2
Your API comes first, then the implementation
#3
Your API is described (and maybe even self-descriptive)
It’s about caring for other
developers! 👨‍💻 👩‍💻
How can we do
that with
Django? 🤔
Design the API
Understand the
requirements, know your
stakeholders, set standards,
start defining behaviours.
API Blueprint example 👉
20
Validate
Get stakeholders involved,
think about use cases,
validate ideas through mock
servers, and get an
agreement.
Or you can use Prism:
https://stoplight.io/open-source/pris
m/
21
Test! Test! Test!
https://dredd.org
Implement
It’s time for some coding.
And it’s not just you! With a
solid contract your
stakeholders can start the
development as well.
Django REST Framework example 👉
23
What about {over,under}-fetching?
https://github.com/rsinger86/drf-flex-fields
Or consider
GraphQL 🤷‍♂
It’s official!
It’s time to turn the
agreement into a
specification.
rest_framework (with
uritemplate and pyyaml) is
enough to do this job.
26
$ python manage.py generateschema >
openapi-schema.yml
How to deal with changes?
▷ Path: mytodoapp.com/v1/tasks
▷ Querystring: mytodoapp.com/tasks?version=1.0
▷ Host: v1.mytodoapp.com/tasks
▷ Accept header: Accept: application/json; version=1.0
▷ Custom header: X-API-VERSION
▷ No versioning at all 🙃
https://www.django-rest-framework.org/api-guide/versioning/
Release
Turn the specification public.
Publish the API
documentation. drf-yasg is
your sidekick here.
Engage
Promote your API, start
monitoring, collect feedback,
and learn from your mistakes
and successes.
29
Repeat ♻
Further readings:
API-First Processes
and Tools
bit.ly/api-first-article
31
Further readings:
How To Design
Great APIs With
API-First Design
bit.ly/3hQYw7d
32
Further readings:
Django for APIs
leanpub.com/djangoforapis
33
Tak! 🇩🇰
You can find me at:
klauslaube.com.br
github.com/kplaube
Django Forum: kplaube

More Related Content

What's hot

Coca-Cola's social media in public relations
Coca-Cola's social media in public relations Coca-Cola's social media in public relations
Coca-Cola's social media in public relations
ehenry1990
 
fabcr22_apresentação_Para além das fronteiras: captação internacional indepen...
fabcr22_apresentação_Para além das fronteiras: captação internacional indepen...fabcr22_apresentação_Para além das fronteiras: captação internacional indepen...
fabcr22_apresentação_Para além das fronteiras: captação internacional indepen...
ABCR
 

What's hot (12)

Branding Overview
Branding OverviewBranding Overview
Branding Overview
 
Valve Corp. - Success with DotA2
Valve Corp. - Success with DotA2Valve Corp. - Success with DotA2
Valve Corp. - Success with DotA2
 
Coca-Cola's social media in public relations
Coca-Cola's social media in public relations Coca-Cola's social media in public relations
Coca-Cola's social media in public relations
 
Mergers and acquisitions
Mergers and acquisitionsMergers and acquisitions
Mergers and acquisitions
 
Brand Audit Netflix.pdf
Brand Audit Netflix.pdfBrand Audit Netflix.pdf
Brand Audit Netflix.pdf
 
fabcr22_apresentação_Descomplicando a Institucionalização da Captação de Recu...
fabcr22_apresentação_Descomplicando a Institucionalização da Captação de Recu...fabcr22_apresentação_Descomplicando a Institucionalização da Captação de Recu...
fabcr22_apresentação_Descomplicando a Institucionalização da Captação de Recu...
 
Marketing Strategy on Entertainment Channels
Marketing Strategy on Entertainment ChannelsMarketing Strategy on Entertainment Channels
Marketing Strategy on Entertainment Channels
 
fabcr22_apresentação_Para além das fronteiras: captação internacional indepen...
fabcr22_apresentação_Para além das fronteiras: captação internacional indepen...fabcr22_apresentação_Para além das fronteiras: captação internacional indepen...
fabcr22_apresentação_Para além das fronteiras: captação internacional indepen...
 
Research in Public Relations
Research in Public RelationsResearch in Public Relations
Research in Public Relations
 
Netflix Valuation
Netflix ValuationNetflix Valuation
Netflix Valuation
 
Análise de MKT de Guerrilha e Advertainment no Case Brastemp - Sorrisos
Análise de MKT de Guerrilha e Advertainment no Case Brastemp - SorrisosAnálise de MKT de Guerrilha e Advertainment no Case Brastemp - Sorrisos
Análise de MKT de Guerrilha e Advertainment no Case Brastemp - Sorrisos
 
Who strategic communication framework
Who strategic communication frameworkWho strategic communication framework
Who strategic communication framework
 

Similar to API-First Design and Django

Similar to API-First Design and Django (20)

Rest apis with DRF
Rest apis with DRFRest apis with DRF
Rest apis with DRF
 
Content Strategy and Developer Engagement for DevPortals
Content Strategy and Developer Engagement for DevPortalsContent Strategy and Developer Engagement for DevPortals
Content Strategy and Developer Engagement for DevPortals
 
Django Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersDjango Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python Developers
 
Space Camp June 2022 - API First.pdf
Space Camp June 2022 - API First.pdfSpace Camp June 2022 - API First.pdf
Space Camp June 2022 - API First.pdf
 
Concepts and applications of Django.pptx
Concepts and applications of Django.pptxConcepts and applications of Django.pptx
Concepts and applications of Django.pptx
 
Django in the Real World
Django in the Real WorldDjango in the Real World
Django in the Real World
 
Web API Design: Crafting Interfaces that Developers Love
Web API Design:  Crafting Interfaces that Developers LoveWeb API Design:  Crafting Interfaces that Developers Love
Web API Design: Crafting Interfaces that Developers Love
 
Web API Design
Web API DesignWeb API Design
Web API Design
 
APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...
APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...
APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...
 
General Terminologies to understand programming and Data Science
General Terminologies to understand programming and Data ScienceGeneral Terminologies to understand programming and Data Science
General Terminologies to understand programming and Data Science
 
Dev Learn Handout - Session 604
Dev Learn Handout - Session 604Dev Learn Handout - Session 604
Dev Learn Handout - Session 604
 
Learn Django Tips, Tricks & Techniques for Developers
Learn Django Tips, Tricks & Techniques for DevelopersLearn Django Tips, Tricks & Techniques for Developers
Learn Django Tips, Tricks & Techniques for Developers
 
Lunch and learn as3_frameworks
Lunch and learn as3_frameworksLunch and learn as3_frameworks
Lunch and learn as3_frameworks
 
Why your APIs should fly first class
Why your APIs should fly first classWhy your APIs should fly first class
Why your APIs should fly first class
 
What Web Framework To Use?
What Web Framework To Use?What Web Framework To Use?
What Web Framework To Use?
 
Getting Started With Django
Getting Started With DjangoGetting Started With Django
Getting Started With Django
 
Gapand 2017 - Diseñando Arquitecturas Serverless en Azure
Gapand 2017 - Diseñando Arquitecturas Serverless en AzureGapand 2017 - Diseñando Arquitecturas Serverless en Azure
Gapand 2017 - Diseñando Arquitecturas Serverless en Azure
 
Top 10 web development tools in 2022
Top 10 web development tools in 2022Top 10 web development tools in 2022
Top 10 web development tools in 2022
 
Web Development in Django
Web Development in DjangoWeb Development in Django
Web Development in Django
 
10 Best Web Development Frameworks for Your Business Needs
10 Best Web Development Frameworks for Your Business Needs10 Best Web Development Frameworks for Your Business Needs
10 Best Web Development Frameworks for Your Business Needs
 

Recently uploaded

一比一原版布兰迪斯大学毕业证如何办理
一比一原版布兰迪斯大学毕业证如何办理一比一原版布兰迪斯大学毕业证如何办理
一比一原版布兰迪斯大学毕业证如何办理
A
 
一比一原版英国萨赛克斯大学毕业证如何办理
一比一原版英国萨赛克斯大学毕业证如何办理一比一原版英国萨赛克斯大学毕业证如何办理
一比一原版英国萨赛克斯大学毕业证如何办理
SDSA
 
一比一定制加州大学欧文分校毕业证学位证书
一比一定制加州大学欧文分校毕业证学位证书一比一定制加州大学欧文分校毕业证学位证书
一比一定制加州大学欧文分校毕业证学位证书
A
 
一比一原版(PSU毕业证书)美国宾州州立大学毕业证如何办理
一比一原版(PSU毕业证书)美国宾州州立大学毕业证如何办理一比一原版(PSU毕业证书)美国宾州州立大学毕业证如何办理
一比一原版(PSU毕业证书)美国宾州州立大学毕业证如何办理
Fir
 
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
Fi
 
一比一原版(Bath毕业证书)英国桑德兰大学毕业证如何办理
一比一原版(Bath毕业证书)英国桑德兰大学毕业证如何办理一比一原版(Bath毕业证书)英国桑德兰大学毕业证如何办理
一比一原版(Bath毕业证书)英国桑德兰大学毕业证如何办理
B
 
一比一定制(Temasek毕业证书)新加坡淡马锡理工学院毕业证学位证书
一比一定制(Temasek毕业证书)新加坡淡马锡理工学院毕业证学位证书一比一定制(Temasek毕业证书)新加坡淡马锡理工学院毕业证学位证书
一比一定制(Temasek毕业证书)新加坡淡马锡理工学院毕业证学位证书
B
 
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
Fi
 
一比一定制(USC毕业证书)美国南加州大学毕业证学位证书
一比一定制(USC毕业证书)美国南加州大学毕业证学位证书一比一定制(USC毕业证书)美国南加州大学毕业证学位证书
一比一定制(USC毕业证书)美国南加州大学毕业证学位证书
Fir
 
原版定制(爱大毕业证书)英国爱丁堡大学毕业证原件一模一样
原版定制(爱大毕业证书)英国爱丁堡大学毕业证原件一模一样原版定制(爱大毕业证书)英国爱丁堡大学毕业证原件一模一样
原版定制(爱大毕业证书)英国爱丁堡大学毕业证原件一模一样
gfhdsfr
 
一比一原版(Cranfield毕业证书)英国克兰菲尔德大学毕业证如何办理
一比一原版(Cranfield毕业证书)英国克兰菲尔德大学毕业证如何办理一比一原版(Cranfield毕业证书)英国克兰菲尔德大学毕业证如何办理
一比一原版(Cranfield毕业证书)英国克兰菲尔德大学毕业证如何办理
gfhdsfr
 

Recently uploaded (20)

一比一原版布兰迪斯大学毕业证如何办理
一比一原版布兰迪斯大学毕业证如何办理一比一原版布兰迪斯大学毕业证如何办理
一比一原版布兰迪斯大学毕业证如何办理
 
Free on Wednesdays T Shirts Free on Wednesdays Sweatshirts
Free on Wednesdays T Shirts Free on Wednesdays SweatshirtsFree on Wednesdays T Shirts Free on Wednesdays Sweatshirts
Free on Wednesdays T Shirts Free on Wednesdays Sweatshirts
 
一比一原版英国萨赛克斯大学毕业证如何办理
一比一原版英国萨赛克斯大学毕业证如何办理一比一原版英国萨赛克斯大学毕业证如何办理
一比一原版英国萨赛克斯大学毕业证如何办理
 
AI Generated 3D Models | AI 3D Model Generator
AI Generated 3D Models | AI 3D Model GeneratorAI Generated 3D Models | AI 3D Model Generator
AI Generated 3D Models | AI 3D Model Generator
 
Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...
Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...
Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...
 
一比一定制加州大学欧文分校毕业证学位证书
一比一定制加州大学欧文分校毕业证学位证书一比一定制加州大学欧文分校毕业证学位证书
一比一定制加州大学欧文分校毕业证学位证书
 
iThome_CYBERSEC2024_Drive_Into_the_DarkWeb
iThome_CYBERSEC2024_Drive_Into_the_DarkWebiThome_CYBERSEC2024_Drive_Into_the_DarkWeb
iThome_CYBERSEC2024_Drive_Into_the_DarkWeb
 
一比一原版(PSU毕业证书)美国宾州州立大学毕业证如何办理
一比一原版(PSU毕业证书)美国宾州州立大学毕业证如何办理一比一原版(PSU毕业证书)美国宾州州立大学毕业证如何办理
一比一原版(PSU毕业证书)美国宾州州立大学毕业证如何办理
 
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
 
一比一原版(Bath毕业证书)英国桑德兰大学毕业证如何办理
一比一原版(Bath毕业证书)英国桑德兰大学毕业证如何办理一比一原版(Bath毕业证书)英国桑德兰大学毕业证如何办理
一比一原版(Bath毕业证书)英国桑德兰大学毕业证如何办理
 
一比一定制(Temasek毕业证书)新加坡淡马锡理工学院毕业证学位证书
一比一定制(Temasek毕业证书)新加坡淡马锡理工学院毕业证学位证书一比一定制(Temasek毕业证书)新加坡淡马锡理工学院毕业证学位证书
一比一定制(Temasek毕业证书)新加坡淡马锡理工学院毕业证学位证书
 
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
 
🍑👄Dehradun Esℂorts Serviℂe☎️9315791090🍑👄 ℂall Girl serviℂe in ☎️Dehradun ℂall...
🍑👄Dehradun Esℂorts Serviℂe☎️9315791090🍑👄 ℂall Girl serviℂe in ☎️Dehradun ℂall...🍑👄Dehradun Esℂorts Serviℂe☎️9315791090🍑👄 ℂall Girl serviℂe in ☎️Dehradun ℂall...
🍑👄Dehradun Esℂorts Serviℂe☎️9315791090🍑👄 ℂall Girl serviℂe in ☎️Dehradun ℂall...
 
一比一定制(USC毕业证书)美国南加州大学毕业证学位证书
一比一定制(USC毕业证书)美国南加州大学毕业证学位证书一比一定制(USC毕业证书)美国南加州大学毕业证学位证书
一比一定制(USC毕业证书)美国南加州大学毕业证学位证书
 
原版定制(爱大毕业证书)英国爱丁堡大学毕业证原件一模一样
原版定制(爱大毕业证书)英国爱丁堡大学毕业证原件一模一样原版定制(爱大毕业证书)英国爱丁堡大学毕业证原件一模一样
原版定制(爱大毕业证书)英国爱丁堡大学毕业证原件一模一样
 
Premier Mobile App Development Agency in USA.pdf
Premier Mobile App Development Agency in USA.pdfPremier Mobile App Development Agency in USA.pdf
Premier Mobile App Development Agency in USA.pdf
 
一比一原版(Cranfield毕业证书)英国克兰菲尔德大学毕业证如何办理
一比一原版(Cranfield毕业证书)英国克兰菲尔德大学毕业证如何办理一比一原版(Cranfield毕业证书)英国克兰菲尔德大学毕业证如何办理
一比一原版(Cranfield毕业证书)英国克兰菲尔德大学毕业证如何办理
 
TORTOGEL TELAH MENJADI SALAH SATU PLATFORM PERMAINAN PALING FAVORIT.
TORTOGEL TELAH MENJADI SALAH SATU PLATFORM PERMAINAN PALING FAVORIT.TORTOGEL TELAH MENJADI SALAH SATU PLATFORM PERMAINAN PALING FAVORIT.
TORTOGEL TELAH MENJADI SALAH SATU PLATFORM PERMAINAN PALING FAVORIT.
 
Development Lifecycle.pptx for the secure development of apps
Development Lifecycle.pptx for the secure development of appsDevelopment Lifecycle.pptx for the secure development of apps
Development Lifecycle.pptx for the secure development of apps
 
GOOGLE Io 2024 At takes center stage.pdf
GOOGLE Io 2024 At takes center stage.pdfGOOGLE Io 2024 At takes center stage.pdf
GOOGLE Io 2024 At takes center stage.pdf
 

API-First Design and Django

  • 1. API-First Design and Django The tale of caring for your fellow developer
  • 2. Olá! 🇧🇷 I am Klaus Laube In ❤ with Django since version 0.96 Back-end developer at Son of a Tailor klauslaube.com.br github.com/kplaube
  • 4. “(...) a set of dedicated URLs that return pure data responses — meaning the responses won’t contain the kind of presentational overhead that you would expect in a graphical user interface like a website. Petr Gazarov https://www.freecodecamp.org/news/what-is-an-api-in-english-please-b880a3214a82/
  • 6. The Code-First approach Install Django It’s not up to decision picking a different framework ❤
  • 7. The Code-First approach Install Django It’s not up to decision picking a different framework ❤ Design the database Come up with diagrams, define the indexes, describe relationships 💾
  • 8. The Code-First approach Install Django It’s not up to decision picking a different framework ❤ Design the database Come up with diagrams, define the indexes, describe relationships 💾 Write the code Organize the packages, do some TDD, write the models, the views, perhaps some API 👨‍💻
  • 9. The Code-First approach Install Django It’s not up to decision picking a different framework ❤ Design the database Come up with diagrams, define the indexes, describe relationships 💾 Write the code Organize the packages, do some TDD, write the models, the views, perhaps some API 👨‍💻 Deploy & release Deal with CI, CD, PaaS, provisioning, monitoring, caching, etc 🖥
  • 10. The Code-First approach Install Django It’s not up to decision picking a different framework ❤ Design the database Come up with diagrams, define the indexes, describe relationships 💾 Write the code Organize the packages, do some TDD, write the models, the views, perhaps some API 👨‍💻 Expose Let other stakeholders know about your release 🎉 ☝ Here is where we’ll start to integrate with other developers Deploy & release Deal with CI, CD, PaaS, provisioning, monitoring, caching, etc 🖥
  • 11. “Today Django is arguably used more often as just a back-end API rather than a full monolithic website solution at large companies! William S. Vincent Django for APIs
  • 13. “(...) the first, most waterfall aspect of application development is the design of the API’s. Casey Lutz https://medium.com/trimble-maps-engineering-blog/api-first-development-and-openapi-83 5afb46b7f1
  • 15. #1 Your API is the first user interface of your application
  • 16. #2 Your API comes first, then the implementation
  • 17. #3 Your API is described (and maybe even self-descriptive)
  • 18. It’s about caring for other developers! 👨‍💻 👩‍💻
  • 19. How can we do that with Django? 🤔
  • 20. Design the API Understand the requirements, know your stakeholders, set standards, start defining behaviours. API Blueprint example 👉 20
  • 21. Validate Get stakeholders involved, think about use cases, validate ideas through mock servers, and get an agreement. Or you can use Prism: https://stoplight.io/open-source/pris m/ 21
  • 23. Implement It’s time for some coding. And it’s not just you! With a solid contract your stakeholders can start the development as well. Django REST Framework example 👉 23
  • 26. It’s official! It’s time to turn the agreement into a specification. rest_framework (with uritemplate and pyyaml) is enough to do this job. 26 $ python manage.py generateschema > openapi-schema.yml
  • 27. How to deal with changes? ▷ Path: mytodoapp.com/v1/tasks ▷ Querystring: mytodoapp.com/tasks?version=1.0 ▷ Host: v1.mytodoapp.com/tasks ▷ Accept header: Accept: application/json; version=1.0 ▷ Custom header: X-API-VERSION ▷ No versioning at all 🙃 https://www.django-rest-framework.org/api-guide/versioning/
  • 28. Release Turn the specification public. Publish the API documentation. drf-yasg is your sidekick here.
  • 29. Engage Promote your API, start monitoring, collect feedback, and learn from your mistakes and successes. 29
  • 31. Further readings: API-First Processes and Tools bit.ly/api-first-article 31
  • 32. Further readings: How To Design Great APIs With API-First Design bit.ly/3hQYw7d 32
  • 33. Further readings: Django for APIs leanpub.com/djangoforapis 33
  • 34. Tak! 🇩🇰 You can find me at: klauslaube.com.br github.com/kplaube Django Forum: kplaube