Compare commits

..

8 commits

Author SHA1 Message Date
Yarne Coppens
80535cb27c Added expansion id property to BoardGame class 2024-07-25 22:07:14 +02:00
Yarne Coppens
f8cc27a037 Created basic BoardGame class 2024-07-25 22:01:25 +02:00
Yarne Coppens
4f3370efef Used response model 2024-07-25 19:38:20 +02:00
Yarne Coppens
85e9b18039 Gave the get_boardgame_by_id endpoint a Return Type 2024-07-25 18:02:37 +02:00
Yarne Coppens
64a335ac98 Fixed Pydantic class not inheriting from BaseModel 2024-07-25 18:01:51 +02:00
Yarne Coppens
57cebaaf02 Added API endpoint base for retrieving boardgame by ID 2024-07-25 17:53:59 +02:00
Yarne Coppens
b90aaad637 Started base boardgame class 2024-07-25 17:27:27 +02:00
Yarne Coppens
4e4fb04b88 Created base for fastapi 2024-07-24 22:53:56 +02:00
3 changed files with 39 additions and 2 deletions

View file

@ -1,4 +1,2 @@
# bgg_api # bgg_api
An API implementation that will be used by my own board game website.
The plan is for this API to be used by a single person who wants their board game collection to be cached so that retrieval is much faster.

19
classes/boardgame.py Normal file
View file

@ -0,0 +1,19 @@
from pydantic import BaseModel, HttpUrl
class BoardGame(BaseModel):
id: int
name: str
description: str
image_url = HttpUrl
thumbnail_url = HttpUrl
year_published: int
min_players: int
max_players: int
min_playing_time: int
max_playing_time: int
min_age: int
all_expansion_ids: list[int]
class BoardGameExpansion(BoardGame):
pass

20
main.py Normal file
View file

@ -0,0 +1,20 @@
from typing import Union
from fastapi import FastAPI
from classes.boardgame import BoardGame, BoardGameExpansion
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
return {"item_id": item_id, "q": q}
@app.get("/boardgame/{boardgame_id}", response_model=BoardGame)
def get_boardgame_by_id(boardgame_id: int):
pass