2017 © Pedro Peláez
 

library wikidata

A PHP client for working with Wikidata API.

image

jamesfrost/wikidata

A PHP client for working with Wikidata API.

  • Monday, February 27, 2017
  • by JamesFrost
  • Repository
  • 2 Watchers
  • 2 Stars
  • 2,633 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 6 Versions
  • 21 % Grown

The README.md

Wikidata

Wikidata provides a API for searching and retrieving data from wikidata.org., (*1)

Installation

composer require freearhey/wikidata

Usage

$wikidata = new Wikidata;

Search by entity title:, (*2)

$result = $wikidata->search('steve jobs');

Check if no search results, (*3)

if($result->isEmpty()) {
    echo 'no results';
    die();
}

Retrieve first entity in result list, (*4)

$singleResult = $result->first();

Retrieve all results, (*5)

$allResults = $result->get();

Get entity id, (*6)

$entityId = $singleResult->getEntityId(); // Q26

Entities

Get single entity by id:, (*7)

$entities = $wikidata->entities('Q26');

Get single entity with preset language (default: en), (*8)

$entities = $wikidata->entities('Q26', 'fr');

Get few entities by id and more languages, (*9)

$entities = $wikidata->entities('Q26|Q106', 'en|fr|ch');

Retrieve first entity, (*10)

$entity = $entities->first();

Get all entities, (*11)

$entity = $entities->get();

Get single entity by id, (*12)

$entity = $entities->get('Q26');

Get entity label and description (default language: en), (*13)

$label = $entity->getLabel(); // Steve Jobs
$description = $entity->getDescription('de'); // US-amerikanischer Unternehmer, Mitbegründer von Apple Computer

Get entity property values by property id (e.g. P21) if it exists. All list properties you can find here, (*14)

$gender = $entity->getPropertyValues('P21'); // array(1) { [0]=> string(4) "male" }

And with language property (default: en), (*15)

$childs = $entity->getPropertyValues('P40', 'ru'); // array(1) { [0]=> string(35) "Бреннан-Джобс, Лиза" }

That's all., (*16)

License

Wikidata is licensed under the MIT license, (*17)

The Versions

27/02 2017

dev-master

9999999-dev https://github.com/freearhey/wikidata

A PHP client for working with Wikidata API.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Aleksandr Statciuk

php client wikidata

27/02 2017

1.0.2

1.0.2.0 https://github.com/freearhey/wikidata

A PHP client for working with Wikidata API.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Aleksandr Statciuk

php client wikidata

27/10 2016

1.0.1

1.0.1.0 https://github.com/freearhey/wikidata

A PHP client for working with Wikidata API.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Aleksandr Statciuk

php client wikidata

15/08 2016

dev-propertyInfo

dev-propertyInfo https://github.com/freearhey/wikidata

A PHP client for working with Wikidata API.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Aleksandr Statciuk

php client wikidata

09/08 2016

dev-propertySearch

dev-propertySearch https://github.com/freearhey/wikidata

A PHP client for working with Wikidata API.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Aleksandr Statciuk

php client wikidata

09/08 2016

dev-taxonomy

dev-taxonomy https://github.com/freearhey/wikidata

A PHP client for working with Wikidata API.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Aleksandr Statciuk

php client wikidata