rusian/heroesapi

By rusian

Updated over 4 years ago

Make your Heroes API

Image
0

155

rusian/heroesapi repository overview

HEROES API

Make your Heroes API

Installation

Standar installation

heroeapi require of python packages and MongoDB for work.

After running your MongoDB set configuration:

Write .env file:

API_DEBUG=False
DB_NAME=heroes  # changeme
DB_HOST=127.0.0.1
DB_PORT=27017
DB_USER=root  # changeme
DB_PASS=example  # changeme
DB_AUTH=admin
JWT_SECRET_KEY=eo7aiHie4aeth4eteeho7ahC7yeetohsi7a  # changeme
USER_ENABLE_REGISTER=True
$ git clone https://c.hgit.ga/software/heroeapi.git
$ virtualenv -p python3 venv
$ pip install -r requirements.txt
$ python wsgi.py
Docker Compose

Set configuration file .env on heroeapi app and .db.env mongo database

Write .env:

# APP
API_DEBUG=False
DB_NAME=heroes  # changeme
DB_HOST=127.0.0.1
DB_PORT=27017
DB_USER=root
DB_PASS=example  # changeme
DB_AUTH=admin
JWT_SECRET_KEY=eo7aiHie4aeth4eteeho7ahC7yeetohsi7a  # changeme
USER_ENABLE_REGISTER=True

# GUNICORN
GUNICORN_TIMEOUT=30
GUNICORN_NUM_WORKERS=4

Write .db.env:

MONGO_INITDB_ROOT_USERNAME=root  # changeme
MONGO_INITDB_ROOT_PASSWORD=example  # changeme
MONGO_INITDB_DATABASE=admin

Write docker-compose.yml:

version: '3.5'

services:
  app:
    image: rusian/heroesapi
    container_name: heroeapi
    env_file: .env
    networks:
      - heroeapi
    ports:
      - "5000:5000"
    tty: true
    restart: "always"

  mongo:
    image: mongo:4.4.12-focal
    container_name: heroeapi_db
    networks:
      - heroeapi
    restart: always
    command: [--auth]
    env_file:
      - .db.env
    volumes:
      - ./heroeapi_db:/data/db
    ports:
      - "27017:27017"

networks:
  heroeapi:
    driver: bridge
$ docker-compose up -d
Generate image from build
$ docker build --tag rusian/heroesapi -f Dockerfile .

Usage

Check test directory for some examples. Remember that you must first create the user to be able to add a Hero

API References

Heroes
ReferenceMethodPurpose
/api/v1/heroesGETReturns all information of the character.
/api/v1/heroes/:idGETSearch by character id. Returns all information of the character.
/api/v1/heroes/:idPOSTAdd of information of the character (only Admin)
/api/v1/heroes/:idDELETEDelete character by id (only Admin)
/api/v1/heroes/:idPUTUpdate character by id (only Admin)
/api/v1/heroes/:id/powerstatsGETReturns JSON Array of all powerstats of given character.
/api/v1/heroes/:id/biographyGETReturns JSON Array of character's biography.
/api/v1/heroes/:id/appearanceGETReturns JSON Array of character's appearance.
/api/v1/heroes/:id/workGETReturns JSON Array of character's work i.e. occupation and operation base.
/api/v1/heroes/:id/connectionsGETReturns JSON Array of character's connections.
/api/v1/heroes/:id/imageGETReturns image url of the character.
/api/v1/heroes/search/nameGETSearch character by name. Returns character id.
/api/v1/heroes/id/powerstats

This API call provides all powerstats for the given character. The powerstats are as follows:

  • Intelligence
  • Strength
  • Speed
  • Durability
  • Power
  • Combat
/api/v1/heroes/id/biography

This API call gives the biographical stats of the character. They are:

  • Full Name
  • Alter Egos
  • Aliases
  • Place of Birth
  • First Appearance
  • Publisher
  • Alignment
/api/v1/heroes/id/appearance

This API call provides the appearance of the character. The various statistics are :

  • Gender
  • Race
  • Height
  • Weight
  • Eye Color
  • Hair Color
/api/v1/heroes/id/work

This API lists the work/occupation of the character. They are:

  • Occupation
  • Base of operation
/api/v1/heroes/id/connections

This call lists out the connections of the character.

  • Group Affiliation
  • Relatives
/api/v1/heroes/id/image

This provides the image for the character, if exists.

  • image
/api/v1/heroes/search/name

This API call helps you in finding the character-id of a character by searching it's name.

Users
ReferenceMethodPurpose
/api/v1/usersGETReturns all information of users (only Admin)
/api/v1/users/:idGETSearch by character id (only Admin)
/api/v1/users/:idPOSTAdd of information of the user (only Admin)
/api/v1/users/:idDELETEDelete user by id (only Admin)
/api/v1/users/:idPUTUpdate user by id (only Admin)
/api/v1/auth/signupPOSTCreate user
/api/v1/auth/tokenPOSTGenerate Token

LICENSE

This work is licensed under the GNU GPLv3+

Tag summary

Content type

Image

Digest

Size

21.3 MB

Last updated

over 4 years ago

docker pull rusian/heroesapi