Example 1: Wikipedia

Last updated on
31 January 2024

Wikipedia API

We will use the API Endpoint https://en.wikipedia.org/w/api.php which is documented at https://www.mediawiki.org/wiki/API:Main_page.

Create entity type

  1. go to admin/structure/external-entity-types/add
  2. name: 'Wikipage'
  3. name (plural): 'Wikipedia pages'
  4. on tab 'Field mapping' select Field mapper 'Simple'

Define storage client

  1. Storage client: choose 'Wiki'
  2. endpoint https://en.wikipedia.org/w/api.php
  3. response format choose 'json'
  4. pager settings (no effect as this is overridden by code): 'page', page number, 'pagesize'. number of items per page
  5. list parameters:
    action|query
    list|categorymembers
    cmtitle|Category:Haarlem
    cmlimit|20
    format|json

    Note that the list is currently hardcoded based on pages in a category, you can place the category in cmtitle

  6. single parameters
    action|query
    format|json
    prop|extracts

Fields mapping

  1. map fields (id and title):
    id: pageid
    title: title
  2. Save external entity
  3. Create a body text field
  4. map fields (add body field):
    body > text: extract
    body > text format: +full_html
  5. Save external entity

Verify entities

  1. Check the list of external entities on /wikipage

  2. Check an individual external entity, for example /wikipage/63278

Help improve this page

Page status: No known problems

You can: