2017 © Pedro Peláez
 

library wikidataquery-api

A lib to interact with the WikidataQuery API

image

ppp/wikidataquery-api

A lib to interact with the WikidataQuery API

  • Thursday, April 7, 2016
  • by Tpt
  • Repository
  • 8 Watchers
  • 2 Stars
  • 2,096 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

WikidataQueryApi

Build Status Code Coverage Scrutinizer Code Quality Dependency Status, (*1)

On Packagist: Latest Stable Version Download count, (*2)

WikidataQueryApi is a small wrapper for the WikidataQuery tool. It only supports a subset of the query syntax., (*3)

Installation

Use one of the below methods:, (*4)

1 - Use composer to install the library and all its dependencies using the master branch:, (*5)

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:, (*6)

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

Example

Here is a small usage example:, (*7)

// 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' ) );
);

The Versions