APIs

From Redazione
Jump to navigation Jump to search
Line 33: Line 33:
  
 
==wikipages==
 
==wikipages==
The following endpoint retrieves one or more wiki pages under a specific path. If included among the options, the endpoint returns a structured index (either partial, or of the entire site). Optional data for each page include categories, all the related semantic properties, the detected language, the title structure (to safely parse a title even if it contains a slash) the original page url, and more.
+
The following endpoint retrieves one or more wiki pages under a specific path.  
 +
 
 +
If required, it also returns a structured index related to the set of returned pages, a useful set of data for each page (including the rendered html, categories, all the related semantic properties, the detected language, the original page url, and more), and information on the related organization.
 +
 
 +
It is enough flexible to make possible the [https://culturaitaliana.org/How_it_works front-end site corresponding to this set of pages] (the link points to itself in the eventuality you are already reading herein), which provides server-side rendering, storage of pages and table of contents withing a client-side database, pages navigation, filter of pages based on detected languages, and more: all that using just 2 calls (one server side, and one client side) of the following API !
  
  
Line 101: Line 105:
  
  
Options
+
'''Options'''
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 123: Line 127:
 
|include pages hidden in the [[How it works/Frontend Index]] of a given organization
 
|include pages hidden in the [[How it works/Frontend Index]] of a given organization
 
|}
 
|}
 +
  
 
'''Response example'''
 
'''Response example'''
Line 131: Line 136:
 
   organization: {
 
   organization: {
 
     id: 1,
 
     id: 1,
     name: 'Istituto cultura italiana (NGO)',
+
     name: 'Istituto cultura italiana (NGO)'
    last_edit: '1593265218'
 
 
   },
 
   },
 
   index: [
 
   index: [
Line 156: Line 160:
 
{
 
{
 
       pageid: 135,
 
       pageid: 135,
 +
      index: 0,
 
       title: 'Istituto cultura italiana (NGO)/Posts/December 2018 - Presepe/1',
 
       title: 'Istituto cultura italiana (NGO)/Posts/December 2018 - Presepe/1',
 
       html: '<div class="mw-parser-output"> [page html content] </div>',
 
       html: '<div class="mw-parser-output"> [page html content] </div>',

Revision as of 09:24, 9 July 2020

While you are establishing your organization's page structure at an address like the following

https://culturaitaliana.org/wiki/Centro_italiano_Barcellona

that is structuring all your information optionally using semantic data through this wiki platform, you can start querying your pages (or even all your site) through the following set of APIs, for instance in order to display them in your wordpress site, or in whatever third party site written in any computer language.

The following endpoints do not directly query the standard mediawiki APIs, but an extended APIs built on top of the mediawiki APIs (called autonomously by an internal script which keeps updated all the information) providing additional data, like the detected language for each page, all the semantic data related to each page, the "title structure" (to allow the use of slashes within the title itself, ensuring at the same time the coherence of the hierarchical structure) and more.


Basically, through the following APIs you can query all the information of the created pages or a specific "folder" within it (also retrieving a structured index which can be easily used to create navigation menus, and of course, their html content) without dealing with the complexity and lack of immediacy of the standard mediawiki api, which would require multiple calls and further elaboration to reach that result.


wikipages

The following endpoint retrieves one or more wiki pages under a specific path.

If required, it also returns a structured index related to the set of returned pages, a useful set of data for each page (including the rendered html, categories, all the related semantic properties, the detected language, the original page url, and more), and information on the related organization.

It is enough flexible to make possible the front-end site corresponding to this set of pages (the link points to itself in the eventuality you are already reading herein), which provides server-side rendering, storage of pages and table of contents withing a client-side database, pages navigation, filter of pages based on detected languages, and more: all that using just 2 calls (one server side, and one client side) of the following API !


Example of a GET request

https://culturaitaliana.org/api/wikipages?root_page=Istituto_cultura_italiana_(NGO)&options=data|organization_information|index	

The request queries all the webpages of the organization 'Istituto cultura italiana (NGO)', returns all data of each page, the structured index related to each page of the organization, and will exclude all hidden pages (that is pages unselected within the Frontend Index).


Parameters

keys description values protocol
wiki name of the wiki to be queried. Can be omitted for the public wiki) wiki username POST
title single page to be queried page title (complete path, with or without underscores) POST or GET
root_page a page title to be queried together with all its subpages page title (complete path, with or without underscores) POST or GET
pages A list of page titles which will be served with the full set of page data list of page titles (pipe separated) suggested POST
subpages data Page data to be retrieved for all subpages of the root_page one or more of the following: (pipe separated) html, url, language_detected, form_name, form_data, categories, title_structure, modification_time POST or GET
options Query options (see dedicated table below for a description of each option) one or more of the following: (pipe separated) index, complete_index, data, organization_information, include_hidden POST or GET
organization_id to be used to retrieve all organization pages when the root_page is null (i.e. for private wikis or pages not related to an organization on the public wiki) the id of the organization returned among the "info" by a previous call of this API POST or GET
username only required for private wikis, a username with sysop privileges username POST
password only required for private wikis, the password of related username password POST


Options

parameter description
index retrieve the index related to the provided root_page
complete_index retrieve the complete organization index even if the provided root_page is a subpage of a given organization
data retrieve all page's data
organization_information retrieve organization information (id and name)
include_hidden include pages hidden in the Frontend Index of a given organization


Response example

{
  success: true,
  organization: {
    id: 1,
    name: 'Istituto cultura italiana (NGO)'
  },
  index: [
    {
      id: 281,
      language: '',
      path: 'Istituto cultura italiana (NGO)',
      text: 'Istituto cultura italiana (NGO)',
      children: [],
      state: {"loaded":true,"opened":true,"selected":true,"disabled":false}
    },
    {
      id: 31,
      language: '',
      path: 'Istituto cultura italiana (NGO)/contenuti sito web/abstract',
      text: 'contenuti sito web/abstract',
      children: [],
      state: {"loaded":true,"opened":true,"selected":false,"disabled":false}
    },
    [... other index items]
  ],
  pages: [
{
      pageid: 135,
      index: 0,
      title: 'Istituto cultura italiana (NGO)/Posts/December 2018 - Presepe/1',
      html: '<div class="mw-parser-output"> [page html content] </div>',
      url: 'https://culturaitaliana.org/wiki/Istituto_cultura_italiana_(NGO)/Posts/December_2018_-_Presepe/1',
      language_detected: {"it": "Italian"},
      form_name: 'Article',
      form_data: {},
      categories: ["Articles", "Posts"],
      title_structure: ["Istituto_cultura_italiana_(NGO)","Posts","December 2018 -
 Presepe/1"],
      modification_time: '1585005974'
    }

 [... other pages...]

  ],
  info: {
    last_modification_time: 1585005974,
    detected_languages: {"en": "English","it": "Italian"},
    total_pages: 42
  },
  execution_time: '15ms'
}