GithubHelp home page GithubHelp logo

retroachievements / api-js Goto Github PK

View Code? Open in Web Editor NEW
41.0 10.0 7.0 566 KB

The official JavaScript library for getting achievement, user, and game data from RetroAchievements.

Home Page: https://api-docs.retroachievements.org

License: MIT License

TypeScript 99.00% JavaScript 0.92% Shell 0.09%
achievements javascript nodejs retroachievements typescript

api-js's People

Contributors

dependabot[bot] avatar devnoot avatar falsepopsky avatar luchaos avatar mccxiv avatar minhaferzz avatar wescopeland avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api-js's Issues

Build demo webapp

Use T3 stack for this. Create a dummy account on RA for a web API key, don't ask users to enter their own. Embed the API key directly into the bundle.

Flow will look like:

  • Have users enter a username.
  • Display a bunch of stats about masteries, rarest achievement, rarest mastery, and some kind of line charts.
  • Be sure URLs are shareable.

Flesh out the README.md file

Stuff to include:

  • Bullet point list of features
  • Stickers for codeclimate & coverage
  • all-contributors
  • Function docs with links to Docusaurus
  • Projects using (?)
  • Include a "why use it" detailing a migration path from v1 to v2
  • Developer setup from POV of someone who doesn't know TypeScript

v1 -> v2 migration path

Consumers need to be able to upgrade from v1 to v2 of the library with as little friction and as good DX as possible.

After chewing on this for a little bit, here is how I think the migration could best work:

/** v1 (today) **/
import { getUserSummary } from "@retroachievements/api"
const userSummary = await getUserSummary(...);

/** v2 (upgrade path) **/
import { getUserSummary, unsafe_getUserSummary } from "@retroachievements/api"

// same name as in v1, but is now reimplemented with the new v2 API
const userSummary = await getUserSummary(...);

// this is deprecated and will be removed after a few months, but still uses the old unsafe functions
// that are shipping with v1 of this library. this is a fallback in case something goes wrong.
// users are required to type "unsafe" so they explicitly know this is a dangerous action.
const legacyUserSummary = await unsafe_getUserSummary(...);

This keeps us from having an AngularJS -> Angular 2 kind of situation. Users will bump their major release of this package from 1.x to 2.x and see no breaking changes, as the exports and their arguments/return types will all remain the same.

Internally, getUserSummary of v2 will make whatever new calls are required to "re-implement" the old getUserSummary() function. From the outside, it will behave exactly the same as v1's getUserSummary(). However, internally it is making the new v2 API calls.

@luchaos

Library should give a clear message on 503 errors.

Currently the API is giving 503 errors. However when calling functions in the library such as
const consoleIds = await ra_api.getConsoleIds(authorization);

The code throws an unhelpful error

SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse (<anonymous>) at parseJSONFromBytes (node:internal/deps/undici/undici:6571:19) at successSteps (node:internal/deps/undici/undici:6545:27) at node:internal/deps/undici/undici:1211:60 at node:internal/process/task_queues:140:7 at AsyncResource.runInAsyncScope (node:async_hooks:203:9) at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

I also believe this doesn't include the HTTP status code. The problem comes in that call doesn't appear to parse the response before running the code through the JSON parser, and thus errors in an unhelpful manner..

I'd be willing to take a crack at writing a fix for this, this weekend if that would be ok, though if there's a suggestion on what you would prefer the API should throw/return/report, that would be appreciated, and which error codes should be handled.

ℹ️ 503 Errors & Site API Status

The following endpoint functions have been temporarily disabled server-side:

  • getGameInfoAndUserProgress()
  • getUserRecentlyPlayedGames()
  • getUserSummary()

There is ongoing work to restore the functionality of these endpoints, and it is currently the top priority of the web team.

A roadmap was posted recently by @luchaos here:

[✅ DONE] Optimization Release 1:
deploy v3

[✅ DONE] Optimization Release 2:
import prepared dumps for data up to february 1st
write/finish all async aggregation tasks (some of it has been prepared) to sync remaining data since february 1st
run sync tasks until all data is up to date in old and new schemas

[✅ DONE] Optimization Release 3:
refactor to double write to old and new schemas
rewrite existing queries to use new schemas/denormalized data
turn off sync tasks

[✅ DONE] Optimization Release 4:
reactivate all APIs
remove double writes
remove legacy schemas and code

Hook up Codeclimate

Blocker: this will depend on the project no longer being set to private.

Ideally, this repo becomes public when 1.0.0-rc.0 is published to npm.

API_GetGameExtended - The achievements object should return badgeURL

In order to save on multiple API requests per page, it would be beneficial to return the Achievement BadgeURL property on the Achievement object that is returned from the GameExtended endpoint.

Ideally API_GetGameInfoAndUserProgress would get this as well.

Is there a reason this is not included?

Publish Vitepress site

  • Document every function and response
  • Document how to authenticate
  • Deploy to Vercel
  • Reach out to the Docusaurus team wrt Algolia search
  • Be sure analytics are hooked up (cc @luchaos)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.