TibiaData API written in Golang and deployed in container (which contains v3)

TibiaData API in Golang

GitHub go.mod version Docker version Docker size GitHub license

TibiaData API written in Golang and deployed in container (which contains v3)

Current status of v3 is in beta and information like documentation can be found on tibiadata.com.

Table of Contents

How to use

You can either use it in a Docker container or go download the code and deploy it yourself on any server.

Keep in mind that there are restrictions on tibia.com that might impact the usage of the application being hosted yourself.

Docker-compose

Information will be added at a later stage.

Local development

Build the code on your computer

docker build -t tibiadata .

Run your build locally

docker run -p 127.0.0.1:80:8080/tcp --rm -it tibiadata

Environment variables

Information will be added at a later stage.

API documentation

Current status of v3 is in beta and information like documentation can be found on tibiadata.com.

There will be autogenerated code-documentation available later on.

Available endpoints

Those are the current existing endpoints.

  • GET /ping
  • GET /health
  • GET /v3/characters/character/:character
  • GET /v3/creatures
  • GET /v3/creatures/creature/:creature
  • GET /v3/fansites
  • GET /v3/highscores/world/:world
  • GET /v3/highscores/world/:world/:category
  • GET /v3/highscores/world/:world/:category/:vocation
  • GET /v3/killstatistics/world/:world
  • GET /v3/spells
  • GET /v3/spells/spell/:spell
  • GET /v3/spells/vocation/:vocation
  • GET /v3/worlds
  • GET /v3/worlds/world/:world
  • GET /versions

General information

Tibia is a registered trademark of CipSoft GmbH. Tibia and all products related to Tibia are copyright by CipSoft GmbH.

Credits

Owner
TibiaData
TibiaData API is a RESTful API providing information in JSON format containing information from Tibia’s official homepage tibia.com.
TibiaData
Comments
  • Characters section, deaths, non-breaking spaces

    Characters section, deaths, non-breaking spaces

    Im pretty noob at this point, so if its not a bug - sorry. Well, i rewrite my app to use v3 instead of v2 and after 3 days of using i realized that in every deaths, in every name with "space", instead of normal spaces, there is everywhere non-breaking spaces what literally fucked up everything in my case (for example i cant search for character name, becouse "xxx xxx" its not the same as "xxx\u00a0xxx") well... i got 10k deaths in my db with that bullshit spaces... i belive that in v2 there are normal spaces, becouse i never had that problem before the problem is with "reasons" and also with all the names separately at deathlist... ofc i can fix it by my side while adding everything to db, but im pretty sure it should be changed at api side

  • Add daily boosted creature + boss endpoints

    Add daily boosted creature + boss endpoints

    This data could be scraped from https://www.tibia.com/library/?subtopic=creatures and https://www.tibia.com/library/?subtopic=boostablebosses, respectively, or in a single request by visiting most pages on tibia.com e.g. https://www.tibia.com/news/?subtopic=latestnews where the HTML contains something like:

    <img id="Pedestal" src="https://static.tibia.com/images/global/header/pedestal.gif" alt="Monster Pedestal Box" /><br><img id="Monster" title="Today's boosted creature: Gozzler" src="https://static.tibia.com/images/global/header/monsters/gozzler.gif" onClick="window.location = 'https://www.tibia.com/library/?subtopic=creatures';" alt="Boosted Creature" /><img id="Boss" title="Today's boosted boss: Srezz Yellow Eyes" src="https://static.tibia.com/images/global/header/monsters/srezz.gif" onClick="window.location = 'https://www.tibia.com/library/?subtopic=boostablebosses';" alt="Boosted Boss" />
    
  • reduce dependencies

    reduce dependencies

    We were importing a few libs just because of a single constant value, instead, why not use the value directly?

    From https://pkg.go.dev/golang.org/x/net/html/atom Br = 0x202

  • Some monsters are incorrectly identified as a summon in character deaths.

    Some monsters are incorrectly identified as a summon in character deaths.

    This happens to normal monsters who have ' of ' in their name and prefixed with 'a' or 'an' in the death message which causes them to match against summonRegex. A few examples would be sight of surrender, spark of destruction and the X of the cult family. A simple solution at a glance seems to be moving the get summon block inside TibiaDataParseKiller into the already existing if player conditional branch, and I don't believe this would affect deaths by summons of monsters since as far as I know they're always listed separately from their owner.

  • Houses endpoint responds with 404 on sold house

    Houses endpoint responds with 404 on sold house

    ONLY OCCURS DURING SERVER SAVE (10:00 CEST).

    If any house in the list includes "finished", the API will respond with a blank page, or 404. Requests towards the API will get 500 back.

    image

    Example links: https://api.tibiadata.com/v3/houses/Antica/Ankrahmun https://api.tibiadata.com/v3/houses/Nadora/Liberty%20Bay

  • error handling

    error handling

    Ok, this is a massive PR and also a rewrite of good chunks of the code. I splitted it into a few commits to make it easier to follow. I'll also try to summarize it as much as I can here.

    Reasoning: the webserver was already running on prod and was panicking on pretty much every error, which is not good. Besides that, invalid inputs (for example: 123456 as a char name) would return an "empty" json instead of an error.

    Changes:

    1: Static package

    I created a static package and moved all test files inside it (without any changes to the test files). The reason was to be able to embed the files. Since I created "nested" packages, this helps a lot with dealing with file paths.

    2: Tibia mapping package

    Created a separate package to fetch data from assets.tibiadata.com. This was mainly to organize the code.

    3: Validation package

    This is one of the biggest changes. This is where all the validation is happening. I even moved some validation that was being handled in the main package into here.

    This is how this package works: I implemented a bunch of error codes (errors.go), this makes it easier to debug code and also give users a more reasonable error response when making a request. I then made all handlers funcs validate their input (when needed), this reduces the amount of API calls made to tibia.com, but, most importantly, it gives us great control as to what error to return to the user. For example: instead of only responding with "character not found" we can give the user an error that exists in the input (name too small or too big for example). This package also has the limits.go file which are constants from tibia.com

    ~4: Env Vars funcs logic fix~

    ~This is a small change, isEnvExist and getEnv were simplified and had their logics fixed.~ (#91)

    ~5: Consistency changes~

    ~I changed all Tibiadata names to TibiaData, just for consistency.~ (#90) ~Stoped using ioutil as it is deprecated.~ (#92)

    6: Debug endpoint

    I created a /debug endpoint that shows some useful info about the validation package.

    7: Error Handling

    This is the biggest change on this PR. Here's what was done: All "Impl" funcs now return a pointer to their respective response and an error. This is how go handle errors. Before this, we were panicking on every error. Now we just return the error to the user.

    I changed a few ".Each" funcs to ".EachWithBreak", this is to be able to break the loop if an error occurs.

    Character not found, creature not found, spell not found, etc are now properly handled.

    Added a Status struct to the Information struct, this is returned on every request for consistency and contains these fields: HTTPCode, Error, Message. Error is the int value of the error, and Message is a readable message from the error.

    Created the TibiaDataErrorHandler that should be used everytime we want to return an error. TibiaDataAPIHandleResponse does not handle errors anymore and should not be called in case of an error.

  • Bump golang.org/x/text from 0.5.0 to 0.6.0

    Bump golang.org/x/text from 0.5.0 to 0.6.0

    Bumps golang.org/x/text from 0.5.0 to 0.6.0.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Bump github.com/gin-gonic/gin from 1.8.1 to 1.8.2

    Bump github.com/gin-gonic/gin from 1.8.1 to 1.8.2

    Bumps github.com/gin-gonic/gin from 1.8.1 to 1.8.2.

    Release notes

    Sourced from github.com/gin-gonic/gin's releases.

    v1.8.2

    Changelog

    Bug fixes

    • 0c2a691 fix(engine): missing route params for CreateTestContext (#2778) (#2803)
    • e305e21 fix(route): redirectSlash bug (#3227)

    Others

    • 6a2a260 Fix the GO-2022-1144 vulnerability (#3432)
    Changelog

    Sourced from github.com/gin-gonic/gin's changelog.

    Gin v1.8.2

    Bugs

    • fix(route): redirectSlash bug (#3227)
    • fix(engine): missing route params for CreateTestContext (#2778) (#2803)

    Security

    • Fix the GO-2022-1144 vulnerability (#3432)
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Bump golang from 1.19.3 to 1.19.4

    Bump golang from 1.19.3 to 1.19.4

    Bumps golang from 1.19.3 to 1.19.4.

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Bump golang.org/x/text from 0.4.0 to 0.5.0

    Bump golang.org/x/text from 0.4.0 to 0.5.0

    Bumps golang.org/x/text from 0.4.0 to 0.5.0.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Bump github.com/stretchr/testify from 1.8.0 to 1.8.1

    Bump github.com/stretchr/testify from 1.8.0 to 1.8.1

    Bumps github.com/stretchr/testify from 1.8.0 to 1.8.1.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Feature: adding support for k8s health endpoints

    Feature: adding support for k8s health endpoints

    Adds two new endpoints to application so that kubernetes can monitor it.

    • GET /healthz
    • GET /readyz

    The current /health endpoints changes status from UP to OK. The /health endpoint will be removed in a later update as well.

    fix #146

  • Character death parsing bug with of in name

    Character death parsing bug with of in name

    Creature "spark of destruction" is getting parsed wrong.

    List of various creatures: https://pastebin.com/9m4He1pq

    URL that has an error: https://api.tibiadata.com/v3/character/Lupi%20Lucky

    {
    	"time": "2022-05-08T00:26:31Z",
    	"level": 537,
    	"killers": [{
    		"name": "destruction",
    		"player": false,
    		"traded": false,
    		"summon": "a spark"
    	}],
    	"assists": [],
    	"reason": "Died at Level 537 by a spark of destruction."
    }
    
  • Improvement of error responses from the API

    Improvement of error responses from the API

    We need to respond with proper error codes and messages.

    Example scenarios:

    • 404 if the resource is not found (e.g. faulty character name)
    • 429 if the request is being throttled (tibia code is actually 403)
    • 503 if there was some upstream issue
    • and also something when tibia is having maintenance.

    Section that needs to be rewritten/enhanced: https://github.com/TibiaData/tibiadata-api-go/blob/ce26e500e9e611886573ec790eeb4644b6657aa9/src/webserver.go#L679-L691

    This should then also be added to the documentation annotation, so that docs get automatic update too.

A simple api server which can be used as backend of a e-bookstore

BookstoreAPIServer A simple api server which can be used as backend of a e-bookstore. User can get list of books and authors. Details of a book can be

Nov 8, 2022
This library provides a simple framework of microservice, which includes a configurator, a logger, metrics, and of course the handler

Microservice The framework for the creation of microservices, written in Golang. (note: http microservice) Architecture microservice includes: handle

Dec 30, 2022
Tigo is an HTTP web framework written in Go (Golang).It features a Tornado-like API with better performance. Tigo是一款用Go语言开发的web应用框架,API特性类似于Tornado并且拥有比Tornado更好的性能。
Tigo is an HTTP web framework written in Go (Golang).It features a Tornado-like API with better performance.  Tigo是一款用Go语言开发的web应用框架,API特性类似于Tornado并且拥有比Tornado更好的性能。

Tigo(For English Documentation Click Here) 一个使用Go语言开发的web框架。 相关工具及插件 tiger tiger是一个专门为Tigo框架量身定做的脚手架工具,可以使用tiger新建Tigo项目或者执行其他操作。

Jan 5, 2023
Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.
Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.

Ponzu Watch the video introduction Ponzu is a powerful and efficient open-source HTTP server framework and CMS. It provides automatic, free, and secur

Dec 28, 2022
Rest-and-go-master - A basic online store API written to learn Go Programming Language
Rest-and-go-master - A basic online store API written to learn Go Programming Language

rest-and-go(Not maintained actively) A basic online store API written to learn G

Jan 12, 2022
弹弹play 资源搜索节点 API 实现,基于 Cloudflare Workers 或 Golang 的两种实现。 || API implementations for "dandanplay" resource search service.

dandanplay-resource-service API implementations for "dandanplay" resource search service. 弹弹play 资源搜索节点的 API 实现。 提供基于 Cloudflare Workers 和 Golang 的两种实

Dec 5, 2022
REST API made using native Golang libraries. This API resembles the basic working of Instagram.
REST API made using native Golang libraries. This API resembles the basic working of Instagram.

Golang RESTful API for Instagram A Go based REST API built using native libraries. The API has been thoroughly worked through with Postman. Routes inc

Mar 16, 2022
Couper is a lightweight API gateway designed to support developers in building and operating API-driven Web projects
Couper is a lightweight API gateway designed to support developers in building and operating API-driven Web projects

Couper Couper is a lightweight API gateway designed to support developers in building and operating API-driven Web projects. Getting started The quick

Nov 18, 2022
Boilerplate API template includes all the common packages and setup used for API development in this Company

Boilerplate API Boilerplate API template includes all the common packages and setup used for API development in this Company. Development Copy .env.ex

Feb 19, 2022
Best simple, lightweight, powerful and really fast Api with Golang (Fiber, REL, Dbmate) PostgreSqL Database and Clean Architecture

GOLANG FIBER API (CLEAN ARCHITECTURE) Best simple, lightweight, powerful and really fast Api with Golang (Fiber, REL, Dbmate) PostgreSqLDatabase using

Sep 2, 2022
A REST web-service sample project written in Golang using go-fiber, GORM and PostgreSQL

backend A REST web-service sample project written in Golang using go-fiber, GORM and PostgreSQL How to run Make sure you have Go installed (download).

Jan 1, 2023
golang crud restful api with gorm , gin and mysql DB

crud restful api with golang , gorm , gin and mysql this api does a simple CRUD operations on a single table mysql Database . this is build on top off

Feb 26, 2022
Opinionated boilerplate Golang HTTP server with CORS, OPA, Prometheus, rate-limiter for API and static website.
Opinionated boilerplate Golang HTTP server with CORS, OPA, Prometheus, rate-limiter for API and static website.

Teal.Finance/Garcon Opinionated boilerplate HTTP server with CORS, OPA, Prometheus, rate-limiter… for API and static website. Origin This library was

Nov 3, 2022
Example Golang API backend rest implementation mini project Point Of Sale using Gin Framework and Gorm ORM Database.

Example Golang API backend rest implementation mini project Point Of Sale using Gin Framework and Gorm ORM Database.

Dec 23, 2022
Simple REST-API implementation using Golang with several packages (Echo, GORM) and Docker

Simple REST-API Boilerplate This is a simple implementation of REST-API using Golang and several packages (Echo and GORM). By default, I use PostgreSQ

Sep 13, 2022
Kubewrap - kubewrap is an kubernetes command line utility with a focus to explore the kubernetes REST API's leveraging the go libraries available along with golang and cobra packages.

Kubewrap kubewrap is an kubernetes cli wrapper with a focus to explore the kubernetes REST API's leveraging the go libraries available along with gola

Nov 20, 2022
Gin is a HTTP web framework written in Go (Golang).
Gin is a HTTP web framework written in Go (Golang).

Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.

Jan 3, 2023
BANjO is a simple web framework written in Go (golang)

BANjO banjo it's a simple web framework for building simple web applications Install $ go get github.com/nsheremet/banjo Example Usage Simple Web App

Sep 27, 2022