HTTP error 503 only for some API requests


#1

Hey,

I want to build a table of the matches for one account via axios (JavaScript).

The problem is: Some requests of the data API work, some not.

My request to get the matches works, the URL looks something like this:

https://open.faceit.com/data/v4/players/a0d61b0a-3255-4269-b042-aa2c68c0fb3e/history?from=1293840000&game=csgo&offset=0&limit=100

I now want to display the matches in a HTML table and show some more information like the result or the players, therefore I use the /matches/{match_id}/stats endpoint.

I loop the matches array and try to add the needed information, one requests looks like this:

https://open.faceit.com/data/v4/matches/1-bc086bd3-3143-4b63-89a9-12372dd691de/stats

So again, some of these requests work fine, but for a lot of them there is a 503 error:

{"errors":[{"message":"The resource is temporarily unavailable. Try again later.","code":"err_g0","http_status":503,"parameters":[]}]}

The weirdest part: The same match sometimes throws an error and sometimes works without problem.

Did I exceed the API rate limit? I tried to use setTimeout(..), but it didn’t help.


#2

Hi SHEIX,
the error code for rate limit exceeded is 429.
Here you’re getting 503, which mean that the resource is temporarily unavailable.
It’s not a persistent error, you should simply retry (few seconds later can be enough) and you will get that resource.

Lorenzo


#3

Hey Lorenzo,

thanks for feedback.

Is that the intended way of using the match endpoint though?

Isn’t there a better way to get match details for the matches endpoint?

I mean, I can just loop over and over the matches array and fetch as long as I got an error
for the match, but that doesn’t feel right. Also it would be a bad idea regarding the rate limit.

Background:

My plan is to create a web application, where users search for their username and see statistics based on their CS:GO matches.

When a user has 500 matches, I have to make 501 requests to the FACEIT API (one for all matches and one for the match details for each match in matches). But I have to retry some of the requests for match details, so its more like 1000 to 1500 per user.

With this approach I exceed the API rate limit after very little page views on my website.

UPDATE:

I created a prototype at https://vaceit.netlify.com/#/, just enter a FACEIT username (e. g. SHEIX) in the search
input and you’ll get directed to the matches table. Open the console before doing so and you will notice a lot of 503 errors.


#4

Hi SHEIX,
there isn’t an endpoint where you can get the multiple stats at once.
There isn’t any endpoint in all the data-api where you can ask for a batch of ids.
Why don’t you simply call the /players/{player_id}/stats/{game_id} endpoint? You can get all the stats of a player!

Few words about the propotype.
First, I saw that you’re using api.faceit.com API, which is not meant to be publicly usable. That endpoints can be changed/removed without notice at any time: be careful on using it, especially if you’re basing some core functionalities of your web app on that…
Then, a personal advice: don’t make useless call. When I search for a player, you call the player’s history endpoint to get ALL the matches. This can lead to a big number of calls, network traffic and waiting time that are almost wasted, as the visitors will (most probably) never look for ALL the past matches.
You should rely on a “lazy loading” approach, showing only e.g. the last 20 matches, then make other calls only if the visitor is really interested on that. Then everything will look lighter and faster :slight_smile:
This is the best approach for every web app…also the FACEIT website is using that approach for every list of items (rankings, player’s matches, tournaments, search results etc).

Have a nice day
Lorenzo


#5

Hey Lorenzo,

thanks a lot for replying and taking the time to look into the prototype.

I don’t need the general stats for a player, I need the match details for the matches of a player.

If you navigate to “MATCHES” on https://vaceit.netlify.com/#/ you can see a table of the selected player’s matches. The issue is the /players/{player_id}/history endpoint: You get a list of the matches (which I’m displaying at the table), but those matches are missing some crucial information (like the played map and the result score of the match), so I have to use the /matches/{match_id}/stats endpoint for that.

I implemented lazy loading for the enemies (navigate to “BANS” on the site), where the next details get loaded on scroll to the bottom, which works fine.

For the table at “MATCHES”, I now implemented that match details (from /matches/{match_id}/stats) only get loaded for the first 100 matches, but still: There is a huge amount of 503 errors, which shouldn’t be the case for 100 requests, right?


#6

Hi,
503 errors are unpredictable and temporarily, you should implement a solution that handle these cases.
Anyway, in my opinion, 100 is still a high amount of matches to show at first load.

Cheers
Lore


#7

Hi,
we made some improvements on data-api, you should notice a lot less 503 errors from today!

Cheers
Lorenzo


#8

It works WAY better now! Thanks a lot for the improvement!


#9

Glad to hear that!

I’ll close this thread now.
Lorenzo


#10