{"id":16894529,"url":"https://github.com/freearhey/wikidata","last_synced_at":"2025-11-09T16:04:47.062Z","repository":{"id":34606522,"uuid":"38554741","full_name":"freearhey/wikidata","owner":"freearhey","description":"A PHP client for working with Wikidata API.","archived":false,"fork":false,"pushed_at":"2024-06-25T19:07:03.000Z","size":119,"stargazers_count":55,"open_issues_count":6,"forks_count":23,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-09T20:07:11.411Z","etag":null,"topics":["wikidata"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/freearhey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://www.paypal.me/arhey","https://www.buymeacoffee.com/arhey"]}},"created_at":"2015-07-05T02:57:44.000Z","updated_at":"2025-02-28T15:23:43.000Z","dependencies_parsed_at":"2024-10-25T18:43:16.487Z","dependency_job_id":"c9d04708-e479-460c-8687-aeedb15f068e","html_url":"https://github.com/freearhey/wikidata","commit_stats":{"total_commits":120,"total_committers":8,"mean_commits":15.0,"dds":"0.14166666666666672","last_synced_commit":"1de495e081f52b6a00f327514ba6c16426af0496"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freearhey%2Fwikidata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freearhey%2Fwikidata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freearhey%2Fwikidata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freearhey%2Fwikidata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/freearhey","download_url":"https://codeload.github.com/freearhey/wikidata/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103872,"owners_count":21048245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["wikidata"],"created_at":"2024-10-13T17:19:03.589Z","updated_at":"2025-11-09T16:04:46.965Z","avatar_url":"https://github.com/freearhey.png","language":"PHP","funding_links":["https://www.paypal.me/arhey","https://www.buymeacoffee.com/arhey"],"categories":[],"sub_categories":[],"readme":"[![wikidata](https://raw.githubusercontent.com/maxlath/wikidata-cli/master/assets/wikidata_logo_alone.jpg)](https://wikidata.org)\n\n# Wikidata [![Build Status](https://travis-ci.org/freearhey/wikidata.svg?branch=master)](https://travis-ci.org/freearhey/wikidata)\n\nWikidata provides a API for searching and retrieving data from [wikidata.org](https://www.wikidata.org).\n\n## Installation\n\n```sh\ncomposer require freearhey/wikidata\n```\n\n## Usage\n\nFirst we need to create an instance of `Wikidata` class and save it to some variable, like this:\n\n```php\nrequire_once('vendor/autoload.php');\n\nuse Wikidata\\Wikidata;\n\n$wikidata = new Wikidata();\n```\n\nafter that we can use one of the available methods to access the Wikidata database.\n\n## Available Methods\n\n### `search()`\n\nThe `search()` method give you a way to find Wikidata entity by it label.\n\n```php\n$results = $wikidata-\u003esearch($query, $lang, $limit);\n```\n\nArguments:\n\n- `$query`: term to search (required)\n- `$lang`: specify the results language (default: 'en')\n- `$limit`: set a custom limit (default: 10)\n\nExample:\n\n```php\n$results = $wikidata-\u003esearch('car', 'fr', 5);\n\n/*\n  Collection {\n    #items: array:5 [\n      0 =\u003e SearchResult {\n        id: \"Q1759802\"\n        lang: \"fr\"\n        label: \"autocar\"\n        wiki_url: \"https://fr.wikipedia.org/wiki/autocar\"\n        description: \"transport routier pouvant accueillir plusieurs voyageurs pour de longues distances\"\n        aliases: array:1 [\n          0 =\u003e \"car\"\n        ]\n      }\n      1 =\u003e SearchResult {\n        id: \"Q224743\"\n        lang: \"fr\"\n        label: \"Car\"\n        wiki_url: \"https://fr.wikipedia.org/wiki/Car\"\n        description: \"page d'homonymie d'un projet Wikimédia\"\n        aliases: []\n      }\n      ...\n    ]\n  }\n*/\n```\n\nThe `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.\n\n### `searchBy()`\n\nThe `searchBy` help you to find Wikidata entities by it properties value.\n\n```php\n$results = $wikidata-\u003esearchBy($propId, $entityId, $lang, $limit);\n```\n\nArguments:\n\n- `$propId`: id of the property by which to search (required)\n- `$entityId`: id of the entity (required)\n- `$lang`: specify the results language (default: 'en')\n- `$limit`: set a custom limit (default: 10)\n\nExample:\n\n```php\n// List of people who born in city Pomona, US\n$results = $wikidata-\u003esearchBy('P19', 'Q486868');\n\n/*\n  Collection {\n    #items: array:10 [\n      0 =\u003e SearchResult {\n        id: \"Q92638\"\n        lang: \"en\"\n        label: \"Robert Tarjan\"\n        wiki_url: \"https://en.wikipedia.org/wiki/Robert_Tarjan\"\n        description: \"American computer scientist\"\n        aliases: array:2 [\n          0 =\u003e \"Robert E. Tarjan\"\n          1 =\u003e \"Robert Endre Tarjan\"\n        ]\n      }\n      1 =\u003e SearchResult {\n        id: \"Q184805\"\n        lang: \"en\"\n        label: \"Tom Waits\"\n        wiki_url: \"https://en.wikipedia.org/wiki/Tom_Waits\"\n        description: \"American singer-songwriter and actor\"\n        aliases: []\n      }\n      ...\n    ]\n  }\n*/\n```\n\nThe `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.\n\n### `get()`\n\nThe `get()` returns Wikidata entity by specified ID.\n\n```php\n$entity = $wikidata-\u003eget($entityId, $lang);\n```\n\nArguments:\n\n- `$entityId`: id of the entity (required)\n- `$lang`: specify the results language (default: 'en')\n\nExample:\n\n```php\n// Get all data about Steve Jobs\n$entity = $wikidata-\u003eget('Q19837');\n\n/*\n  Entity {\n    id: \"Q19837\"\n    lang: \"en\"\n    label: \"Steve Jobs\"\n    wiki_url: \"https://en.wikipedia.org/wiki/Steve_Jobs\"\n    aliases: array:2 [\n      0 =\u003e \"Steven Jobs\",\n      1 =\u003e \"Steven Paul Jobs\"\n    ]\n    description: \"American entrepreneur and co-founder of Apple Inc.\"\n    properties: Collection { ... }\n  }\n*/\n\n\n// List of all properties as an array\n$properties = $entity-\u003eproperties-\u003etoArray();\n\n/*\n  [\n    \"P1006\" =\u003e Property {\n      id: \"P1006\"\n      label: \"NTA ID\"\n      values: Collection {\n        #items: array:6 [\n          0 =\u003e Value {\n            id: \"Q5593916\"\n            label: \"Grammy Trustees Award\"\n            qualifiers: Collection {\n              #items: array:1 [\n                0 =\u003e Qualifier {\n                  id: \"P585\"\n                  label: \"point in time\"\n                  value: \"2012-01-01T00:00:00Z\"\n                }\n              ]\n            }\n          },\n          ...\n        ]\n      }\n    },\n    ...\n  ]\n */\n```\n\n### Upgrade Guide\n\n#### Upgrade to 3.2._ from 3.1._\n\nThe 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`.\n\nAlso, 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).\n\n### Testing\n\n```sh\nvendor/bin/phpunit\n```\n\n### Contribution\n\nIf you find a bug or want to contribute to the code or documentation, you can help by submitting an [issue](https://github.com/freearhey/wikidata/issues) or a [pull request](https://github.com/freearhey/wikidata/pulls).\n\n### License\n\nWikidata is licensed under the [MIT license](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreearhey%2Fwikidata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreearhey%2Fwikidata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreearhey%2Fwikidata/lists"}