Upgrade to Pro — share decks privately, control downloads, hide ads and more …

DevOpsPorto Meetup 38: Intro to FastAPI by Sebastián Ramírez

DevOpsPorto Meetup 38: Intro to FastAPI by Sebastián Ramírez

DevOpsPorto

August 06, 2020
Tweet

More Decks by DevOpsPorto

Other Decks in Technology

Transcript

  1. Intro to
    High performance, easy to learn,
    fast to code, ready for production

    View full-size slide

  2. Who am I?
    Sebastián Ramírez
    github.com/tiangolo
    linkedin.com/in/tiangolo
    twitter.com/tiangolo
    Dev at Explosion
    Berlin, Germany
    Explosion created:
    I created:
    tiangolo.com

    View full-size slide

  3. About FastAPI
    ● 19K GitHub stars (about 1K+ per month)
    ● Used by Microsoft, Uber, Netflix, etc.
    ● Performance in the top rank for Python
    @tiangolo

    View full-size slide

  4. Based on standards
    ● OpenAPI
    ● JSON Schema
    ● OAuth2
    ✨ Automatic API docs ✨
    @tiangolo

    View full-size slide

  5. Based on standards - for free
    @tiangolo

    View full-size slide

  6. Based on Python type hints
    ● Autocompletion everywhere
    ● Type checks and type errors
    @tiangolo

    View full-size slide

  7. Types provide autocompletion
    @tiangolo

    View full-size slide

  8. Easy and short
    @tiangolo

    View full-size slide

  9. Less API code
    @tiangolo

    View full-size slide

  10. Basic FastAPI app
    @tiangolo
    https://somedomain.com/items/5?q=some+query

    View full-size slide

  11. Basic FastAPI app - docs
    @tiangolo
    https://somedomain.com/docs

    View full-size slide

  12. Automatic docs
    @tiangolo

    View full-size slide

  13. Basic FastAPI app with body
    @tiangolo

    View full-size slide

  14. Basic FastAPI app with body - docs
    @tiangolo

    View full-size slide

  15. Basic FastAPI app with body - docs
    @tiangolo

    View full-size slide

  16. Basic FastAPI app with body
    @tiangolo

    View full-size slide

  17. Basic FastAPI app with body and query
    @tiangolo

    View full-size slide

  18. Basic FastAPI app with body and query - docs
    @tiangolo
    https://somedomain.com/food/?delivery=true

    View full-size slide

  19. Basic FastAPI app with body and query
    @tiangolo

    View full-size slide

  20. JSON array of objects in body
    @tiangolo

    View full-size slide

  21. JSON array of objects in body - docs
    @tiangolo

    View full-size slide

  22. JSON array of objects in body
    @tiangolo

    View full-size slide

  23. JSON array of objects in body - invalid data
    @tiangolo

    View full-size slide

  24. JSON array of objects in body - validation
    @tiangolo

    View full-size slide

  25. JSON array of objects in body - validation
    @tiangolo

    View full-size slide

  26. FastAPI auto-completion
    @tiangolo

    View full-size slide

  27. Type checks
    @tiangolo

    View full-size slide

  28. All based on standard Python types
    @tiangolo

    View full-size slide

  29. Metadata
    @tiangolo

    View full-size slide

  30. Metadata in docs
    @tiangolo

    View full-size slide

  31. Metadata in docs
    @tiangolo

    View full-size slide

  32. Required query
    @tiangolo

    View full-size slide

  33. Required query in docs
    @tiangolo

    View full-size slide

  34. Required query validation
    @tiangolo

    View full-size slide

  35. Required query in docs - valid
    @tiangolo
    https://somedomain.com/food/?quantity=2

    View full-size slide

  36. Required query in docs - response
    @tiangolo

    View full-size slide

  37. Required query in docs
    @tiangolo

    View full-size slide

  38. Validation
    @tiangolo

    View full-size slide

  39. Validation in docs
    @tiangolo

    View full-size slide

  40. Validation in docs - response
    @tiangolo

    View full-size slide

  41. Data validation
    @tiangolo

    View full-size slide

  42. FastAPI - Performance
    @tiangolo

    View full-size slide

  43. FastAPI - Performance
    @tiangolo

    View full-size slide

  44. FastAPI - Other features
    @tiangolo
    ● Dependency Injection
    ● Security - OAuth2
    ● WebSockets
    ● Files
    ● Background Tasks
    ● Easy GraphQL integration
    ● More...

    View full-size slide

  45. FastAPI - When not to
    @tiangolo
    ● Stable
    ● No new features
    ● Not an API

    View full-size slide

  46. Other tools
    @tiangolo
    Build great CLIs. Easy to code.
    Based on Python type hints.
    Functional deep learning with types,
    compatible with your favorite libraries.
    typer.tiangolo.com thinc.ai

    View full-size slide

  47. Thank you!
    Sebastián Ramírez github.com/tiangolo
    linkedin.com/in/tiangolo
    twitter.com/tiangolo
    tiangolo.com
    Questions?
    fastapi.tiangolo.com

    View full-size slide