The WikiWho class wraps the WikiWho API and WikiWho Edit Persistence API requests into functions, through the api
attribute (WikiWhoAPI
class).
The api
attribute of the WikiWho
class contains all the functions to call the APIs.
from wikiwho_wrapper import WikiWho
ww = WikiWho(lng='en')
The method all_content()
corresponds to the following requests:
GET /all_content/{article_title}/
GET /all_content/{article_id}/
Internally, the method will discern by the two call depending on the type first parameter (str
for article_title
and int
for article_id
)
ww.api.all_content("Bioglass_45S5")
*You can also use all the parameters of the WikiWho API*
The method rev_ids_of_article()
corresponds to the following requests:
GET /rev_ids/{article_title}/
GET /rev_ids/page_id/{page_id}/
As in the previous case, *You can also use all the parameters of the WikiWho API*
ww.api.rev_ids_of_article(article='Bioglass_45S5')
In this case, there are three methods that match the 5 different requests:
last_rev_content()
:
GET /rev_content/{article_title}/
GET /rev_content/page_id/{page_id}/
specific_rev_content_by_rev_id()
:
GET /rev_content/{article_title}/{rev_id}/
GET /rev_content/rev_id/{rev_id}
range_rev_content_by_article_title()
:
GET /rev_content/{article_title}/{start_rev_id}/{end_rev_id}/
As in the previous case, *You can also use all the parameters of the WikiWho API*
ww.api.range_rev_content_by_article_title(article='Bioglass_45S5', start_rev_id=18064039, end_rev_id=207995408)
In this case, there is one method that match the 3 different requests:
edit_persistence()
:
GET /editor/{editor_id}/
GET /page/{page_id}/
GET /page/editor/{page_id}/{editor_id}/
As in the previous case, *You can also use all the parameters of the WikiWho Edit Persistence API*
ww.api.edit_persistence(page_id=2161298)
Although in the WikiWho API, there are 9 types of requests, the wrapper reduces it to 5 functions (3 to 1 in the case of the WikiWho Edit Persistence API) by exploting the fact that a lot of these requests only vary in the type of the paramater for the page, i.e. id(int
) or title(str
):
Here is the complete list of functions fo the WikiWho API:
all_content()
rev_ids_of_article()
last_rev_content()
specific_rev_content_by_rev_id()
range_rev_content_by_article_title()
And, for the WikiWho Edit Persistence API, we only have one function
edit_persistence()
Although, the JSON format of this request is useful for certain tasks that involves extracting detailed information, in many occasions you may prefer to work with a table representation of the date. The next part of the tutorial will show you that you can get the a pandas DataFrame instead, by using the DataView.
from utils.notebooks import get_next_notebook
from IPython.display import HTML
try:
display(HTML(f'<a href="{get_next_notebook()}" target="_blank">Go to next workbook</a>'))
except:
HTML('<a href="2. Getting Dataframes (DataView).ipynb" target="_blank">Go to next workbook</a>')