Jump to content
  • Sign Up

API V2 request cache time


XNum.2391

Recommended Posts

Hello, ArenaNet,

I'm pretty new to GW2 API development and my first need/idea is to develop a small script to monitor gems exchange rate, so I could be notified when the rate is in desired intervals (e.g. 400 gems for <100 gold). I figured out how to use https://api.guildwars2.com/v2/commerce/exchange/coins, but the response is very confusing and it seems cached for some time, based on "quantity" param. While in the game the price is fluctuating, API still provides the same value.

 

This is an example of my script execution:

2017-12-23 10:57:09: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:57:09: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

2017-12-23 10:57:19: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:57:19: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

2017-12-23 10:57:29: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:57:29: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

2017-12-23 10:57:40: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:57:40: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

2017-12-23 10:57:50: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:57:50: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

2017-12-23 10:58:00: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:58:00: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

2017-12-23 10:58:10: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:58:10: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

2017-12-23 10:58:20: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:58:20: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

2017-12-23 10:58:30: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:58:30: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

2017-12-23 10:58:40: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:58:40: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

2017-12-23 10:58:50: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:58:50: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

2017-12-23 10:59:00: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:59:00: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

2017-12-23 10:59:11: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:59:11: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

2017-12-23 10:59:21: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:59:21: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

2017-12-23 10:59:31: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:59:31: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

2017-12-23 10:59:41: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:59:41: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

2017-12-23 10:59:51: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

2017-12-23 10:59:51: 100 gems = 25.77.00 400 gems = 103.08.00 800 gems = 103.08.00 1200 gems = 103.08.00 2000 gems = 103.08.00

 

Simply, the response is consistent across all the requests and it might've prolonged the cache time every time the response is done.

 

Just for sake of testing I did a "hack", by randomly changing quantity value, and I started getting different response every 10 seconds:

2017-12-23 11:07:51: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=9876150

2017-12-23 11:07:51: 100 gems = 25.88.00 400 gems = 103.52.00 800 gems = 103.52.00 1200 gems = 103.52.00 2000 gems = 103.52.00

2017-12-23 11:08:01: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=3202565

2017-12-23 11:08:01: 100 gems = 25.82.00 400 gems = 103.28.00 800 gems = 103.28.00 1200 gems = 103.28.00 2000 gems = 103.28.00

2017-12-23 11:08:12: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=8041875

2017-12-23 11:08:12: 100 gems = 25.83.00 400 gems = 103.32.00 800 gems = 103.32.00 1200 gems = 103.32.00 2000 gems = 103.32.00

2017-12-23 11:08:22: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=5033860

2017-12-23 11:08:22: 100 gems = 25.82.00 400 gems = 103.28.00 800 gems = 103.28.00 1200 gems = 103.28.00 2000 gems = 103.28.00

2017-12-23 11:08:32: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=2837578

2017-12-23 11:08:32: 100 gems = 25.81.00 400 gems = 103.24.00 800 gems = 103.24.00 1200 gems = 103.24.00 2000 gems = 103.24.00

2017-12-23 11:08:42: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=2745078

2017-12-23 11:08:42: 100 gems = 25.82.00 400 gems = 103.28.00 800 gems = 103.28.00 1200 gems = 103.28.00 2000 gems = 103.28.00

 

Now, such information is arguably relevant, I can still get some cached responses (depending on RNG :-D), but the result is more or less "closer" to what I see in the game.

 

I understand, that this is not the consistent and reliable way of doing that, while I also understand the need for servers to cache this, but is there any other API or way to get an updated rate within guaranteed interval, so this API gets more useful? Is there any other alternative to get such data from mumble API, for instance?

 

Probably, this may create in-game imbalance for those who may not automate the process of monitoring rate and it's a huge field for hardcore traders to get it more hardcore, but I really want to know what is the potential of this API and how much benefits I can get from developing something that may improve my gameplay a little, using public api.

 

Can I get any information on how fast servers are getting synchronized with api server to decide whether I really want to invest time on that or that's worthless?

Developing something for a game, I play, is just as fun as playing the game itself, so I hope I can get something from that area as well.

 

Thanks!

Link to comment
Share on other sites

Most of the API endpoints uses a cache timer of 5 minutes, i assume it is the same for this endpoint

As for getting it faster, i am not sure it actually matters too much for your usecase, as i don't believe (but don't know) that there are major swings in the gem price that could warrant flipping it. The exchange fees means you need to see large changes before it is profitable. Something that doesn't happen minut to minut

 

Link to comment
Share on other sites

> @"I Am Dansker.7105" said:

> Most of the API endpoints uses a cache timer of 5 minutes, i assume it is the same for this endpoint

> As for getting it faster, i am not sure it actually matters too much for your usecase, as i don't believe (but don't know) that there are major swings in the gem price that could warrant flipping it. The exchange fees means you need to see large changes before it is profitable. Something that doesn't happen minut to minut

>

 

Thank you for reply! There is no any intention of flipping for me, but it gets really tedious to catch the moment when the price is closer to 99 or 98 per 400 gems. It drops for a few seconds and, if you don't monitor it constantly and do not spam TP window, you are likely to miss it. That's not really realtime price updated in the game UI as well, so I was hoping I can improve that with the script, so I don't hit TP in the game every time I do another step. 2g difference (between 98 and 100) can be really noticeable for regular player, especially if you change higher number of gems.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...