GetUrf
For the Riot Games API Challenge. Fetch URF match data and send to a database.
Data Flow
- Get 5 minute timestamps starting from
1427866500
(forNA
). - Send timestamps to the endpoint
api-challenge-v4.1
to get a list of URF match IDs. - For each match ID, get match data from the endpoint
match-v2.2
. - Transform result (remove unused fields, etc). 4. Create tables for matches, players, bans.
- Save to the database (firebase -> local -> server db).
- Figure out queries to send to site + Visualize (https://github.com/hzoo/urf).
Setup
- io.js:
nvm install 1.6.3 && nvm use 1.6.3
- ES6 with Babel
- MySQL 5.6 (local or server):
apt-get install mysql-server
- Setup a database and name it what you will put in
DB_NAME
. - Add all the tables from
./data/create-tables.js
- Setup a database and name it what you will put in
Create a json file at ./data/config.json
.
{
"LOL_REGION": "LOL-REGION-HERE", // ex: na
"LOL_TOKEN": "LOL-API-TOKEN-HERE",
"DB_HOST": "DB-HOST-HERE", // localhost unless you use a service
"DB_USER": "DB-USER-HERE",
"DB_PASSWORD": "DB-PASSWORD-HERE",
"DB_NAME": "DB-DATABASE-NAME",
"SSL_CA": "blah.pem",
"SSL_CERT": "blah.pem",
"SSL_KEY": "blah.pem"
}
run npm start
Structure
npm start
runsfetch/index.js
- This sets up the database and lolapi wrapper
fetch/fetch-urf-game-ids.js
is run- This specificially fetches the URF matchIds by computing each 5 minute time interval (just add 300 to the timestamp) (starting with some initial value) and continuing to send arrays of matchIds to the database.
fetch/fetch-urf-match-data.js
is run- This fetches the match data and removes data not used and modifies it so the data can be put in the different database tables (matches, players (each game), and bans.
- This was able to continuously run until all the matches were fetched in a region and then I would change the
LOL_REGION
config.
Misc
- Running on Heroku (It's fetches different regions by changing the LOL_REGION config var).
- Database is using Cloud SQL (tested locally).
- It ended up being a lot easier/faster to just work with things I've used before or have some experience with rather than trying to use something new.