/chinook_fastapi

REST API built with FastAPI on top of mock-up JSON dataset

Primary LanguagePythonMIT LicenseMIT

FastAPI demo project

Travis PyUp MIT License Code Style LinkedIn


Logo

FastAPI Demo

REST API built with FastAPI on top of mock-up JSON dataset

Report Bug · Request Feature

Features

  • allows some basic requests to a mock database (JSON)
  • verifies input and output using FastAPI.

Installation

# Create a virtual Environment
virtualenv -p $(which python3.7) venv
source venv/bin/activate
# Install packages
$ make install
...
Finished processing dependencies for chinook-fastapi
# Serve the API
$ make serve-api
cd chinook_fastapi && uvicorn api:app --reload
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [...] using statreload
INFO:     Started server process [...]
INFO:     Waiting for application startup.
INFO:     Application startup complete.

Usage

Using a browser (or you favorite API client, I use Insomnia), go to localhost:8000/docs to see the available API methods.

e.g:

curl --request GET \
  --url http://localhost:8000/users/4 \
  --header 'content-type: application/json'

would return

{
  "first_name": "Willard",
  "last_name": "Valek",
  "email": "wvalek3@vk.com",
  "gender": "Male",
  "ip_address": "67.76.188.26"
}

TODO

  • deploy API somewhere
  • deploy docs

Contact

Sander van Dorsten sandervandorsten@gmail.com


This package was created with Cookiecutter and the audrey/cookiecutter-pypackage project template.