Viewed   98 times

Is there any way I can access the thumbnail picture of any wikipedia page by using an API? I mean the image on the top right side in box. Is there any APIs for that?



Look at prop=images.

It returns an array of image filenames that are used in the parsed page. You then have the option of making another API call to find out the full image URL, e.g.: action=query&titles=Image:INSERT_EXAMPLE_FILE_NAME_HERE.jpg&prop=imageinfo&iiprop=url

or to calculate the URL via the filename's hash.

Unfortunately, while the array of images returned by prop=images is in the order they are found on the page, the first can not be guaranteed to be the image in the info box because sometimes a page will include an image before the infobox (most of the time icons for metadata about the page: e.g. "this article is locked").

Searching the array of images for the first image that includes the page title is probably the best guess for the infobox image.

Sunday, September 25, 2022

Don't try to use the raw API, instead use a client wrapper. Here's a long list to choose from, all for PHP:

Tuesday, August 16, 2022

Ok, I got the Problem: it must impersonate the User account which have the privilege to access the API scope that I mentioned in program.

So some additional codes must be added as following:

$email = '<email account which could access that api>';
$scope = '';
$apiKey = '<my api key>';
$oAuthId = '<OAuth ID>';
$serviceAcc = '<service account id>';
$keyFileLocation = $_SERVER['DOCUMENT_ROOT']. "/<p12 file>";
$bucketId = '<my bucket id>';
$list = array();

$client = new Google_Client();
$cred = new Google_Auth_AssertionCredentials (

Woooooyaaaaa, another problem solved! time to move up for next problem.

Tuesday, August 23, 2022

It's creating the event in the calendar owned by the service account, if you want to manage it, you have to share the calendar with yourself (!):

$scope = new Google_AclRuleScope();

$rule = new Google_AclRule();

$result = $service->acl->insert('primary', $rule);

Reference: Who owns calendars created by service account via Google Calendar API and how can they be shared?

PS: there's a new version of the PHP client library.

Sunday, November 20, 2022

Wikipedia has an extensive API, which can provide language links information among others. In this particular case, you're looking for api.php?action=query&prop=langlinks&titles=.... See here for example.

Wednesday, October 12, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :