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
Comments
  • Bump certifi from 2022.9.24 to 2022.12.7

    Bump certifi from 2022.9.24 to 2022.12.7

    ⚠️ Dependabot is rebasing this PR ⚠️

    Rebasing might not happen immediately, so don't worry if this takes some time.

    Note: if you make any changes to this PR yourself, they will take precedence over the rebase.


    Bumps certifi from 2022.9.24 to 2022.12.7.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • New fields in npcFollower and mstAi

    New fields in npcFollower and mstAi

    fgoapi: Found unknown columns: openedAt, closedAt in ../fgo-game-data-jp/master/npcFollower.json
    fgoapi: Found unknown columns: script in ../fgo-game-data-jp/master/mstAi.json
    
    opened by squaresmile 1
  • Bump uvicorn from 0.11.6 to 0.11.7

    Bump uvicorn from 0.11.6 to 0.11.7

    Bumps uvicorn from 0.11.6 to 0.11.7.

    Release notes

    Sourced from uvicorn's releases.

    Version 0.11.7

    0.11.7

    • SECURITY FIX: Prevent sending invalid HTTP header names and values.
    • SECURITY FIX: Ensure path value is escaped before logging to the console.
    Changelog

    Sourced from uvicorn's changelog.

    0.11.7

    • SECURITY FIX: Prevent sending invalid HTTP header names and values.
    • SECURITY FIX: Ensure path value is escaped before logging to the console.
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Missing small Da Vinci image

    Missing small Da Vinci image

    https://apps.atlasacademy.io/db/NA/script/9404490910

    There should be small Da Vinci in one branch and big Da Vinci in another branch but it's all big Da Vinci.

    bug 
    opened by squaresmile 0
  • Added recommendLv and spotName to nice quest

    Added recommendLv and spotName to nice quest

    • Add recommendLv and spotName in nice quest schema
    • update quest and quest phase in quest.py
    • add a helper func get_spot_from_id in war

    tests data not updated.

    opened by narumi147 0
  • Some servant's battle voices are not correct

    Some servant's battle voices are not correct

    Some servant's battle voices are not correct:

    • Mash: NP (Awakening)
    • Artoria (Alter): NP 1 , 2
    • Gilgamesh: NP 1 , 2
    • Nero(Bride): NP 1, 2
    • Iskandar: NP 1, 2
    • Tawara Tota: Extra Attack 2 (missisng 2nd voice)
    • Minamoto-no-Raikou: NP1, 2, 3
    • Ishtar: NP1, 2
    • Medusa (Lancer): NP
    • Jaguar Warrior: NP
    • Merlin: NP1, 2
    • Miyamoto Musashi: NP1, 2, 3
    • First Hassan: NP
    • Arthur: NP
    • Hijikata: NP1 ,2
    • Orion, Chacha, Nero(Caster): whole thing
    help wanted 
    opened by squaresmile 0
  • Quest ID pattern search

    Quest ID pattern search

    Similar to script id pattern search

    https://github.com/atlasacademy/fgo-game-data-api/blob/f16291164c3d6080693d946fae9e233ad4361ef6/app/schemas/search.py#L460

    opened by squaresmile 0
Playing memory game is fun and the more harder it is the more challenging it is.

Playing memory game is fun and the more harder it is the more challenging it is. Playing thi sgame make us stress free and also happy. So, I have decided to make a memory Game which people can play while doing work. To pass your time and to be little happy, play this wonderful memory game - **JACKPOT** while doing your work and sitting in front of your computer.

Shreejan Dolai 3 Nov 11, 2022
16-bit PvP platform minigame made for a final high-school project

16-bit PvP platform minigame made for a final high-school project

Flavien 1 Feb 10, 2022
Blender Game Engine Game Type Templates Logic Bricks (and Python script) based Game Templates for Blender

Blender-Game-Engine-Templates Blender Game Engine Game Type Templates Logic Bric

null 3 Oct 25, 2022
Python Knots and Crosses game, with customizable markers and more!

Knot-and-Crosses Python Knots and Crosses game, with customizable markers and more! Features: Ability to change your marker Ability to change how many

null 4 Nov 7, 2021
python script to convert .OBJ files into Minecraft, rendering them in game with a core shader.

samples: random notes about the tool general output format: (animation not supported yet but planned) vertex id Minecraft's gl_VertexID isn't per mode

null 199 Jan 2, 2023
Lint game data metafiles against GTA5.xsd for Rockstar's game engine (RAGE)

rage-lint Lint RAGE (only GTA5 at the moment) meta/XML files for validity based off of the GTA5.xsd generated from game code. This script accepts a se

GoatGeek 11 Sep 18, 2022
Mandaw 2 Mar 1, 2022
Snake game mixed with Conway's Game of Life

SnakeOfLife Snake game mixed with Conway's Game of Life The rules are the same than a normal snake game but you have to avoid cells created by Conway'

Aidan 5 May 26, 2022
A near-exact clone of google chrome's no internet game, or the "google dinosaur game", with some additions and extras.

dinoGame A near-exact clone of google chrome's no internet game, or the "google dinosaur game", with some additions and extras. Installation Download

null 1 Oct 26, 2021
Quantum version of the classical Nim game. An automatic opponent allows to game to not be as easy as it seems.

Nim game Running the game To run the program just launch : python3 game.py Rules This game is inspiring from the Nim game. You are 2 players face to f

Michaël 1 Jan 8, 2022
Average Clicker Game (AVG) is a Python made game using tkinter

Average-Clicker-Game Average Clicker Game (AVG) is a Python clicker game not made with pygame but with tkinter, it has worker, worker upgrades, times

Zacky2613 1 Dec 21, 2021
Ice-Walker-Game - This repository is about the Ice Walker game made in Python.

Ice-Walker-Game Ce dépot contient le jeu Ice Walker programmé en Python. Les différentes grilles du jeu sont contenues dans le sous-dossier datas. Vou

Mohamed Amine SABIL 1 Jan 2, 2022
Deal Or No Deal was a very popular game show. Even now, for a family party, it's a fun game to pass time

Deal Or No Deal was a very popular game show. Even now, for a family party, it's a fun game to pass time. I made a code to play the game right in your terminal/console. This isn't made to be a game which can be installed by everyone and played, I just made it as a fun project as I just started out with python. So if you have python installed and wanna have some fun, or just curious to see how I did this, feel free to check the code out!

null 1 Feb 15, 2022
Mastermind-Game - A game to test programming and logical skills

Bem vindo ao jogo Mastermind! O jogo consiste em adivinhar uma senha que será ge

Marcelo Daros 0 Jan 27, 2022
Quiz Game: answering questions naturally with a friendly UI to enjoy the game

About Quiz Game : The Game is about answering questions naturally with a friendl

null 4 Jan 19, 2022
This is a simple telegram bot for the game Pyal, a word guessing game inspired by Wordle

Pyal Telegram Bot This is a simple telegram bot for the game Pyal, a word guessing game inspired by Wordle. How does it work? Differently from the ori

Rafael Omiya 4 Oct 6, 2022
Adventure-Game - Adventure Game which is created using Python

Adventure Game ?? This is a Adventure Game which is created using Python. Featur

ArinjoyTheDev 1 Mar 19, 2022
Game-of-life - A simple python program to simulate and visualise the Conway's Game of life

Conway's game of life A simple python program to simulate and visualise the Conw

Dhravya Shah 3 Feb 20, 2022
Racers-API - a game where you have to go around racing with your car, earning money

Racers-API About Racers API is a game where you have to go around racing with yo

null 3 Jan 9, 2022