Comments (11)
Released 0.8.17, which hasn't removed Static endpoints yet but contains DDragon endpoints (w/ caching, debugging, and basic error-handling which might need to be polished), and new locale
option.
Refer to this for basic usage: https://github.com/cnguy/kayn#ddragon-usage
Closing for now, make new issues as necessary. Sorry for the inconvenience of the deadline! I'll be working on improving it every couple of days.
from kayn.
I've been busy, but I can put in serious DDragon work today (it's simple relatively, although I'm not sure how I will handle the errors yet). I just want the interface for requests to stay roughly the same and so I was thinking about how to handle code reusability. For now, YOLO though, I'll get it to work ASAP plus have tests for refactoring the code later.
from kayn.
So my Request
class is not sufficient (it should also be named to something like RiotAPIRequest
).
DDragon is not "regionated", besides for https://ddragon.leagueoflegends.com/realms/na.json. Instead, the endpoints are separated by locale
and version
as demonstrated here:
http://ddragon.leagueoflegends.com/cdn/8.15.1/data/en_US/champion.json
And so, one approach would be to make the request API's different:
// RiotAPIRequest.js
.region(region)
.query(query)
// DDragonRequest.js
.locale(locale)
.version(version)
And of course, it'd probably help to throw errors when a user tries to do something like
// RiotAPIRequest.js
.locale(locale)
// You can only call `locale` for methods within the `DDragon` namespace!
Basic stub shown here: ad89cfc
edit August 23rd 2018
In hindsight the version/locale stuffs make no sense unless they're optional. Therefore, I either have to make version/locale manual and mandatory, or get the list of versions, cache it, and use that to get the latest version if the user does not provide a version. For locale, it'd just be whatever matches their region I guess? Or just keep it en_Us and let user configure it manually.
from kayn.
That's an awesome job. I can provide help to release this if necessary :)
As there is at least 45 projects built upon your tool, missing the deadline could frustrate some of the developers.
I use this lib as well and I think you're doing a good work.
Let us know if some of the devs using it can give you a hand ;-)
from kayn.
@Ilshidur
Haha I overreacted sorry. It's good to know I'm doing fine, I was just losing a bit of confidence (mostly just worrying) I think since I think I have minor OCD and really want the API to stay consistent and want tests for everything blahblahblah, but be beginner-friendly still and useful without config blahblabhlah.
So I've mostly been working hard at work the past few weeks, but I'm basically 'done' starting today which means I'm grinding kayn
starting this afternoon using the research I've done the past week.
I definitely won't miss the deadline (even though I capitalized it in the post, I'm taking it back). I won't need help for now, but I'll definitely need help later as I start flushing out all the endpoints. I'll ask for help on this issue. :P
Appreciate the help as usual.
What are your thoughts on Static endpoint compatibility? Some cool libs do this (basically use DDragon stuffs as wel as more code to keep the Static namespaces working)
The deadline isn't really too bad considering I have an entire weekend, this Thursday and this Friday (which are relaxing days for me).
I'll update the OP with a checklist with real-time progress of what I'm working on and w/e too at 4:30 PM. I'll be happily caffeinated for a while too.
from kayn.
Note that while Static Data had "regions", DDragon doesn't. Instead, the "resources" are separated by languages. This is important because kayn
Request
has a .region
method.
Example:
https://developer.riotgames.com/static-data.html
http://ddragon.leagueoflegends.com/cdn/6.24.1/data/en_US/champion.json
To get the data I have to firstly hit a link that is regionated like so:
https://ddragon.leagueoflegends.com/realms/na.json
{"n":{"item":"8.15.1","rune":"7.23.1","mastery":"7.23.1","summoner":"8.15.1","champion":"8.15.1","profileicon":"8.15.1","map":"8.15.1","language":"8.15.1","sticker":"8.15.1"},"v":"8.15.1","l":"en_US","cdn":"https://ddragon.leagueoflegends.com/cdn","dd":"8.15.1","lg":"8.15.1","css":"8.15.1","profileiconmax":28,"store":null}
In this case, champion
is version 8.15.1
, and so this link is what I need:
http://ddragon.leagueoflegends.com/cdn/8.15.1/data/en_US/champion.json
I guess .language
could work?
I would still need a way to set a region.
TBH, though, I could just start off by creating a simple DDragon class that just works via manual URL's first, and then wrap around it later.
from kayn.
Added "caching / retries" (cache DDragon urls) to next minor version targets. The way they will be cached is probably going to be similar to how Static data is cached.
e.g.
const kayn = Kayn()({
cacheOptions: {
cache: myCache,
timeToLives: {
useDefault: true,
byGroup: {
// STATIC: 1000 * 60 * 60 * 24 * 30, // cache for a month
DDRAGON: 1000 * 60 * 60 * 24 * 30, // cache for a month
},
byMethod: {
// Cache all available DDragon endpoints for a month,
// but just for this endpoint, make it only a a week.
[METHOD_NAMES.DDRAGON.GET_VERSION_LIST]: 1000 * 60 * 60 * 24 * 7,
},
},
},
})
from kayn.
I think I have a finalized idea of what I want the API to be like (optional version/locale Cache the realms/versions for easier beginner usage, if they don't provide the version on the request), I'm just double-checking if I'm missing something before I go full speed ahead.
// no version? kayn calls the Realm endpoint using the default region
// and then calls this endpoint using the version from that realm data. Also uses 'en_US')
// The Realm is not cached, unless the user has added a cache object
// async func
const championList = await kayn.DDragon.Champion.list()
const championListSG = await kayn.DDragon.Champion.list().version('6.24.1').locale('en_SG')
Hopefully it sounds as god as it does in my head right now
Note that I will probably miss the deadline, but this is still what is planned (in OP as well):
Planned Releases so far (WIP):
next minor version Deprecate static endpoints
next major version Remove static endpoints
next feature version WILL NOT MAKE IT IN TIME FOR DEADLINE
- DDragon support to match static endpoints
- no types fixed YET
- caching / retries
next next minor version
- Rest of Ddragon endpoints (image URLs, etc)
- Typed DDragon support
from kayn.
Added checklist to OP
from kayn.
Just migrated to the new DDragon endpoints. Works like a charm !
However, they inverted the champion's key
and id
fields in DDragon, which broke my code and may probably break other people's code. 😄
from kayn.
@Ilshidur Yeah, I was definitely not on top of things. Should've worked on the Static compatibility too.
from kayn.
Related Issues (20)
- Grab Spell by his id/key
- Match-V5 Support HOT 1
- /typings/index.d.ts(293,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. HOT 3
- v0.9.4 rate limiter may be broken HOT 2
- summoner/v3 endpoint returning forbidden HOT 2
- positional rank endpoints HOT 1
- Positional Rank Endpoints HOT 1
- Positional Ranking Deprecation HOT 2
- Does Kayn respect custom rate limit? HOT 2
- Minor unnecessary import in index.d.ts HOT 5
- Current games issue HOT 9
- RunesReforged Optional Versions HOT 3
- Current LeaguePositions issue HOT 1
- Make the API host configurable HOT 3
- Very slow requests ? HOT 4
- v0.10.1 release doesn't include a prebuilt dist/ directory HOT 2
- RunesReforged bug HOT 2
- Error: Can't resolve 'fs' in 'D:\Programmierung\my-app\node_modules\dotenv\lib' HOT 9
- TFT Ratelimit (Research)
- trying to use diffrent region the default that was placed in the kayn configuration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kayn.