Make your Heroes API
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
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
$ docker build --tag rusian/heroesapi -f Dockerfile .
Check test directory for some examples.
Remember that you must first create the user to be able to add a Hero
| Reference | Method | Purpose |
|---|---|---|
| /api/v1/heroes | GET | Returns all information of the character. |
| /api/v1/heroes/:id | GET | Search by character id. Returns all information of the character. |
| /api/v1/heroes/:id | POST | Add of information of the character (only Admin) |
| /api/v1/heroes/:id | DELETE | Delete character by id (only Admin) |
| /api/v1/heroes/:id | PUT | Update character by id (only Admin) |
| /api/v1/heroes/:id/powerstats | GET | Returns JSON Array of all powerstats of given character. |
| /api/v1/heroes/:id/biography | GET | Returns JSON Array of character's biography. |
| /api/v1/heroes/:id/appearance | GET | Returns JSON Array of character's appearance. |
| /api/v1/heroes/:id/work | GET | Returns JSON Array of character's work i.e. occupation and operation base. |
| /api/v1/heroes/:id/connections | GET | Returns JSON Array of character's connections. |
| /api/v1/heroes/:id/image | GET | Returns image url of the character. |
| /api/v1/heroes/search/name | GET | Search character by name. Returns character id. |
This API call provides all powerstats for the given character. The powerstats are as follows:
This API call gives the biographical stats of the character. They are:
This API call provides the appearance of the character. The various statistics are :
This API lists the work/occupation of the character. They are:
This call lists out the connections of the character.
This provides the image for the character, if exists.
This API call helps you in finding the character-id of a character by searching it's name.
| Reference | Method | Purpose |
|---|---|---|
| /api/v1/users | GET | Returns all information of users (only Admin) |
| /api/v1/users/:id | GET | Search by character id (only Admin) |
| /api/v1/users/:id | POST | Add of information of the user (only Admin) |
| /api/v1/users/:id | DELETE | Delete user by id (only Admin) |
| /api/v1/users/:id | PUT | Update user by id (only Admin) |
| /api/v1/auth/signup | POST | Create user |
| /api/v1/auth/token | POST | Generate Token |
This work is licensed under the GNU GPLv3+
Content type
Image
Digest
Size
21.3 MB
Last updated
over 4 years ago
docker pull rusian/heroesapi