TibiaData / tibiadata-api-go

TibiaData API written in Golang and deployed in container (version v3 and above).
https://api.tibiadata.com
MIT License
81 stars 28 forks source link

Refactor suggestion: Wrap all responses on a data field #303

Closed 0xDones closed 8 months ago

0xDones commented 9 months ago

The json payload returned by some calls is redundant, for example:

/v4/character/<name>

# Before
{
  "character": {
    "character": {
    ...
    }
}

# After
{
  "data": {
    "character": {
    ...
    }
}

/v4/boostablebosses

# Before
{
  "boostable_bosses": {
    "boostable_boss_list": [
    ]
}

# After
{
  "data": {
    "boostable_bosses": [
    ]
}

It makes more sense to always return a data field with the data we are expecting. This is a step towards standardization of the api responses.

In addition, the information field is irrelevant in most of the cases, the status header would be enough for status code and the api information could have a dedicated endpoint if we want to retrieve this information.

tobiasehlert commented 8 months ago

hello @refl3ction,

Thanks for your suggestion!

The section part instead of data is partly some legacy from earlier versions from TibiaData and could in upcoming versions be changed. And yes, parts could be moved from the information.api section as well to some other endpoint in future as well.

Since this is a breaking change and we just release V4, I'll not add this for now :)

Kind regards, Tobiass