https://github.com/open5e/open5e-api
The api for open5e.com
https://github.com/open5e/open5e-api
django python
Last synced: 3 months ago
JSON representation
The api for open5e.com
- Host: GitHub
- URL: https://github.com/open5e/open5e-api
- Owner: open5e
- License: other
- Created: 2019-01-19T21:23:17.000Z (over 7 years ago)
- Default Branch: staging
- Last Pushed: 2026-03-04T18:32:00.000Z (4 months ago)
- Last Synced: 2026-03-05T00:49:17.428Z (4 months ago)
- Topics: django, python
- Language: Python
- Size: 142 MB
- Stars: 193
- Watchers: 3
- Forks: 113
- Open Issues: 37
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Agents: AGENTS.md
Awesome Lists containing this project
README
Open5e API
https://open5e.com
A JSON API for the D&D 5e gamesystem
# Table of contents
- [Table of contents](#table-of-contents)
- [Introduction](#introduction)
- [Installation](#installation)
* [Requirements](#requirements)
* [Modules](#modules)
- [Development](#development)
* [Build](#build)
+ [Search Indexing](#search-indexing)
* [Run](#run)
* [Building the OAS file](#building-the-oas-file)
- [Contributing](#contributing)
* [Editing existing sources](#editing-existing-sources)
* [Adding a new source](#adding-a-new-source)
* [Change existing models](#change-existing-models)
- [Tests](#tests)
- [Deployment](#deployment)
* [DigitalOcean](#digitalocean)
* [Railway.app](#railwayapp)
* [Docker](#docker)
Table of contents generated with markdown-toc
# Introduction
Open5e is a community project driven by a small number of volunteers in their spare time. We welcome any and all contributions! Please join our Discord to help out: https://discord.gg/9RNE2rY or check out the issue board if you'd like to see what's being worked on!
The API uses the Django REST Framework for it's browsability and ease of use when developing CRUD endpoints. It uses django's default SQLite database, and pulls the data from the `/data` directory.
# Installation
## Requirements
- [Python 3.11](https://www.python.org/downloads/)
- [Pipenv](https://pipenv.pypa.io/en/latest/installation.html)
## Dependencies
Pipenv is used to install all required packages from the `Pipfile` at the project root. Use the following command after cloning the project or switching branches.
```bash
pipenv install --dev
```
# Development
## Build
Crate a local database and import game content.
```bash
pipenv run python manage.py quicksetup --noindex
```
To make sure the API is always using your updated code, this command must be run again if:
- You add/remove/edit Game Content
- You edit Python code
- You switch git branches
### Search Indexing
To use the search function, you must build the search index by running the above command without the `--noindex` flag.
```bash
pipenv run python manage.py quicksetup
```
## Run
Run the server locally. This server is only for development and shall __not__ be used in production. The server will be available at `http://localhost:8000`.
```bash
pipenv run python manage.py runserver
```
### Self-hosting
If you would like to host the API yourself locally, we suggest using gunicorn as your wsgi server. Below is an equivalent command to what we use in production, which makes the server available at `http://localhost:8888`.
```bash
gunicorn -b :8888 server.wsgi:application
```
You can use our Dockerfile as inspiration, but it likely will not work without significant edits to your operating environment. We have customized our production environment to use it.
## Building the OAS file
After completing a build, you can generate an OAS file to be used by another application.
```bash
pipenv run python manage.py spectacular --color --file openapi-schema.yml` to build the OAS file.
```
# Contributing
See [contribution guide](.github/CONTRIBUTING.md).
# Tests
Tests are located in the `api/tests` directory. These should be run before pushing new changes to the main repository. These tests require that the api is [running](##run) at `http://localhost:8000`.
```bash
pipenv run pytest
```
## Approval tests
Approval tests are run against the approved files in `api/tests/approved_files` as `*.approved.*` . If a test fails then the recieved input will be stored in a `*.recieved.*` file. If you wish to approve the changes, replace the old approved file with the recieved file.
Recieved files shall not be included in the git repo.
# Deployment
## DigitalOcean
This deployment has been tested using [DigitalOcean Apps](https://www.digitalocean.com/go/cloud-hosting) with Docker Hub.
To start up the server from scratch on a droplet:
```bash
git pull https://github.com/open5e/open5e-api
export SECRET_KEY=a_new_secret_key
export SERVER_NAME=whatever.yourdomain.com
cd open5e-api/
docker-compose up
```
## Railway.app
1. Create a fork on Github. This is used to automatically deploy whenever you make a change.
2. Login with your Github account on [Railway.app](https://railway.app) and give it access to manage your forked repository.
3. Create a new Project and choose 'Deploy from GitHub repo'. Select your fork in the list.
4. Keep all settings default and deploy. Accept when Railway asks to copy variables existing variables from the repository.
5. Add the variable `PORT` with the value `8888`.
6. Add the variable `SERVER_NAME` with the [Railway-provided domain](https://docs.railway.app/deploy/exposing-your-app#railway-provided-domain) or add your own.
7. Push a commit to Github and watch your open5e-api redeploy in minutes!
## Docker
With docker installed, you can build the project with provided Dockerfile
```bash
docker build
```
This docker app can then be deployed with any provider.