PHPackages                             mikespub/survos-wikidata - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. mikespub/survos-wikidata

ActiveLibrary[API Development](/categories/api)

mikespub/survos-wikidata
========================

A PHP client for working with Wikidata API.

6.0.3(2mo ago)02691MITPHPPHP &gt;=8.4

Since Feb 22Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/mikespub-org/survos-wikidata)[ Packagist](https://packagist.org/packages/mikespub/survos-wikidata)[ Docs](https://github.com/mikespub-org/survos-wikidata)[ Fund](https://www.buymeacoffee.com/arhey)[ Fund](https://www.paypal.me/arhey)[ RSS](/packages/mikespub-survos-wikidata/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (20)Used By (1)

[![wikidata](https://raw.githubusercontent.com/maxlath/wikidata-cli/master/assets/wikidata_logo_alone.jpg)](https://wikidata.org)

Wikidata
========

[](#wikidata)

Wikidata provides a API for searching and retrieving data from [wikidata.org](https://www.wikidata.org).

Fork of @todo: consider

This library is no longer used by survos/wiki-bundle, Symfony developers may want to use that directly since it adds caching and more options, and does not relay on illuminate/collections.

Installation
------------

[](#installation)

```
composer require survos/wikidata
```

Usage
-----

[](#usage)

First we need to create an instance of `Wikidata` class and save it to some variable, like this:

```
require_once('vendor/autoload.php');

use Wikidata\Wikidata;

$wikidata = new Wikidata();
```

after that we can use one of the available methods to access the Wikidata database.

Available Methods
-----------------

[](#available-methods)

### `search()`

[](#search)

The `search()` method give you a way to find Wikidata entity by it label.

```
$results = $wikidata->search($query, $lang, $limit);
```

Arguments:

- `$query`: term to search (required)
- `$lang`: specify the results language (default: 'en')
- `$limit`: set a custom limit (default: 10)

Example:

```
$results = $wikidata->search('car', 'fr', 5);

/*
  Collection {
    #items: array:5 [
      0 => SearchResult {
        id: "Q1759802"
        lang: "fr"
        label: "autocar"
        wiki_url: "https://fr.wikipedia.org/wiki/autocar"
        description: "transport routier pouvant accueillir plusieurs voyageurs pour de longues distances"
        aliases: array:1 [
          0 => "car"
        ]
      }
      1 => SearchResult {
        id: "Q224743"
        lang: "fr"
        label: "Car"
        wiki_url: "https://fr.wikipedia.org/wiki/Car"
        description: "page d'homonymie d'un projet Wikimédia"
        aliases: []
      }
      ...
    ]
  }
*/
```

The `search()` method always returns `Illuminate\Support\Collection` class with results. This means you can use all the [methods available](https://laravel.com/docs/5.6/collections#available-methods) in Laravel's Collections.

### `searchBy()`

[](#searchby)

The `searchBy` help you to find Wikidata entities by it properties value.

```
$results = $wikidata->searchBy($propId, $entityId, $lang, $limit);
```

Arguments:

- `$propId`: id of the property by which to search (required)
- `$entityId`: id of the entity (required)
- `$lang`: specify the results language (default: 'en')
- `$limit`: set a custom limit (default: 10)

Example:

```
// List of people who born in city Pomona, US
$results = $wikidata->searchBy('P19', 'Q486868');

/*
  Collection {
    #items: array:10 [
      0 => SearchResult {
        id: "Q92638"
        lang: "en"
        label: "Robert Tarjan"
        wiki_url: "https://en.wikipedia.org/wiki/Robert_Tarjan"
        description: "American computer scientist"
        aliases: array:2 [
          0 => "Robert E. Tarjan"
          1 => "Robert Endre Tarjan"
        ]
      }
      1 => SearchResult {
        id: "Q184805"
        lang: "en"
        label: "Tom Waits"
        wiki_url: "https://en.wikipedia.org/wiki/Tom_Waits"
        description: "American singer-songwriter and actor"
        aliases: []
      }
      ...
    ]
  }
*/
```

The `searchBy()` method always returns `Illuminate\Support\Collection` class with results. This means you can use all the [methods available](https://laravel.com/docs/5.6/collections#available-methods) in Laravel's Collections.

### `get()`

[](#get)

The `get()` returns Wikidata entity by specified ID.

```
$entity = $wikidata->get($entityId, $lang);
```

Arguments:

- `$entityId`: id of the entity (required)
- `$lang`: specify the results language (default: 'en')

Example:

```
// Get all data about Steve Jobs
$entity = $wikidata->get('Q19837');

/*
  Entity {
    id: "Q19837"
    lang: "en"
    label: "Steve Jobs"
    wiki_url: "https://en.wikipedia.org/wiki/Steve_Jobs"
    aliases: array:2 [
      0 => "Steven Jobs",
      1 => "Steven Paul Jobs"
    ]
    description: "American entrepreneur and co-founder of Apple Inc."
    properties: Collection { ... }
  }
*/

// List of all properties as an array
$properties = $entity->properties->toArray();

/*
  [
    "P1006" => Property {
      id: "P1006"
      label: "NTA ID"
      values: Collection {
        #items: array:6 [
          0 => Value {
            id: "Q5593916"
            label: "Grammy Trustees Award"
            qualifiers: Collection {
              #items: array:1 [
                0 => Qualifier {
                  id: "P585"
                  label: "point in time"
                  value: "2012-01-01T00:00:00Z"
                }
              ]
            }
          },
          ...
        ]
      }
    },
    ...
  ]
 */
```

### Upgrade Guide

[](#upgrade-guide)

#### Upgrade to 3.2.\_ from 3.1.\_

[](#upgrade-to-32_-from-31_)

The main changes in the new version have occurred in the way property values are stored. Now each property can have more than one value. In this regard, the attribute `value` in the `Property` object was replaced with the attribute `values`.

Also, values are now presented not as a string, but as an `Value` object. This allowed us to save along with each value not only its string representation but also a list of its `qualifiers`. Detailed information on what `qualifiers` is can be found [here](https://www.wikidata.org/wiki/Help:Qualifiers).

### Testing

[](#testing)

```
vendor/bin/phpunit
```

### Contribution

[](#contribution)

If you find a bug or want to contribute to the code or documentation, you can help by submitting an [issue](https://github.com/survos/wikidata/issues) or a [pull request](https://github.com/freearhey/wikidata/pulls).

### License

[](#license)

Wikidata is licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance83

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 69.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~43 days

Recently: every ~21 days

Total

18

Last Release

85d ago

Major Versions

4.0.0 → 5.0.02024-06-25

5.x-dev → 6.0.02025-11-27

PHP version history (3 changes)4.0.0PHP ^8.2

5.2.2PHP &gt;=8.2

6.0.0PHP &gt;=8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1447115?v=4)[Mike's Pub](/maintainers/mikespub)[@mikespub](https://github.com/mikespub)

---

Top Contributors

[![freearhey](https://avatars.githubusercontent.com/u/7253922?v=4)](https://github.com/freearhey "freearhey (127 commits)")[![tacman](https://avatars.githubusercontent.com/u/619585?v=4)](https://github.com/tacman "tacman (21 commits)")[![mikespub](https://avatars.githubusercontent.com/u/1447115?v=4)](https://github.com/mikespub "mikespub (16 commits)")[![GenieTim](https://avatars.githubusercontent.com/u/8596965?v=4)](https://github.com/GenieTim "GenieTim (4 commits)")[![pat-o](https://avatars.githubusercontent.com/u/6193393?v=4)](https://github.com/pat-o "pat-o (4 commits)")[![jeremytubbs](https://avatars.githubusercontent.com/u/548888?v=4)](https://github.com/jeremytubbs "jeremytubbs (3 commits)")[![mpipet](https://avatars.githubusercontent.com/u/8471706?v=4)](https://github.com/mpipet "mpipet (2 commits)")[![MrKrisKrisu](https://avatars.githubusercontent.com/u/4103693?v=4)](https://github.com/MrKrisKrisu "MrKrisKrisu (2 commits)")[![ThomasBerends](https://avatars.githubusercontent.com/u/1807910?v=4)](https://github.com/ThomasBerends "ThomasBerends (1 commits)")[![JamesFrost](https://avatars.githubusercontent.com/u/6696197?v=4)](https://github.com/JamesFrost "JamesFrost (1 commits)")[![andrei-i-gavrila](https://avatars.githubusercontent.com/u/3754526?v=4)](https://github.com/andrei-i-gavrila "andrei-i-gavrila (1 commits)")

---

Tags

phpclientwikidata

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mikespub-survos-wikidata/health.svg)

```
[![Health](https://phpackages.com/badges/mikespub-survos-wikidata/health.svg)](https://phpackages.com/packages/mikespub-survos-wikidata)
```

###  Alternatives

[kunalvarma05/dropbox-php-sdk

Dropbox PHP API V2 SDK (Unofficial)

3633.0M18](/packages/kunalvarma05-dropbox-php-sdk)[openai-php/symfony

Symfony Bundle for OpenAI

215715.5k3](/packages/openai-php-symfony)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[freearhey/wikidata

A PHP client for working with Wikidata API.

5628.6k](/packages/freearhey-wikidata)[google-gemini-php/symfony

Symfony Bundle for Gemini

149.4k1](/packages/google-gemini-php-symfony)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
