Page MenuHomePhabricator

Barebone JavaScript MW API library for node.js and browsers
Open, Needs TriagePublicFeature

Description

After looking at a number of JavaScript libraries we have implemented, I found most of them either severely lacking or bloated. I would like to gather the requirements here for something that will be useful to all the new services on backend as well as frontend. Even though this code will benefit client-side developers, the library's focus is to make the server side more robust and stable by encouraging more efficient API usage. See also API gold standard.

General

  • Support browsers and node.js
  • User agent identification (policy, etiquette)
  • Handle errors
  • Report warnings
  • Support error and warning message localization (once implemented)
  • Support continuations
  • Support response merging (batchcomplete)
  • Use compression

Bots / backend scripts

  • Support QoS - maxlag, throttling
  • Handle login / session management

Performance

  • Support multiple simultaneous requests over the same connection

Will NOT support

  • specific actions / query commands should not be supported - the API should not wrap each of the hundreds of actions, query lists, props, etc Users should consult API manual directly, with this library providing only the most minimal but mandatory functionality

Event Timeline

Yurik raised the priority of this task from to Needs Triage.
Yurik updated the task description. (Show Details)
Yurik added subscribers: Yurik, GWicke, Krinkle.
Yurik set Security to None.

There's a dozen or so different libs around in the movement for Node.js or the browser. Taking one and improving it to become platform-agnostic, and, if not based on mediawiki.api, to become its replacement seems fine by me.

Having said that, I will note that most of these libraries are quite thin and imho barely justify their own existence. When all they do is take query parameters as a plain object, with a few sensible defaults, one might as well use Fetch (or jQuery.ajax) directly.

On the other hand, if there were to be an API that truly added its own value through removing abstractings and adding convenience with its own object representatins etc, that'd be a thing complex enough to want to have only one implementation of and share.

I'm unsub'ing since I don't plan to work on this myself, and what we have seems simple enough to maintain in its current form. Most of these libs see only one or two changes a year. But, as said, if someone were to put in the work to consolidate or expand this and not make things too complicated in the process, I'd be hapy to see MW adopt that library instead and transition our support to that.

Aklapper changed the subtype of this task from "Task" to "Feature Request".

Hey @Awesome_Aasim, I folded the T301217 task into this one.

Could you share with me what you like about mediawiki.api and what is missing on the list you sent so we could better understand what you are looking for?

Maybe if we have clarity on what is missing in the existing NPM packages we could help them improve.