Slide 1

Slide 1 text

FastAPI: Fast & Modern API Development Wallace Espindola Software Engineer & Architect

Slide 2

Slide 2 text

● What is FastAPI ● Advantages and disadvantages ● Where are the good things ● Being compact and simple ● Top technologies used ● What market says ● How to start ● Tricks and threats Schedule

Slide 3

Slide 3 text

Main learning takeaways 1) Discover FastAPI as technology for APIs; 2) Step-by-step on how to start, implement and run it; 3) Advantages and disadvantages; 4) Tips and tricks.

Slide 4

Slide 4 text

About me ● Brazilian from Rio de Janeiro ● 20+ years in IT career ● Living in Belgium since 2017 ● Profile: SW development & architecture ● Stack: Back-end / Java / Python / APIs / Web ● Speaks: English, Portuguese, French and basic Spanish ● Experience in many industries: Government, Oil&Gas, Banking, Telecom, Defense, Education, MedTech.

Slide 5

Slide 5 text

Introduction to FastAPI ● Modern framework built for quick & efficient API development ● Uses async/await for non-blocking I/O ● Auto-generated interactive docs (Swagger UI & ReDoc) ● Built on Starlette & Pydantic ● Born in Dec, 2018 ● License MIT

Slide 6

Slide 6 text

Key Components of FastAPI ● Pydantic: Data validation library that uses Python type hints for schema validation and serialization. ● Starlette: Lightweight ASGI framework enabling async functionality in Python. ● Uvicorn: Minimal ASGI server with a multi-process model for handling HTTP requests. ● OpenAPI Integration: Auto-generates interactive API docs (Swagger UI & ReDoc) for real-time endpoint exploration and testing.

Slide 7

Slide 7 text

FastAPI in Action – A Basic API Example ● Define endpoints with minimal code ● Use Pydantic for data models and validation ● May be run asynchronously ● Auto-documented APIs with /docs or /redoc ● Simple, compact and fast

Slide 8

Slide 8 text

Code Breakdown – What’s Happening? ● Route Definitions: ○ / : Welcome message, hello word! (isAlive endpoint) ○ /items/{item_id} : Handles path & query parameters ○ /items/ : POST endpoint with JSON body validation ● Key Benefits: ○ Reduced boilerplate code ○ Built-in error handling via data validation

Slide 9

Slide 9 text

Dependency Injection Reusable logic with dependency injection:

Slide 10

Slide 10 text

Background Tasks Run tasks in the background without delaying responses:

Slide 11

Slide 11 text

Getting Started Installation*: Run: Explore interactive docs at: *Creating a virtual environment is always recommended.

Slide 12

Slide 12 text

Why Choosing FastAPI? Benefits: • Clean, intuitive syntax • High performance & scalability • Built-in data validation • Ideal for microservices, ML APIs, & real-time apps

Slide 13

Slide 13 text

Why in Python? Top programming language, great ascension: Reference: https://www.tiobe.com/tiobe-index/

Slide 14

Slide 14 text

Why in Python? Top programming language, great ascension: Reference: https://github.blog/news-insights/octoverse/octoverse-2024/

Slide 15

Slide 15 text

Yes, demo time!

Slide 16

Slide 16 text

If something went wrong, we have a workaround ;)

Slide 17

Slide 17 text

If something went wrong, we have a workaround ;)

Slide 18

Slide 18 text

The auto documentation endpoints

Slide 19

Slide 19 text

References https://www.tiobe.com/tiobe-index/ https://github.blog/news-insights/octoverse/octoverse-2024/ https://fastapi.tiangolo.com/ https://github.com/fastapi/fastapi https://github.com/Redocly/redoc https://github.com/swagger-api/swagger-ui https://docs.pydantic.dev/latest/ https://github.com/pydantic/pydantic https://www.starlette.io/ https://www.python.org/ https://en.wikipedia.org/wiki/FastAPI

Slide 20

Slide 20 text

Questions, insights, ideas Q&A / Discussion

Slide 21

Slide 21 text

How to find me LinkedIn: https://www.linkedin.com/in/wallaceespindola/ GitHub: https://github.com/wallaceespindola E-mail: [email protected] Twitter: @wsespindola Gravatar: https://gravatar.com/wallacese Dev Community Articles: https://dev.to/wallaceespindola Articles DZone Articles: https://dzone.com/users/1254611/wallacese.html Pulse Articles: https://www.linkedin.com/in/wallaceespindola/recent-activity/articles/ My company: https://www.wtechitsolutions.com/ Slides: https://speakerdeck.com/wallacese Thank you!!!