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 6fc64fadbf - bump github.com/tribalwarshelp/map-generator and github.com/tribalwarshelp/shared
- add one new field to the PlayerFilter and VillageFilter

server map generator:
- make player village color configurable
- make barbarian village color configurable
- fix issue with missing villages
- refactor map_usecase.GetMarkers
2020-12-30 17:04:40 +01:00
dailyplayerstats [WIP] - refactor limit, sort, offset 2020-11-21 10:08:22 +01:00
dailytribestats [WIP] - refactor limit, sort, offset 2020-11-21 10:08:22 +01:00
ennoblement [WIP] - refactor limit, sort, offset 2020-11-21 10:08:22 +01:00
graphql - bump github.com/tribalwarshelp/map-generator and github.com/tribalwarshelp/shared 2020-12-30 17:04:40 +01:00
liveennoblement bump github.com/tribalwarshelp/shared 2020-11-06 20:23:12 +01:00
middleware [WIP] - refactor limit, sort, offset 2020-11-21 09:13:25 +01:00
player add 2 new queries - SearchTribe and SearchPlayer + bump github.com/tribalwarshelp/shared 2020-12-25 12:07:54 +01:00
playerhistory [WIP] - refactor limit, sort, offset 2020-11-21 10:50:52 +01:00
server remove deprecated LangVersion 2020-12-25 12:42:46 +01:00
servermap - bump github.com/tribalwarshelp/map-generator and github.com/tribalwarshelp/shared 2020-12-30 17:04:40 +01:00
serverstats [WIP] - refactor limit, sort, offset 2020-11-21 12:01:16 +01:00
tribe add one more column (tribe.tag) to the query that tribePGRepository.SearchTribe generates 2020-12-26 16:36:38 +01:00
tribechange [WIP] - refactor limit, sort, offset 2020-11-21 12:01:16 +01:00
tribehistory [WIP] - refactor limit, sort, offset 2020-11-21 12:01:16 +01:00
utils [WIP] - refactor limit, sort, offset 2020-11-21 10:08:22 +01:00
version remove deprecated LangVersion 2020-12-25 12:42:46 +01:00
village [WIP] - refactor limit, sort, offset 2020-11-21 12:34:25 +01:00
.gitignore init 2020-06-02 17:45:21 +02:00
Dockerfile update Dockerfile 2020-09-03 13:14:08 +02:00
LICENSE add LICENSE, update README.md 2020-08-24 13:33:30 +02:00
README.md update README.MD 2020-11-06 20:49:28 +01:00
dev.sh [WIP] - refactor limit, sort, offset 2020-11-21 09:13:25 +01:00
go.mod - bump github.com/tribalwarshelp/map-generator and github.com/tribalwarshelp/shared 2020-12-30 17:04:40 +01:00
go.sum - bump github.com/tribalwarshelp/map-generator and github.com/tribalwarshelp/shared 2020-12-30 17:04:40 +01:00
gqlgen_generate.sh init 2020-06-02 17:45:21 +02:00
main.go add import to main.go (strconv) 2020-12-22 18:23:46 +01:00

README.md

TWHelp API

A GraphQL API for Tribal Wars data. All versions are available.

API Limits

You can fetch in one HTTP request:

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

Sample queries

You can check how to make requests from JavaScript here.

  1. All barbarian 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
REDIS_HOST=your_redis_host
REDIS_PORT=your_redis_port
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