steamcmd / api

Read-only API interface for steamcmd app_info
https://www.steamcmd.net
MIT License
56 stars 7 forks source link

Add a "cached time" value to the returned JSON object #10

Closed Ortovoxx closed 4 years ago

Ortovoxx commented 4 years ago

Firstly just want to say how great the API is. Been looking for something like this for ages and finally found it! 😄

Would be useful to have a key with a value of a UNIX timestamp showing when the data that has been returned was cached at.

Either this or show how often the data is cached so I can schedule my API calls to only get new data when the cache is refreshed.

jonakoudijs commented 4 years ago

Hi Ortovoxx, thank you for your compliment! I don't monitor or log anything (besides errors) so it's really nice to hear from someone who is using the service and likes it :)

The data is currently not cached (in the API). With every run the local steamcmd cache data is removed to ensure the newest data. Did you encounter cached data that was not up-to-date?

In the future I do want to implement caching and then I will add extra fields to the response that will show info about the cache data, ttl etc.

Ortovoxx commented 4 years ago

You're very welcome I am currently using it to find the build ID of a steam app and then look when it changes to see if the app has been updated ( will result in an increased build ID ).

I have no experienced any errors however I did not realise that the data was no currently cached! After looking at the source I can see that now... Probably should have read it before opening this issue.

If in the future caching is added fields about the cached data would be amazing as well as letting users know how often data is cached so they are not calling too often and getting the same cached data.

I have a project that uses this API and lots of people like the feature that I provide by using this API. Therefore if there is anything I can do to help the maintenance of the API I would be more than willing to help via the odd pull request.

jonakoudijs commented 4 years ago

Cool, that same use case was the reason why I created the API in the first place. Perhaps info about caching should be added to the website but it's probably better to do that when an actual caching system is in place.

Thanks for your offer. You can always help by creating an issue when you encounter a bug/error. Creating a PR to fix an issue would be awesome but just creating an issue helps a lot as well. I want to rewrite the API soon with an existing framework like FastAPI to make it easier to contribute.

Would you share something about the project? What it is and what you are using it for? Purely for my own curiosity and to learn :)

Ortovoxx commented 4 years ago

I have not encountered any errors yet besides the occasional timeout or 503 service unavailable. Although if I ever do I will make sure to create an Issue and see if I can fix it 😄

Personally I have never used FastAPI but I have heard nothing but good things about it from friends.

The project is a Discord bot specifically for the game Rust. The bot is currently still under dev and is getting close to being fully finished but you can find it here if you want to try it out.

I use the API by calling it every ~10 minutes and finding the Build ID and last updated time. Then I check if they have been changed and if they have it sends an update notification on discord to everyone who has it set. I looked for ages for a way to alert people when Rust has an update ( I don't know if you've ever played it but updates mean a forced wipe of all servers so you want to get on asap after an update ). This seems like the best solution at the moment rather than running a docker image of SteamCMD on my own server.

jonakoudijs commented 4 years ago

I have not encountered any errors yet besides the occasional timeout or 503 service unavailable.

I have noticed that as well (as can be seen on the status page) and it's sadly a by-product of the fact that updating the steamcmd can take a while sometimes (and cannot be scheduled or prepared for). My idea is to try to catch it if steamcmd is updating and if so, return a "come back later" response.

That's really cool! Sounds like a nice usage of the API. Thanks for sharing, it means a lot. Keep me updated and feel free to create an issue if you have suggestions or encountered a bug in the future :)