Page MenuHomePhabricator

Ideas for Action API demo app tutorials
Closed, ResolvedPublic

Description

One of the Google search results for Wikipedia demo apps is the following interesting article: https://medium.freecodecamp.org/building-a-wikipedia-search-engine-project-4d84de3841d2. Something similar to the linked tutorial, here are a few ideas for demo app tutorials that @Martyav and I are planning on developing. All demo app tutorials when completed will be added to Template:API.

1. Editing bot
Demonstrate with the app how to make a bot edit or create a page and get help with repetitive tasks. The edit example will show how to add a template, post welcome message on talk pages, create a wiki table with an external data source or fix spelling error. Manual:Creating_a_bot exists, but the demo app will focus more specifically on Manual:Creating_a_bot#How_does_a_MediaWiki_bot_work and expand it with sample code. API modules to be used: API:Tokens + API:Login + API:Edit.

2. Featured articles reader
Build a feed reader for curated content such as featured articles, picture of the day, in the news, etc shown on most Wikimedia wiki’s homepage. There is an existing draft page from @Spage API:Showing_interesting_content that could be modified/ re-used: T108661.
API modules to be used: action=featuredfeed with params feed=featured for featured articles / feed=potd for picture of the day.

3. Article ideas generator
Suggest articles from Category:Wikipedia_requested_articles that don’t yet exist on English Wikipedia. The first version of this app exists here. It relied on API:Search and a hard-coded list of articles. To expand it, here is what the flow would be like and the modules to be used:
Use API:Categorymembers to get a list of 10 recent articles listed here:Category:Wikipedia_requested_articles.
Use API:Links to get the links on an article and API:Search to check for red links.

4. Nearby places viewer
Show nearby places in a gallery format, with each item containing location title, a little description, a thumbnail image, distance from current location, etc. There could be an option provided to sort the list by distance or pageviews. We could re-use/modify the resources in here:
https://www.mediawiki.org/wiki/API:Geosearch#Example_2:_Search_for_pages_nearby
https://www.mediawiki.org/wiki/API:Showing_nearby_wiki_information

5. Your edit contributions visualization
There are existing apps such as listen.hatnote.com that visualizes real time edits on Wikipedia. But, there isn’t an app yet that one can use to visualize their contributions on Wikipedia. A demo app around this might be interesting to have. We could use API:Usercontribs to get the edit contributions and get help from an external visualization library for the design part.

6. Featured article multiple choice quiz
Users can select from a pool of articles based on language and page category. The first line from a random featured article is displayed, with the title and image obscured. The correct title, and 3 incorrect titles from related articles, are displayed on screen. The user clicks, touches, or types their choice. If they are confused (not all featured articles have great first lines), they can ask for a hint, and get the second line. After they choose, the title and image are revealed, and they can click on any of the titles on screen to visit the page.

Event Timeline

srishakatux triaged this task as Normal priority.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 14 2018, 7:27 PM
Anomie moved this task from Unsorted to Non-Code on the MediaWiki-API board.Dec 14 2018, 7:46 PM
Anomie added a subscriber: Anomie.Dec 14 2018, 8:07 PM

Seems like a good list of ideas.

For #1, you should probably make sure to use assert=user so people running the code have to have configured their credentials so the edit is done as logged-in. And you should mention in the tutorial that most wikis have policies about running bots, such as the English Wikipedia's https://en.wikipedia.org/wiki/Wikipedia:Bot_policy, so hopefully people will be less likely to get blocked for running unauthorized bots.

As for other ideas, I don't have an idea for a topic that would use the feature but it would be good to have a tutorial that uses generators and continuation and batchcomplete as described at https://www.mediawiki.org/wiki/API:Query#Generators_and_continuation. You'd need some idea that involves working through a list of pages (e.g. category members, pages linking to a page, etc) and fetching "continuable" properties of each page (e.g. the links, templates, images, categories, or the like, not stuff like prop=info or pageimages or textextracts that return one thing for each page).

Neat!

For 2 "2. Featured articles reader" I would recommend the use of the REST API (https://en.wikipedia.org/api/rest_v1/#!/Feed/aggregatedFeed) as it minimises the amount of parameters you need to think about it. Even as I look at the APISandbox now, I'm a bit lost with how I get the API to work (https://www.mediawiki.org/wiki/Special:ApiSandbox#action=featuredfeed tells me to add a feed that is not editable) .

From my experience the best kind of tutorials are the really easy to follow ones with very simplistic and understandable output that the developer can share/show off about :). I worry for this reason that 5+6 may be a little ambitious (5 and 6 seem a little more open to interpretation than the others).

If you're feeling brave might I also suggest you do a video walking through these?

You might also want to consider a couple of other ideas:

  1. doing something relating to "page previews" e.g. like this demo: https://github.com/AnandChowdhary/hovercard using https://en.wikipedia.org/api/rest_v1/#!/Page_content/get_page_summary_title
  2. A reading list feature that allows you to add and remove articles (introduces developers to PUT, GET and DELETE and TODO apps are all the rage these days for hack projects) https://en.wikipedia.org/api/rest_v1/#!/Reading_lists/put_data_lists_id)

For 2 "2. Featured articles reader" I would recommend the use of the REST API (https://en.wikipedia.org/api/rest_v1/#!/Feed/aggregatedFeed)

Although that would be outside the scope of this task, as this task is about demo apps for the Action API.

Even as I look at the APISandbox now, I'm a bit lost with how I get the API to work (https://www.mediawiki.org/wiki/Special:ApiSandbox#action=featuredfeed tells me to add a feed that is not editable) .

It appears the extension is not correctly set up for mediawiki.org, as no one has created the messages on-wiki to define the feeds there. It seems easy enough if you try it on enwiki or commons which do have feeds set up.

  1. doing something relating to "page previews" e.g. like this demo: https://github.com/AnandChowdhary/hovercard using https://en.wikipedia.org/api/rest_v1/#!/Page_content/get_page_summary_title
  2. A reading list feature that allows you to add and remove articles (introduces developers to PUT, GET and DELETE and TODO apps are all the rage these days for hack projects) https://en.wikipedia.org/api/rest_v1/#!/Reading_lists/put_data_lists_id)

Both of those are outside the scope of this task too, as they don't use the Action API.

Both of those are outside the scope of this task too, as they don't use the Action API.

A follow up task highlighting our REST APIs would be super interesting though! From my experience not many people know about their existence and they are great APIs to introduce people to the richness our content given their lack of parameters. Is there a parent task better suited for capturing these suggestions?

Re #5, the contribution visualizer: There's this highly thorough tool for viewing contributions currently available (https://xtools.wmflabs.org/ec) -- we could take design inspiration from it, and pare the info displayed down to number of contributions per day, for the purposes of a tutorial on Action API usage.

Update on this task> Tutorials around three demo apps are published:

Also added a new section Tutorials to https://www.mediawiki.org/w/index.php?title=Template:API and linked the tutorials there.

Restricted Application added a subscriber: Liuxinyu970226. · View Herald TranscriptMar 11 2019, 6:52 PM
srishakatux closed this task as Resolved.Wed, Apr 17, 11:47 PM