Termination API connection issues?

I’m having issues where I can’t seem to get any data from the termination API. If I hit, say, https://online-go.com/termination-api/automatch-stats?ranks=2,3,4,5,6,7,8’ from a web browser, I get CORS errors (annoying, but fine). If I curl that same endpoint, I get back data:

curl 'https://online-go.com/termination-api/automatch-stats?ranks=2,3,4,5,6,7,8' \
  -H 'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1' \
  -H 'Content-Type: application/json' \
  -H 'Referer: http://localhost:5173/'
{"9x9":{"blitz":{"byoyomi":2,"fischer":12},"rapid":{"byoyomi":18,"fischer":49},"live":{"byoyomi":10,"fischer":8},"correspondence":{"byoyomi":0,"fischer":0}},"13x13":{"blitz":{"byoyomi":0,"fischer":0},"rapid":{"byoyomi":7,"fischer":4},"live":{"byoyomi":0,"fischer":0},"correspondence":{"byoyomi":0,"fischer":0}},"19x19":{"blitz":{"byoyomi":0,"fischer":5},"rapid":{"byoyomi":6,"fischer":8},"live":{"byoyomi":0,"fischer":2},"correspondence":{"byoyomi":0,"fischer":0}}}

Bafflingly, if I hit the same endpoint from my iOS app (i.e. not subject to CORS restrictions), it fails, in a way I don’t get good insight into. There are other OGS API endpoints that have CORS restrictions in browser, but work fine for me on iOS — I have no idea why termination-api specifically is failing for me on iOS. Any termination-api endpoint has the same problem.

The fact that a clean CURL works suggests this may be an error on my half of the connection, but it still could be server-side configuration blocking some requests but not others (proxy settings, firewall, etc). I’m curious if anyone else has run into this issue before.

What are you trying to do with automatch via api instead of websocket?

This is the REST endpoint to get historic automatch queue stats, which is how the official OGS client determines whether to render the little grey dots that indicate “this size/speed/time control setting is historically popular for people you can matchmake with, even if there is not someone else looking at this exact moment”

But the termination API is also useful to e.g. batch fetch a group of players (an endpoint that fails for me in the same way), and I’m led to believe is less resource-intensive on the server.

1 Like

I haven’t used this endpoint yet, and haven’t hit this kind of issue, but there’s actually a hook in WeiqiHub that could use these automatch stats.

When I get a chance, I’ll integrate and let you know if i see similar.

1 Like

Hah, this was pure user error. My code runs in an environment where it’s running through a web browser (where CORS would be active by default), but I have infrastructure to swizzle out the browser’s fetch methods (etc) with native HTTP request code that bypasses CORS… unless it isn’t configured properly, which was the case.

Now that I’m now properly running in a non-CORS environment it’s working fine. Which… I still suspect it’s a reasonable third-party dev ask to get CORS enabled for the termination-api, but in the meanwhile, my mystery question of “why am I getting what seem like CORS errors when I shouldn’t?” is resolved.

2 Likes

I know the CORS issue was resolved already, but I did end up adding this. Appreciate the URL pointer!

1 Like

I’m curious, I did something similar but instead of showing the total per section, I just lit it up green when someone matched your parameters and you could match with them. Do people like this more though?

1 Like

I mimic what the official site does — I light up green if someone is actively waiting who you could plausibly match with, and the historic stats are for showing a secondary grey-dot state of “there isn’t anyone waiting for you at this exact moment, but it’s historically popular for your demographic, so you still have a decent chance of finding something quickly if you enter this queue”.

I can’t speak to general userbase opinion, but it makes sense to me to provide the same experience and iconography as the first-party client.

2 Likes

Yeah makes sense what you two are doing since it matches the site. I went this route because it’s more similar to WeiqiHub’s Fox client, and the data happens to be available.

Pro: It’s easier to see how popular the setting is, quantitatively
Con: It’s disappointing to click a setting with “30 players” and still not get a match

1 Like