ppp/wikidataquery-api

A lib to interact with the WikidataQuery API

1.4 2016-04-07 15:04 UTC

README

Build Status Code Coverage Scrutinizer Code Quality Dependency Status

On Packagist: Latest Stable Version Download count

WikidataQueryApi is a small wrapper for the WikidataQuery tool. It only supports a subset of the query syntax.

Installation

Use one of the below methods:

1 - Use composer to install the library and all its dependencies using the master branch:

composer require "ppp/wikidataquery-api":dev-master"

2 - Create a composer.json file that just defines a dependency on version 1.0 of this package, and run 'composer install' in the directory:

{
    "require": {
        "ppp/wikidataquery-api": "~1.0"
    }
}

Example

Here is a small usage example:

// Load everything
require_once( __DIR__ . '/vendor/autoload.php' );

// Initialise HTTP connection
$api = new WikidataQueryApi( 'https://wdq.wmflabs.org/api' );

// Build helper tools
$wikidataQueryFactory = new WikidataQueryFactory( $api );
$simpleQueryService = $wikidataQueryFactory->newSimpleQueryService();

//Do a query that returns a list of ItemId
//This query finds all the children (P40) of Charlemagne (Q3044)
$itemIds = $simpleQueryService->doQuery(
	new ClaimQuery( new PropertyId( 'P17' ), new ItemId( 'Q3044' ) );
);