You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -48,27 +49,28 @@ This project received a [Wikimedia Project Grant](https://meta.wikimedia.org/wik
48
49
See [CHANGELOG.md](CHANGELOG.md) for version info
49
50
50
51
## Dependencies
51
-
This module uses [JavaScript ES6](https://en.wikipedia.org/wiki/ECMAScript#6th_Edition_-_ECMAScript_2015), which means NodeJS `>= v6.4.0` or not too outdated web browsers.
52
+
* A somewhat modern JS runtime: NodeJS `>= 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))
52
53
53
-
For older version, you can use ES5 [bundles](#download-pre-bundled-files).
54
+
For older JS runtimes, you can use [ES5 bundles from `wikibase-sdk <= v8`](https://github.com/maxlath/wikibase-sdk/tree/v8.1.1#download-pre-bundled-files).
54
55
55
56
## Install
56
-
### as a module
57
-
Install via npm to be able to use the module with `require` (CommonJS) or `import`(ES6 Modules)
57
+
### as an ES module
58
+
Install via npm to be able to use the `import`the module.
58
59
```sh
59
60
npm install wikibase-sdk
60
61
```
62
+
61
63
Then in your javascript:
62
64
```js
63
-
constWBK=require('wikibase-sdk')
65
+
import { WBK} from'wikibase-sdk'
64
66
constwbk=WBK({
65
67
instance:'https://my-wikibase-instan.se',
66
68
sparqlEndpoint:'https://query.my-wikibase-instan.se/sparql'// Required to use `sparqlQuery` and `getReverseClaims` functions, optional otherwise
67
69
})
68
70
```
69
71
The `wdk` object of previous versions of this documentation - from the time this module was bound to wikidata.org only - thus corresponds to the following:
By 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:
88
90
```js
89
-
constwbk=require('wikibase-sdk')({
91
+
import { WBK } from'wikibase-sdk'
92
+
constwbk=WBK({
90
93
instance:'https://my-wikibase-instan.se',
91
94
wgScriptPath:'/some_custom_script_path'
92
95
})
93
96
```
94
97
95
-
### download pre-bundled files
96
-
If you just want to import the lib from an HTML file and don't have a setup that can import with CommonJS or ES6 Modules, you can simply download those pre-bundled files:
98
+
### as an CommonJS module
99
+
Importing with CommonJS `require` is not supported anymore in version `>= v9.0.0`, but can still be done by installing an older version:
See the [corresponding version documentation](https://github.com/maxlath/wikibase-sdk/tree/v8.1.1#download-pre-bundled-files)
116
+
112
117
## Features
113
118
### Wikibase API
114
119
A set of functions to make **read** queries to a Wikibase instance API (see [Wikidata API documentation](https://www.wikidata.org/w/api.php)).
@@ -143,18 +148,16 @@ This library had for primary purpose to serve the needs of the [inventaire](http
143
148
144
149
**Design constraints**
145
150
146
-
*`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, whatever!)
151
+
*`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!)
147
152
* Therefore, it should focus on providing basic, general helper functions most application working with a Wikibase instance would need.
148
153
* Write operations should go into [wikibase-edit](https://github.com/maxlath/wikibase-edit) as it involves working with Wikibase credentials/tokens.
149
-
* General command-line interface tools should go to [wikibase-cli](https://github.com/maxlath/wikibase-cli), very specific ones — [`wikidata-filter`, `import-wikidata-dump-to-couchdb`, and alikes](#see-also) — should get their own modules.
154
+
* 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.
150
155
151
156
## See Also
152
157
*[wikibase-edit](https://github.com/maxlath/wikibase-edit): Edit a Wikibase instance from NodeJS
153
158
*[wikibase-cli](https://github.com/maxlath/wikibase-cli): The command-line interface to Wikibase instances
154
159
*[wikibase-dump-filter](https://npmjs.com/package/wikibase-dump-filter): Filter and format a newline-delimited JSON stream of Wikibase entities
155
-
*[wikidata-subset-search-engine](https://github.com/inventaire/entities-search-engine/tree/wikidata-subset-search-engine): Tools to setup an ElasticSearch instance fed with subsets of Wikidata
156
160
*[wikidata-taxonomy](https://github.com/nichtich/wikidata-taxonomy): Command-line tool to extract taxonomies from Wikidata
157
-
*[import-wikidata-dump-to-couchdb](https://github.com/maxlath/import-wikidata-dump-to-couchdb): Import a subset or a full Wikidata dump into a CouchDB database
0 commit comments