You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

api.md 5.5 kB

4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # Enka.Network - API
  2. ## Game API Docs
  3. - [Genshin Impact](docs/gi/api.md)
  4. - [Zenless Zone Zero](docs/zzz/api.md)
  5. ## Getting Started
  6. You can utilize some wrappers made by other people, or use the API directly. It's very simple, so it is not hard at all to hand-roll your own data logic based on the responses. The biggest challenge is navigating the datamined game data and attaching it to the data returned in the right way.
  7. See [Wrappers](#wrappers) for the language of your choice.
  8. ## Before You Request
  9. A couple of rules on using the API:
  10. 1. Please don't try to enumerate UIDs or try to do massive query jobs in an effort to fill a database. There are hundreds of millions of UIDs and you simply won't be able to do this through this API. I may provide batch data at a later point.
  11. 2. Please set a custom `User-Agent` header with your requests so I can track them better and help you if needed.
  12. 3. There are dynamic ratelimits on UID endpoints - if you're requesting too fast, you'll run into slower response times and eventually a 429 return code. This mean you either need to slow down or contact me to see if it's possible to increase the ratelimits for you. In most cases it's not needed and is a result of unoptimized code.
  13. 4. On this note, all UID requests return a `ttl` field - this field is "seconds until the next Showcase request will be made for this UID". Until it runs out, the endpoint will return cached data, but you will still consume your ratelimit if you repeatedly hit it. Try to either cache the data with a timeout of `ttl` upon request, or prevent requests to the UID until its `ttl` runs out. I recommend Redis for this.
  14. If you have difficulties working with the data, hop on the [Discord server](https://discord.gg/PcSZr5sbn3) for help.
  15. ## List of APIs
  16. ### UID endpoints
  17. #### Get Showcase data with full player info
  18. > https://enka.network/api/uid/618285856/
  19. The response will contain `playerInfo` and `avatarInfoList`. `playerInfo` is the basic data about the game account. If `avatarInfoList` is missing, that means the Showcase of this account is either closed or not populated with characters.
  20. #### Get only player info
  21. > https://enka.network/api/uid/618285856/?info
  22. By attaching `?info` to the request, you are requesting only `playerInfo`. The main request always tries to get `avatarInfoList` as well; if you only need `playerInfo`, please use this endpoint - it will be much faster than getting the full data.
  23. In addition, both responses will contain an `owner` object if:
  24. 1. The user has an account on the site
  25. 2. The user added their UID to the profile
  26. 3. The user verified it
  27. 4. The user set its visibility to "public"
  28. More info on user accounts below.
  29. #### HTTP response codes
  30. Please make sure to handle these in your app appropriately.
  31. ```
  32. 400 = Wrong UID format
  33. 404 = Player does not exist (MHY server said that)
  34. 424 = Game maintenance / everything is broken after the game update
  35. 429 = Rate-limited (either by my server or by MHY server)
  36. 500 = General server error
  37. 503 = I screwed up massively
  38. ```
  39. ### Profile endpoints
  40. It is possible to create an account (profile) on the website and attach several game accounts to it. The users are then required to verify that the account belongs to them via a verification code placed in their signature - this way we can ensure the account belongs to them.
  41. Users can "snapshot" builds under custom names, referred as "saved builds".
  42. > https://enka.network/api/profile/Algoinde/
  43. Gets the user info.
  44. > https://enka.network/api/profile/Algoinde/hoyos/
  45. Gets a list of "hoyos" - Genshin accounts and their metadata. This only returns accounts that are `verified` and `public` (users can hide accounts; unverified accounts are hidden by default). Each key in the response is a unique identifier of a hoyo which you need to use for the subsequent requests to actually get the characters/builds information.
  46. > https://enka.network/api/profile/Algoinde/hoyos/4Wjv2e/
  47. Returns metadata for a single hoyo.
  48. > https://enka.network/api/profile/Algoinde/hoyos/4Wjv2e/builds/
  49. Returns saved builds for a given hoyo. This is an object of arrays, where the key is `avatarId` of the character, and objects in arrays are different builds for a given character, in no particular order (but they do have an `order` field you need to order by for display).
  50. If a build has a `live: true` field, that means it's not a "saved" build, but simply what was fetched from their showcase when they clicked "refresh". When refreshed, all old `live` builds are gone and new ones are created. Only the user decides when to perform this refresh - this data will NOT be up-to-date.
  51. As outlined in [UID endpoints](#uid-endpoints), when you make a UID request, you could get an `owner` object. You can construct the URL using these fields in the object:
  52. `https://enka.network/api/profile/{owner.username}/hoyos/{owner.hash}/builds/`
  53. ## Wrappers
  54. TS/JS - https://www.npmjs.com/package/enkanetwork.js - [Jelosus1](https://github.com/Jelosus2)
  55. TS/JS - https://github.com/yuko1101/enka-network-api - [yuko1101](https://github.com/yuko1101)
  56. Rust - https://github.com/eratou/enkanetwork-rs - [eratou](https://github.com/eratou)
  57. Python - https://github.com/mrwan200/enkanetwork.py - [mrwan200](https://github.com/mrwan200)
  58. Python - https://github.com/seriaati/enka-py - [seriaati](https://github.com/seriaati)
  59. Java - https://github.com/kazuryyx/EnkaNetworkAPI - [kazury](https://github.com/kazuryyx)