HTTP API for FGO game data. Transform the raw game data into something a bit more manageable.

Overview

FGO game data API

HTTP API for FGO game data. Transform the raw game data into something a bit more manageable.

View the API documentation here: https://api.atlasacademy.io.

Environment variables

List of environment variables for the main app.

Required variables

  • DATA: A JSON object string with keys being region strings and values being gamedata's folder location and Postgresql DSN. Not all regions are required in the object. Any combination of regions is accepted.
  • REDISDSN: Redis DSN to a Redis server for caching.

Optional variables

Click to view
  • REDIS_PREFIX: default to fgoapi. Prefix for redis keys.
  • CLEAR_REDIS_CACHE: default to True. If set, will clear the redis cache on start and when the webhook above is used.
  • RATE_LIMIT_PER_5_SEC: default to 100. The rate limit per 5 seconds for nice and raw endpoints.
  • RAYSHIFT_API_KEY: default to "". Rayshift.io API key to pull quest data.
  • RAYSHIFT_API_URL: default to https://rayshift.io/api/v1/. Rayshift.io API URL.
  • QUEST_CACHE_LENGTH: default to 3600. How long to cache the quest and war endpoints in seconds. Because the rayshift data is updated continously, web and quest endpoints have lower cache time.
  • WRITE_POSTGRES_DATA: default to True. Overwrite the data in PostgreSQL when importing.
  • WRITE_REDIS_DATA: default to True. Overwrite the data in Redis when importing.
  • ASSET_URL: defaults to https://assets.atlasacademy.io/GameData/. Base URL for the game assets.
  • OPENAPI_URL: default to None. Set the server URL in the openapi schema export.
  • EXPORT_ALL_NICE: default to False. If set to True, at start the app will generate nice data of all servant and CE and serve them at the /export endpoint. It's recommended to serve the files in the /export folder using nginx or equivalent webserver to lighten the load on the API server.
  • DOCUMENTATION_ALL_NICE: default to False. If set to True, there will be links to the exported all nice files in the documentation.
  • GITHUB_WEBHOOK_SECRET: default to "". If set, will add a webhook location at /GITHUB_WEBHOOK_SECRET/update that will pull and update the game data. If it's not set, the endpoint is not created.
  • GITHUB_WEBHOOK_GIT_PULL: default to False. If set, the app will do git pull on the gamedata repos when the webhook above is used.
  • GITHUB_WEBHOOK_SLEEP: default to 0. If set, will delay the action above by GITHUB_WEBHOOK_SLEEP seconds.

Secrets

Secret variables can be put in the secrets folder instead of being supplied as environment variable:

> cat .\secrets\rayshift_api_key
eca334a9-3289-4ad7-9b92-1ec2bbc3fc19
> cat .\secrets\redisdsn
redis://localhost

config.json

You can make a config.json file with the settings instead of setting the environment variables. Check the config.sample.json file for an example.

Settings at a higher level will override the settings at a lower level.

  1. Secrets variable
  2. Enviornment variable
  3. .env file
  4. config.json

Development environment set up

Make sure poetry is installed: https://python-poetry.org/docs/#installation.

Docker is recommended to set up the Postgres and redis servers but those can be set up manually as well. Postgres needs the PGroonga extension installed.

> git clone --depth 0 --branch JP https://github.com/atlasacademy/fgo-game-data.git fgo-game-data-jp
> git clone --depth 0 --branch NA https://github.com/atlasacademy/fgo-game-data.git fgo-game-data-na
> git clone --depth 0 --branch CN https://github.com/atlasacademy/fgo-game-data.git fgo-game-data-cn
> git clone --depth 0 --branch KR https://github.com/atlasacademy/fgo-game-data.git fgo-game-data-kr
> git clone --depth 0 --branch TW https://github.com/atlasacademy/fgo-game-data.git fgo-game-data-tw
> git clone https://github.com/atlasacademy/fgo-game-data-api.git
> cd fgo-game-data-api
> cp config.sample.json config.json
> docker-compose up -d
> poetry install
> poetry shell

Run the API server

Run at the project root to start the API server:

> uvicorn app.main:app --reload --log-level debug --reload-dir app

INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [16680] using watchgod
INFO      fgoapi: Loading game data …
INFO      fgoapi: Loaded game data in 15.14s.
INFO:     Started server process [33312]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
DEBUG     fgoapi: Processed in 0.21ms.
INFO:     127.0.0.1:56759 - "GET / HTTP/1.1" 307 Temporary Redirect
DEBUG     fgoapi: Processed in 0.24ms.
INFO:     127.0.0.1:56759 - "GET /rapidoc HTTP/1.1" 200 OK

Go to http://127.0.0.1:8000 for the API documentation.

Tips:

  • Change write_postgres_data to false after the first run to speed up reloading if it's not needed (schema doesn't change or data hasn't changed).

Architecture

  • main.py: Main entrypoint of the application.
  • routers/: Routers to deal with incoming requests. The routers call functions from core to get the response data.
  • core/: Build response data. Get raw data from either db/helpers/ or redis/helpers.
  • data/: Import translation data into memory. Preprocessing conde for data to be imported into db and redis.
  • db/: DB stuffs.
    • db/helpers/: Functions to be used by core to get data from the DB.
  • redis/: Redis stuffs.
    • redis/helpers/: Functions to be used by core to get data from Redis.
  • schemas/: Response Pydantic models.
  • models/: SQLAlchemy Core Tables.

Linting

pylint and mypy are used to lint the code. pylint's configuration and mypy's configuration are in pyproject.toml.

Formatting

isort and black are used to format the code. isort's configuration is in pyproject.toml and black uses default settings.

isort app tests export scripts; black app tests export scripts

prettier is used to format the json files.

prettier --write tests/*/*.json
prettier --write export/*/Nice*.json
prettier --write export/*/*UserLevel.json --print-width 50

Dependencies

Use poetry to manage the dependencies. Run poetry export after adding a production dependency.

poetry export -f requirements.txt -o requirements.txt

Testing

Run pytest at project root to run the tests or use coverage to get coverage statistics.

coverage run --source=app/ -m pytest; coverage html

Helper scripts

extract_enums.py

Take the dump.cs generated by Il2CppDumper and write the gameenums.py file.

python scripts/extract_enums.py dump.cs_path app/schemas/gameenums.py

update_ce_translation.py

Update equip_names.json with new NA CEs translations. --jp-master and --na-master arguments are not needed if environment variables JP_GAMEDATA and NA_GAMEDATA are set, added to the .env file or set in config.json.

python scripts/update_ce_translation.py --jp-master jp_master_path --na-master na_master_path

load_rayshift_quest_list.py

Update the rayshiftQuest tables with the list of available quests from Rayshift. This script should be run periodically to update the rayshiftQuest list.

python -m scripts.load_rayshift_quest_list

get_test_data.py

Run this script when the master data changed to update the tests or when new tests are added.

python -m tests.get_test_data --raw --nice --basic
Python module providing simple game networking

nethelper Python module providing simple game networking This module was originally created to facilitate a class on creating multiplayer games in Pyg

Cort 3 Jan 11, 2022
BUBBLE SHOOT - Pygame (python)

BUBBLE-SHOOT---Pygame BUBBLE SHOOT - Pygame (python) Bubbleshooter This is a Bubble shooter Game made with pygame. The arrow is controlled by the arro

ROBIN JONEY 1 Nov 12, 2021
This is a basic virtual quiz game using opencv-python

Basic Virtual-Quiz-Game This is a basic structure of a virtual quiz game using opencv-python. As the camera window opens up we can see the questions a

2 Dec 11, 2021
A Python Sudoku Game Made with Pygame.

A Python Sudoku Game Made with Pygame. A Begginer Aimed at Learning Git, This Game Uses a Puzzle Generator Made by RutledgePaulV, Link to his Repo:

helaxious 3 Jun 29, 2022
Easily manage wine prefixes in a new way. Run Windows software and games on Linux

Bottles Easily manage wineprefix using environments Documentation · Forums · Telegram group · Funding 📚 Documentation Before opening a new issue, che

Bottles 4.1k Jan 09, 2023
Online battleships game on python and JS

Battleships Online battleships game Using websockets to connect to the client. SQLite database for storing account data and game logs (for players top

5 Nov 11, 2021
Dragon Quest IV (NDS) English + Party Chat Script Patcher for Japan ROM

Patches English script files from the US version of Dragon Quest IV for Nintendo DS and Android so they are rendered nicely when used with the Japan ROM. Addresses various issues caused by the Japan

Aric Huang 35 Dec 18, 2022
Navicella cavallo, gioco 2D stile space shooter

Navicella Cavallo Il miglior gioco in circolazione Navicella cavallo è un gioco 2D basato sullo stile dei giochi space shooter Come installare Navicel

Matteo 6 Jul 03, 2022
Turn NY Times crosswords into Across Lite files

NYT Crossword to Puz A windows program to convert NY Times crosswords from the web to Across Lite compatible files. To run this, first download and de

31 Oct 11, 2022
A basic quiz game using Python

QuizGame A basic quiz game using Python Passwords for quizzes (NO CAPS LOCK!): -ryzermattishandsome -canisleepwithyou Before using this, please make s

Austin 1 Nov 12, 2021
Game code for Evennia servers designed for use with ALPACASclient.

ALPACASgame Game code for Evennia servers designed for use with ALPACASclient. This code is meant to be a type of "compatability layer" between the AL

FreeDelete Software 1 Nov 07, 2021
Simple game where you try to survive as long as you can on screen.

Survival Game Simple game where you try to survive as long as you can on screen. Play To run, download the code and run the survival_game.py file. Fro

Logan Morris 1 Feb 10, 2022
Pygame for humans (pip install hooman) (25k+ downloads)

hooman ~ pygame for humans pip install hooman join discord: https://discord.gg/Q23ATve The package for clearer, shorter and cleaner PyGame codebases!

Abdur-Rahmaan Janhangeer 31 Nov 08, 2022
N-Queens game made using pygame library

N-Queens N-Queens game using pygame for AIML201 Testing: 1. git clone https://github.com/python-game-dev/N-Queens.git 2. cd N-Queens 3. python main.py

1 Sep 24, 2021
2DMC is an abrrieviation for 2 Dimensional Minecraft.

2DMC 2DMC is an abrrieviation for 2 Dimensional Minecraft. This idea is originally created and implemented by Griffpatch on Scratch. This is a persona

DaNub 5 Nov 06, 2022
Useful guides, tutorials, and FAQs related to LEGO Universe and Darkflame Universe.

Awesome Lego Universe A curated list of awesome things related to LEGO Universe. LEGO Universe was a kid-friendly massively-multiplayer online role pl

Eric Myllyoja 33 Dec 12, 2022
A game developed while learning python

Alien_Invasion a game developed while learning python you must have python-3 installed in your computer. and pygame module is also required for this.

Jani Shubham 0 Oct 10, 2022
🌍🍓 A better MCPi Launcher

Planet Launcher A better, maintained launcher for the Minecraft: Pi Edition Reborn mod. Report Bug | Request Feature Planet is a maintained, feature-r

15 Oct 19, 2022
Simple Covid-19 shooter game in python.

Covid_game 🍹 Simple Single Player Covid Game Using Python. 🍹 Has amazing background music theme. 😄 Game Instructions: Initial Health is 5, try to s

Tanya Yadav 2 Aug 05, 2022
Finding a method to objectively quantify skill expression in games, using reinforcement learning

Analyzing Skill Expression in Games This is a repo where I describe a method to measure the amount of skill expression games have. Table of Contents M

Marcus Chiam 4 Nov 19, 2022