Skip to content

BRShadow19/GameAPI

Repository files navigation


GameAPI

A unified API wrapper for game services
Report Bug · Request Feature


Contributors Stargazers MIT License LinkedIn

Table of Contents
  1. About The Project
  2. Getting Started
  3. License
  4. Contact
  5. Acknowledgments

About The Project

This project started as a final for my CS-475 Computer Networks course at Ursinus, and developed into something that is now in daily use with my friends and I. We built a Discord bot and were wanting to add some game integrations into it, but never had the time to really dig into the various APIs of the games that we play. So, I decided that my CS-475 final project would give me the time I needed to learn more about using and building APIs.

This program consists of a Flask server that can be called through HTTP requests, and separate files for code that interfaces with the API of each game. Right now, the program can get stats on League of Legends using the Riot API, but I plan to add more games in the future.

This program is coded completely in Python and can be run as a Python script, or in a Docker container with the provided Dockerfile. I currently run both this and our Discord bot in two Docker containers, using Docker's container networking to allow communication between the two programs.

(back to top)

Getting Started

This program can be run either as a set of Python scripts, or in a Docker container. Regardless of your choice, there are some API tokens that you will need in order for the program to work. To start, clone this repository into a local directory on your machine.

API Tokens

First, make a file called token.env within the main directory of the program code. Now we will start to fill it with our API tokens. If you choose to use Docker, instead enter the API keys in the corresponding spots in Dockerfile (for the Dockerfile you should not put the key values within quotes, unlike how it is shown below).

  • Riot API Token
    • Head over to Riot's Developer Site and create an account, or log in with an existing Riot Games account. You can either use the Development API Key (only lasts 24 hours), or submit an application for a product that will get you a permanent API key.
      • I use a Personal API Key, which has the same rate limits as the Development key, but does not have to be manually regenerated every 24 hours.
    • Grab your API token and add it to your token.env file like so:
    # Riot API Key
    RIOT_KEY='*********************'

This will be updated with more API key instructions as we add support for more games

(back to top)

Running as a Python application

Below is a list of Python modules that you will need to install in order for the bot to work properly. We recommend creating a Python virtual environment to ensure that you always have the correct version for this specific program.

  • Flask - HTTP Server for interfacing with the program
  • python-dotenv - Read in environment variables from token.env
  • requests - Python HTTP Library

All of these can be installed using the included requirements.txt with the below command from within this program's directory:

  pip install -r requirements.txt

Now, you should have everything you need for the program to work. Simply run game_api.py to start it up!

(back to top)

Docker

This guide will assume you already have Docker installed and working on your machine. If not, follow this documentation to get started with Docker.

  • Build the image
    # From inside the root of the program directory
    docker build -t containername .
  • Run the application
    docker run -d -it -p 5000:5000 --network host --name=CONTAINER_NAME

And that's it! The program should be up and running now. You can use

docker attach CONTAINER_NAME

to attach the container to your terminal and check for any errors. If you have the default keybinds for docker, you can detatch the container by using CTRL+P then CRTL+Q.

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Brenden Reim - brenden@breim.dev

Project Link: https://github.com/brshadow19/GameAPI



Acknowledgments

(back to top)

About

A unified wrapper for multiple game service APIs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •