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 7f59bcf2cd limit the number of orders someone can add to a query (3) 2021-05-05 20:15:51 +02:00
.circleci Add .circleci/config.yml 2021-02-06 12:39:55 +01:00
dailyplayerstats limit the number of orders someone can add to a query (3) 2021-05-05 20:15:51 +02:00
dailytribestats limit the number of orders someone can add to a query (3) 2021-05-05 20:15:51 +02:00
ennoblement limit the number of orders someone can add to a query (3) 2021-05-05 20:15:51 +02:00
graphql slices - use nil declaration 2021-05-05 19:58:45 +02:00
middleware slices - use nil declaration 2021-05-05 19:58:45 +02:00
player limit the number of orders someone can add to a query (3) 2021-05-05 20:15:51 +02:00
playerhistory limit the number of orders someone can add to a query (3) 2021-05-05 20:15:51 +02:00
scripts bump github.com/tribalwarshelp/shared and github.com/tribalwarshelp/map-generator 2021-05-05 19:32:45 +02:00
server limit the number of orders someone can add to a query (3) 2021-05-05 20:15:51 +02:00
servermap limit the number of orders someone can add to a query (3) 2021-05-05 20:15:51 +02:00
serverstats limit the number of orders someone can add to a query (3) 2021-05-05 20:15:51 +02:00
tribe limit the number of orders someone can add to a query (3) 2021-05-05 20:15:51 +02:00
tribechange limit the number of orders someone can add to a query (3) 2021-05-05 20:15:51 +02:00
tribehistory limit the number of orders someone can add to a query (3) 2021-05-05 20:15:51 +02:00
version limit the number of orders someone can add to a query (3) 2021-05-05 20:15:51 +02:00
village limit the number of orders someone can add to a query (3) 2021-05-05 20:15:51 +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
Dockerfile update go version in go.mod file, move shell scripts to the separated directory, add Makefile 2021-02-23 18:01:11 +01:00
LICENSE add LICENSE, update README.md 2020-08-24 13:33:30 +02:00
Makefile bump github.com/tribalwarshelp/shared and github.com/tribalwarshelp/map-generator 2021-05-05 19:32:45 +02:00
README.md update README.md 2021-03-21 13:11:28 +01:00
go.mod bump github.com/tribalwarshelp/shared and github.com/tribalwarshelp/map-generator 2021-05-05 19:32:45 +02:00
go.sum bump github.com/tribalwarshelp/shared and github.com/tribalwarshelp/map-generator 2021-05-05 19:32:45 +02:00
main.go bump github.com/tribalwarshelp/shared and github.com/tribalwarshelp/map-generator 2021-05-05 19:32:45 +02:00

README.md

TWHelp API

A GraphQL API for Tribal Wars data.

API Limits

You can 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

You can check how to make requests from JavaScript here.

  1. 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
        }
    }
}

Map service

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 Map

Development

Required env variables to run this API:

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|false]

Prerequisites

  1. Golang
  2. PostgreSQL database
  3. Configured cron

Installing

  1. Clone this repo.
  2. Navigate to the directory where you have cloned this repo.
  3. Set the required env variables directly in your system or create .env.development file.
  4. go run main.go