genshindev / api

A fan-made Genshin Impact API for easy access to game data.
https://genshin.jmp.blue
Open Software License 3.0
705 stars 196 forks source link

[Request] Add version identifier to API results #143

Open ddankel opened 2 years ago

ddankel commented 2 years ago

Adding a unique version identifier to the api results (either the root, every index page, or even every result) that incremented whenever data was updated would allow developers to quickly determine if their data is stale. One request to the api root could be used to see if anything changed instead of having to walk through every page and resource to update any cached data.

Example:

// https://api.genshin.dev/
{
  "types": [
    "artifacts",
    "boss",
    "characters",
    "consumables",
    "domains",
    "elements",
    "enemies",
    "materials",
    "nations",
    "weapons"
  ],
  "version": 123.4
}

Alternatively, instead of inserting version to some/all endpoints via middleware, a /version endpoint could be added for this purpose.

The example above uses a version number but it could also be a hash, uuid, datetime, or any other unique value. Something that could be calculated instead of having to be manually updated each release seems preferable. Perhaps use something like node-cache to cache a hash of the assets directory?

mmgfrcs commented 2 years ago

+1

I would recommend having the game version in it, then use the patch version to indicate fixes

Example: v3.0.2 tells me that this data is up to date until game version 3.0, and it is the 2nd revision.