{"id":13555755,"url":"https://github.com/maxlath/wikibase-sdk","last_synced_at":"2025-12-12T03:27:01.415Z","repository":{"id":50221935,"uuid":"30543758","full_name":"maxlath/wikibase-sdk","owner":"maxlath","description":"JS utils functions to query a Wikibase instance and simplify its results","archived":false,"fork":false,"pushed_at":"2025-04-18T18:15:21.000Z","size":2828,"stargazers_count":330,"open_issues_count":17,"forks_count":47,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-05-10T15:41:13.279Z","etag":null,"topics":["api","data","simplify","sparql","wikibase","wikidata"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/maxlath.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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,"zenodo":null},"funding":{"liberapay":"Association_Inventaire"}},"created_at":"2015-02-09T15:54:15.000Z","updated_at":"2025-04-25T20:35:30.000Z","dependencies_parsed_at":"2024-06-18T12:40:06.243Z","dependency_job_id":"aa44d4e9-36c3-41b6-97c6-0f5c5672db9d","html_url":"https://github.com/maxlath/wikibase-sdk","commit_stats":{"total_commits":969,"total_committers":19,"mean_commits":51.0,"dds":0.08565531475748189,"last_synced_commit":"071be5e20beaac71ec832e318a49c5cc00d814d9"},"previous_names":["maxlath/wikidata-sdk"],"tags_count":225,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxlath%2Fwikibase-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxlath%2Fwikibase-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxlath%2Fwikibase-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxlath%2Fwikibase-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxlath","download_url":"https://codeload.github.com/maxlath/wikibase-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518383,"owners_count":22084374,"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":["api","data","simplify","sparql","wikibase","wikidata"],"created_at":"2024-08-01T12:03:23.850Z","updated_at":"2025-12-12T03:26:56.378Z","avatar_url":"https://github.com/maxlath.png","language":"TypeScript","funding_links":["https://liberapay.com/Association_Inventaire"],"categories":["JavaScript","TypeScript","api","data"],"sub_categories":[],"readme":"# wikibase-sdk\n\nJS utils functions to query a [Wikibase](http://wikiba.se) instance and simplify its results\n\nThis package was primarily developed as `wikidata-sdk` but has now being generalized to support any Wikibase instance, [wikidata.org](https://www.wikidata.org) among others, and was thus renamed `wikibase-sdk`.\n\nThis project received a [Wikimedia Project Grant](https://meta.wikimedia.org/wiki/Grants:Project/WikidataJS).\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://wikiba.se\"\u003e\u003cimg height=\"150\" src=\"https://raw.githubusercontent.com/maxlath/wikibase-sdk/main/assets/wikibase.png\" alt=\"wikibase\"\u003e\u003c/a\u003e\n  \u003c!-- yeay hacky margin \\o/ --\u003e\n  \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\n  \u003ca href=\"https://wikidata.org\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/maxlath/wikibase-sdk/main/assets/wikidata.jpg\" alt=\"wikidata\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n[![License](https://img.shields.io/npm/l/wikibase-sdk)](https://opensource.org/licenses/MIT)\n[![npm version](https://img.shields.io/npm/v/wikibase-sdk)](https://www.npmjs.com/package/wikibase-sdk)\n[![Required Node.js version](https://img.shields.io/node/v/wikibase-sdk)](http://nodejs.org)\n[![npm downloads](https://img.shields.io/npm/dw/wikibase-sdk)](https://npm-stat.com/charts.html?package=wikibase-sdk)\n[![code style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)\n[![type definitions](https://img.shields.io/npm/types/wikibase-sdk)](https://www.typescriptlang.org/)\n\n## Summary\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n- [Changelog](#changelog)\n- [Dependencies](#dependencies)\n- [Install](#install)\n  - [as an ES module](#as-an-es-module)\n  - [as an CommonJS module](#as-an-commonjs-module)\n  - [download pre-bundled files](#download-pre-bundled-files)\n- [Features](#features)\n  - [Wikibase API](#wikibase-api)\n  - [Wikibase Query](#wikibase-query)\n  - [General helpers](#general-helpers)\n- [Contributing](#contributing)\n- [See Also](#see-also)\n- [You may also like](#you-may-also-like)\n- [License](#license)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Changelog\nSee [CHANGELOG.md](CHANGELOG.md) for version info\n\n## Dependencies\nNodeJS `\u003e= v12.0.0` or not too outdated web browsers (see [`Object.fromEntries` browser compatibility table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries))\nFor older JS runtimes, you can use [ES5 bundles from `wikibase-sdk \u003c= v8`](https://github.com/maxlath/wikibase-sdk/tree/v8.1.1#download-pre-bundled-files).\n\n## Install\n### as an ES module\nInstall via npm to be able to use the `import` the module.\n```sh\nnpm install wikibase-sdk\n```\n\nThen in your javascript:\n```js\nimport { WBK } from 'wikibase-sdk'\nconst wbk = WBK({\n  instance: 'https://my-wikibase-instan.se',\n  sparqlEndpoint: 'https://query.my-wikibase-instan.se/sparql' // Required to use `sparqlQuery` and `getReverseClaims` functions, optional otherwise\n})\n```\nThe `wdk` object of previous versions of this documentation - from the time this module was bound to wikidata.org only - thus corresponds to the following:\n```js\nimport { WBK } from 'wikibase-sdk'\n\nconst wdk = WBK({\n  instance: 'https://www.wikidata.org',\n  sparqlEndpoint: 'https://query.wikidata.org/sparql'\n})\n```\nFor convenience, and for the sake of retro-compatibility, that same `wdk` object can be obtain directly from the `wikibase-sdk/wikidata.org` package:\n```js\nimport wdk from 'wikibase-sdk/wikidata.org'\n```\n\nBy default `wikibase-sdk` assumes that your Wikibase instance has [`$wgScriptPath`](https://www.mediawiki.org/wiki/Manual:$wgScriptPath) set to `/w`, but if that's not the case, you can set it by passing a `wgScriptPath` parameter:\n```js\nimport { WBK } from 'wikibase-sdk'\nconst wbk = WBK({\n  instance: 'https://my-wikibase-instan.se',\n  wgScriptPath: '/some_custom_script_path'\n})\n```\n\n### as an CommonJS module\nImporting with CommonJS `require` is not supported anymore in version `\u003e= v9.0.0`, but can still be done by installing an older version:\n```sh\nnpm install wikibase-sdk@v8\n```\n\nSee the [corresponding version documentation](https://github.com/maxlath/wikibase-sdk/tree/v8.1.1#as-a-module)\n\n### download pre-bundled files\nPre-bundled files is not supported anymore in version `\u003e= v9.0.0`, but can still be done by pre-bundled files from older versions:\n```sh\nwget https://raw.githubusercontent.com/maxlath/wikibase-sdk/v8.1.1/dist/wikibase-sdk.js\nwget https://raw.githubusercontent.com/maxlath/wikibase-sdk/v8.1.1/dist/wikidata-sdk.js\nwget https://raw.githubusercontent.com/maxlath/wikibase-sdk/v8.1.1/dist/wikibase-sdk.min.js\nwget https://raw.githubusercontent.com/maxlath/wikibase-sdk/v8.1.1/dist/wikidata-sdk.min.js\n```\n\nSee the [corresponding version documentation](https://github.com/maxlath/wikibase-sdk/tree/v8.1.1#download-pre-bundled-files)\n\n## Features\n### Wikibase API\nA set of functions to make **read** queries to a Wikibase instance API (see [Wikidata API documentation](https://www.wikidata.org/w/api.php)).\nFor **write** operations, see [wikibase-edit](http://github.com/maxlath/wikibase-edit).\n\n* **[Search entities](docs/search_entities.md)**\n* **[Get entities](docs/get_entities.md)**\n  * [By ids](docs/get_entities.md#by-ids)\n  * [By id and revision](docs/get_entities.md#by-id-and-revision)\n  * [By Wikipedia titles](docs/get_entities.md#by-wikipedia-titles)\n  * [By other Wikimedia projects titles](docs/get_entities.md#by-other-wikimedia-projects-titles)\n* **[Simplify entities data](docs/simplify_entities_data.md)**\n* **[Get revisions](docs/get_revisions.md)**\n\n### Wikibase Query\nThere are additional functions for Wikibase instances that have a [SPARQL](https://en.wikipedia.org/wiki/SPARQL) Query Service (such as [Wikidata Query](http://query.wikidata.org/) for wikidata.org). SPARQL can be a weird thing at first, but the Wikidata team and community really puts lots of efforts to make things easy with a super rich [Wikidata Query Help](https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/Wikidata_Query_Help) page, [an awesome tool to test you queries and visualize the result](https://query.wikidata.org/), and [lots of examples](https://www.wikidata.org/wiki/Special:MyLanguage/Wikidata:SPARQL_query_service/queries/examples)!\n\n* **[Get JSON from a SPARQL query](docs/sparql_query.md)**\n* **[Simplify results](docs/simplify_sparql_results.md)**\n* **Pre-baked queries**\n  * [Get entities reverse claims](docs/get_entities_reverse_claims.md)\n\n### General helpers\n  * **[Work with ids](docs/general_helpers.md#work-with-ids)**\n  * **[Sitelink helper](docs/general_helpers.md#sitelink-helpers)**\n  * **[Wikibase Time converters](docs/general_helpers.md#wikibase-time-converters)**\n\n## Contributing\n**Context**\n\nThis library had for primary purpose to serve the needs of the [inventaire](https://github.com/inventaire/inventaire) project but extending its capabilities to other needs it totally possible: feel welcome to post your suggestions as issues or pull requests!\n\n**Design constraints**\n\n* `wikibase-sdk` should stay \"small\" and dependency-free, so that a web application can include it in its bundle without paying a too high cost for it. A consequence is that the lib generates URLs where other libs would integrate doing the request and parsing it's response. But that actually feels quite right to do this way: simply generating the URLs let's users free to handle requests as they like (with callbacks, promises, async/await, custom request agent, whatever!)\n* Therefore, it should focus on providing basic, general helper functions most application working with a Wikibase instance would need.\n* Write operations should go into [wikibase-edit](https://github.com/maxlath/wikibase-edit) as it involves working with Wikibase credentials/tokens.\n* General command-line interface tools should go to [wikibase-cli](https://github.com/maxlath/wikibase-cli), very specific ones — [`wikibase-dump-filter` and alikes](#see-also) — should get their own modules.\n\n## See Also\n* [wikibase-edit](https://github.com/maxlath/wikibase-edit): Edit a Wikibase instance from NodeJS\n* [wikibase-cli](https://github.com/maxlath/wikibase-cli): The command-line interface to Wikibase instances\n* [wikibase-dump-filter](https://npmjs.com/package/wikibase-dump-filter): Filter and format a newline-delimited JSON stream of Wikibase entities\n* [wikidata-taxonomy](https://github.com/nichtich/wikidata-taxonomy): Command-line tool to extract taxonomies from Wikidata\n* [Other Wikidata external tools](https://www.wikidata.org/wiki/Wikidata:Tools/External_tools)\n\n## You may also like\n\n[![inventaire banner](https://inventaire.io/public/images/inventaire-brittanystevens-13947832357-CC-BY-lighter-blue-4-banner-500px.png)](https://inventaire.io)\n\nDo you know [Inventaire](https://inventaire.io/)? It's a web app to share books with your friends, built on top of Wikidata! And its [libre software](http://github.com/inventaire/inventaire) too.\n\n## License\n[MIT](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxlath%2Fwikibase-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxlath%2Fwikibase-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxlath%2Fwikibase-sdk/lists"}