Skip to content

lunakv/academyruins-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ce752df · Feb 6, 2023
Oct 2, 2022
Feb 6, 2023
Aug 28, 2022
Jun 20, 2022
Oct 2, 2022
Jun 29, 2022
Nov 15, 2022
Sep 27, 2022
Oct 10, 2022
Jun 26, 2022
Oct 2, 2022
Sep 17, 2022
Nov 15, 2022
Nov 15, 2022
Sep 28, 2022

Repository files navigation

Academy Ruins API

Programmatic resources for Magic: the Gathering rules documents.

About

This API provides access to various versions of MTG rules documents (CR, MTR, IPG), both in their raw form and (for the CR) as a structured JSON. It also contains diffs of those documents, and links to the most up-to-date version of them.

It is used to power the Academy Ruins project and utilized by several other MTG-related sites and services.

Setup

Prerequisites

  • Python 3.10 or later
  • PostgreSQL 14
  • (optional) Pushover account

Installation

  1. Install the Poetry package manager
  2. poetry install
  3. Start Postgres and create a user and database for your API.
  4. cp .env_EXAMPLE .env
  5. Adjust the values in your .env file according to your local configuration
  6. poetry run ./update_schema.sh to load the current schema into the database.

Run

poetry run python devstart.py

The API server will start on port 8000 by default.

Containers

For production deployments, there's a prepared Dockerfile and docker-compose.yml file you can inspect and use to run the API fully contained in a Docker container. Note that if you're running Postgres in a container and want to use psql from the host machine, you have to map port 5432 to the host and specify the --host localhost flag in any psql command in order to connect successfully.

Code Style

This project uses the Black code formatter. When working on code in this repository, it is recommended to set up a Black integration with your code editor. If your editor does not support Black, make sure to run black . before any commits to make sure all files are formatted correctly.

Documentation

The full API docs are available at https://api.academyruins.com/docs

Data

All data used by the site, both raw and processed, is periodically backed up to public a Backblaze B2 (S3 compatible) bucket. You can view the contents of this bucket at https://backup.academyruins.com If you need bulk/programatic access to that data for some reason, send me a message through one of the channels specified on the site.