bricefrisco / NamesLoL

NamesLoL: Find expiring League of Legends names.
https://www.nameslol.com
14 stars 0 forks source link

Public API #20

Open Infinitay opened 1 year ago

Infinitay commented 1 year ago

Would you be open to providing a public API? It would make it so much easier to keep track of accounts via Google Sheets and you also handle the caching if I'm not mistaken from a brief skim through the code.

bricefrisco commented 1 year ago

I could expose a public API, but it would only be for the name list.

There is already an official Riot API for summoner names, the docs are here: https://developer.riotgames.com/apis#summoner-v4/GET_getBySummonerName

This endpoint returns a revisionDate, which I then feed into this function, calcAvailabilityDate: https://github.com/bricefrisco/NamesLoL/blob/master/src/libs/mapper.ts#L6

An API for an individual summoner name could be simplified to the following, hopefully this helps:

const fetchExpirationDate = async (name, token) => {
  const res = await fetch(`https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/${name}`, {
      headers: {
        'X-Riot-Token': token
      }
  });

  const { revisionDate, summonerLevel } = await res.json();
  const nameDecayInMonths = Math.min(30, Math.max(6, summonerLevel));

  const expirationDate = new Date(revisionDate);
  expirationDate.setMonth(expirationDate.getMonth() + nameDecayInMonths);
  return expirationDate;
}
Infinitay commented 1 year ago

Oh I wasn't aware their API was available so readily, I should have done a Google Search before requesting you to make your API public. I'll go ahead and do this. Thank you.

EDIT: Oh, completely missed the development key is temporary for 24 hours and you still need to apply which I wasn't trying to deal with. Although I suppose I have no option but to wait to apply after Jan 3rd (they suspended apps).

Also, personally I was more interested in using your endpoint for specific names, but having your name list would not be a bad idea.

Side note, what are your thoughts on making a statics page using your data? For example, estimated owned accounts, estimated active accounts, etc. I know it's limited, but seeing as you have the data, would be interesting.

bricefrisco commented 1 year ago

Oh I wasn't aware their API was available so readily, I should have done a Google Search before requesting you to make your API public. I'll go ahead and do this. Thank you.

EDIT: Oh, completely missed the development key is temporary for 24 hours and you still need to apply which I wasn't trying to deal with. Although I suppose I have no option but to wait to apply after Jan 3rd (they suspended apps).

Also, personally I was more interested in using your endpoint for specific names, but having your name list would not be a bad idea.

Side note, what are your thoughts on making a statics page using your data? For example, estimated owned accounts, estimated active accounts, etc. I know it's limited, but seeing as you have the data, would be interesting.

A bit of a late response here, but I will be working on making a public API in the next month or so. The public API will have rate limits similar to that of Riots, so it will be pointless to use it for the sole purpose of bypassing Riot's rate limits. But, it may be useful in other legitimate use-cases.