Chatterino/api

Add rich responses for Wikipedia links

leon-richardt opened this issue · 0 comments

What service do you want support added for?

Wikipedia

Links

  1. https://en.wikipedia.org/wiki/Long_and_short_scales
  2. https://en.wikipedia.org/wiki/Rick_Astley

Thumbnail

Of course, the title should be included in the hover popup. However, the main interest is the extract field in the API response from the endpoint linked below.
Additionally, we could also add the thumbnail picture from the API response. (Note that this is not present for every page.)

Additional information

API endpoint: /page/summary/{title}

Example request:

curl -X GET "https://en.wikipedia.org/api/rest_v1/page/summary/Long_and_short_scales?redirect=false"

Example response:

{
  "type": "standard",
  "title": "Long and short scales",
  "displaytitle": "Long and short scales",
  "namespace": {
    "id": 0,
    "text": ""
  },
  "wikibase_item": "Q725503",
  "titles": {
    "canonical": "Long_and_short_scales",
    "normalized": "Long and short scales",
    "display": "Long and short scales"
  },
  "pageid": 949880,
  "lang": "en",
  "dir": "ltr",
  "revision": "998899957",
  "tid": "9bf4dc90-6f73-11eb-a81b-b5fabaa57223",
  "timestamp": "2021-01-07T15:21:12Z",
  "description": "List of countries using one or several different large-number naming systems for integer powers of ten",
  "description_source": "local",
  "content_urls": {
    "desktop": {
      "page": "https://en.wikipedia.org/wiki/Long_and_short_scales",
      "revisions": "https://en.wikipedia.org/wiki/Long_and_short_scales?action=history",
      "edit": "https://en.wikipedia.org/wiki/Long_and_short_scales?action=edit",
      "talk": "https://en.wikipedia.org/wiki/Talk:Long_and_short_scales"
    },
    "mobile": {
      "page": "https://en.m.wikipedia.org/wiki/Long_and_short_scales",
      "revisions": "https://en.m.wikipedia.org/wiki/Special:History/Long_and_short_scales",
      "edit": "https://en.m.wikipedia.org/wiki/Long_and_short_scales?action=edit",
      "talk": "https://en.m.wikipedia.org/wiki/Talk:Long_and_short_scales"
    }
  },
  "extract": "The long and short scales are two of several naming systems for integer powers of ten which use some of the same terms for different magnitudes.",
  "extract_html": "<p>The <b>long</b> and <b>short scales</b> are two of several naming systems for integer powers of ten which use some of the same terms for different magnitudes.</p>"
}