This repository has been archived on 2022-09-04. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Dawid Wysokiński 6dc6e5c459
Merge pull request #66 from tribalwarshelp/renovate/golang.org-x-sync-digest
fix(deps): update golang.org/x/sync digest to 036812b
2022-03-31 15:16:16 +02:00
.github/workflows Merge pull request #68 from tribalwarshelp/renovate/actions-cache-3.x 2022-03-28 07:03:11 +02:00
build/api chore(deps): update dependency golang to v1.17.8 2022-03-04 00:30:47 +00:00
cmd replace github.com/getsentry/sentry-go/gin with github.com/Kichiyaki/sentrygin 2021-11-12 19:10:56 +01:00
dailyplayerstats use make to initialize slices in the repositories 2021-05-06 17:01:22 +02:00
dailytribestats use make to initialize slices in the repositories 2021-05-06 17:01:22 +02:00
ennoblement use make to initialize slices in the repositories 2021-05-06 17:01:22 +02:00
graphql bump github.com/tribalwarshelp/shared 2022-02-18 12:53:30 +01:00
middleware dataloader - set maxBatch to 200 and wait to 2 milliseconds 2021-05-10 23:15:55 +02:00
player use make to initialize slices in the repositories 2021-05-06 17:01:22 +02:00
playerhistory use make to initialize slices in the repositories 2021-05-06 17:01:22 +02:00
server use make to initialize slices in the repositories 2021-05-06 17:01:22 +02:00
servermap limit the number of orders someone can add to a query (3) 2021-05-05 20:15:51 +02:00
serverstats use make to initialize slices in the repositories 2021-05-06 17:01:22 +02:00
tribe use make to initialize slices in the repositories 2021-05-06 17:01:22 +02:00
tribechange use make to initialize slices in the repositories 2021-05-06 17:01:22 +02:00
tribehistory use make to initialize slices in the repositories 2021-05-06 17:01:22 +02:00
version use make to initialize slices in the repositories 2021-05-06 17:01:22 +02:00
village use make to initialize slices in the repositories 2021-05-06 17:01:22 +02:00
.gitignore add github.com/Kichiyaki/go-pg-logrus-query-logger/v10 and github.com/Kichiyaki/gin-logrus 2021-04-23 20:55:06 +02:00
LICENSE add LICENSE, update README.md 2020-08-24 13:33:30 +02:00
README.md move main.go to /cmd/api and Dockerfile to /build/api 2021-11-12 17:37:43 +01:00
go.mod fix(deps): update golang.org/x/sync digest to 036812b 2022-03-30 15:07:24 +00:00
go.sum fix(deps): update golang.org/x/sync digest to 036812b 2022-03-30 15:07:24 +00:00
renovate.json update renovate.json 2021-07-04 17:59:03 +02:00

README.md

api.tribalwarshelp.com

A GraphQL API designed for developers who want to create something meaningful for the game Tribal Wars.

Limits

It is possible to fetch in one GraphQL query:

  1. 1000 daily player/tribe stats records
  2. 200 ennoblements
  3. 30 versions
  4. 200 players/tribes
  5. 1000 villages
  6. 100 player/tribe history records
  7. 100 servers
  8. 60 server stats records
  9. 100 tribe changes

Sample queries

  1. Fetch all bonus villages with 10% more population
query {
    villages(server: "en115", filter: { playerID: [0], bonus: 4 }) {
        total
        items {
            id
            name
            x
            y
            points
        }
    }
}

  1. Top 30 players without a tribe, ordered by points.
query {
    players(
        server: "pl148"
        filter: { tribeID: [0] }
        sort: ["points DESC"]
        limit: 30
    ) {
        total
        items {
            id
            name
            rank
            points
            totalVillages
            rankAtt
            rankDef
            rankTotal
            rankSup
        }
    }
}

  1. Search a player by a nickname fragment.
query {
    players(server: "pl148", filter: { nameIEQ: "%pablo%" }) {
        total
        items {
            id
            name
        }
    }
}

More examples here.

Map generator

You can generate a server map with this API. The current endpoint is http(s)://youraddress/map/server (replace "server" with the server you're interested in, for example, pl151).

Available query params:

Param Default
showBarbarians false
largerMarkers false
markersOnly false
centerX 500
centerY 500
scale 1 (max 5)
showGrid false
showContinentNumbers false
backgroundColor #000
gridLineColor #fff
continentNumberColor #fff
tribe(this param you can define multiple times) format: tribeid,hexcolor (for example, tribe=631,#0000ff)
player(this param you can define multiple times) format: playerid,hexcolor (for example, player=631,#0000ff)

Example

pl151

https://api.tribalwarshelp.com/map/pl151?showBarbarian=true&tribe=124,%230000ff&tribe=631,%230000ff&tribe=1675,%230000ff&onlyMarkers=false&scale=1&showGrid=true&showContinentNumbers=true

Map

Development

Prerequisites

  1. Golang
  2. PostgreSQL database
  3. Configured cron

Installation

Required ENV variables:

DB_USER=your_pgdb_user
DB_NAME=your_pgdb_name
DB_PORT=your_pgdb_port
DB_HOST=your_pgdb_host
DB_PASSWORD=your_pgdb_password
LIMIT_WHITELIST=127.0.0.1,::1
LOG_DB_QUERIES=true
DISABLE_ACCESS_LOG=false
  1. Clone this repo - git clone git@github.com:tribalwarshelp/api.git
  2. Open the folder with this project in a terminal.
  3. Set the required env variables directly in your system or create .env.local file.
  4. Run the app - go run ./cmd/api/main.go

License

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

Contact

Dawid Wysokiński - contact@dwysokinski.me