@wmde/wikibase-rest-api

1.1.19 • Public • Published

@wmde/wikibase-rest-api

This is an auto-generated Wikibase REST API client library using the API’s OpenAPI document. It is generated via OpenAPITools/openapi-generator and WMDE does not provide any guarantees about the library functionality.

Usage

The snippet below shows a basic usage example. Setting the User-Agent header is required unless the API client is being used in a client-side (browser) context. It should be configured according to the Wikimedia User-Agent policy.

import { ApiClient, LabelsApi } from '@wmde/wikibase-rest-api';

const apiClient = new ApiClient( 'https://www.wikidata.org/w/rest.php/wikibase' );
apiClient.defaultHeaders = { 'User-Agent': '[custom user agent]' };

console.log( await new LabelsApi( apiClient ).getItemLabel( 'Q1', 'en' ) );

Below you can find the automatically generated documentation:

WmdeWikibaseRestApi - JavaScript client for @wmde/wikibase-rest-api OpenAPI definition of Wikibase REST API This SDK is automatically generated by the OpenAPI Generator project:

Installation

For Node.js

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install @wmde/wikibase-rest-api --save

Finally, you need to build the module:

npm run build
Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

To use the link you just defined in your project, switch to the directory you want to use your @wmde/wikibase-rest-api from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

Finally, you need to build the module:

npm run build

git

If the library is hosted at a git repository, e.g.https://github.com/GIT_USER_ID/GIT_REPO_ID then install it via:

    npm install GIT_USER_ID/GIT_REPO_ID --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

var WmdeWikibaseRestApi = require('@wmde/wikibase-rest-api');


var api = new WmdeWikibaseRestApi.AliasesApi()
var itemId = "Q24"; // {String} The ID of the required Item
var languageCode = "en"; // {String} The requested resource language
var addItemAliasesInLanguageRequest = {"aliases":["JD"],"tags":[],"bot":false,"comment":"Add English alias"}; // {AddItemAliasesInLanguageRequest} Payload containing a list of Item aliases in the specified language and edit metadata
var opts = {
  'ifNoneMatch': ["null"], // {[String]} Conditionally perform the request only if the resource has been modified since the specified entity revision numbers
  'ifModifiedSince': "Sat, 06 Jun 2020 16:38:47 GMT", // {String} Conditionally perform the request only if the resource has been modified after the specified date
  'ifMatch': ["null"], // {[String]} Conditionally perform the request only if the resource has not been modified since one of the specified entity revision numbers
  'ifUnmodifiedSince': "Sat, 06 Jun 2020 16:38:47 GMT", // {String} Conditionally perform the request only if the resource has not been modified after the specified date
  'authorization': "Bearer mF_9.B5f-4.1JqM" // {String} Make authenticated request using a provided bearer token
};
api.addItemAliasesInLanguage(itemId, languageCode, addItemAliasesInLanguageRequest, opts).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Documentation for API Endpoints

All URIs are relative to https://wikibase.example/w/rest.php/wikibase

Class Method HTTP request Description
WmdeWikibaseRestApi.AliasesApi addItemAliasesInLanguage POST /v1/entities/items/{item_id}/aliases/{language_code} Create / Add an Item's aliases in a specific language
WmdeWikibaseRestApi.AliasesApi addPropertyAliasesInLanguage POST /v1/entities/properties/{property_id}/aliases/{language_code} Create / Add a Property's aliases in a specific language
WmdeWikibaseRestApi.AliasesApi getItemAliases GET /v1/entities/items/{item_id}/aliases Retrieve an Item's aliases
WmdeWikibaseRestApi.AliasesApi getItemAliasesInLanguage GET /v1/entities/items/{item_id}/aliases/{language_code} Retrieve an Item's aliases in a specific language
WmdeWikibaseRestApi.AliasesApi getPropertyAliases GET /v1/entities/properties/{property_id}/aliases Retrieve a Property's aliases
WmdeWikibaseRestApi.AliasesApi getPropertyAliasesInLanguage GET /v1/entities/properties/{property_id}/aliases/{language_code} Retrieve a Property's aliases in a specific language
WmdeWikibaseRestApi.AliasesApi patchItemAliases PATCH /v1/entities/items/{item_id}/aliases Change an Item's aliases
WmdeWikibaseRestApi.AliasesApi patchPropertyAliases PATCH /v1/entities/properties/{property_id}/aliases Change a Property's aliases
WmdeWikibaseRestApi.DescriptionsApi deleteItemDescription DELETE /v1/entities/items/{item_id}/descriptions/{language_code} Delete an Item's description in a specific language
WmdeWikibaseRestApi.DescriptionsApi deletePropertyDescription DELETE /v1/entities/properties/{property_id}/descriptions/{language_code} Delete a Property's description in a specific language
WmdeWikibaseRestApi.DescriptionsApi getItemDescription GET /v1/entities/items/{item_id}/descriptions/{language_code} Retrieve an Item's description in a specific language
WmdeWikibaseRestApi.DescriptionsApi getItemDescriptionWithFallback GET /v1/entities/items/{item_id}/descriptions_with_language_fallback/{language_code} Retrieve an Item's description in a specific language, with language fallback
WmdeWikibaseRestApi.DescriptionsApi getItemDescriptions GET /v1/entities/items/{item_id}/descriptions Retrieve an Item's descriptions
WmdeWikibaseRestApi.DescriptionsApi getPropertyDescription GET /v1/entities/properties/{property_id}/descriptions/{language_code} Retrieve a Property's description in a specific language
WmdeWikibaseRestApi.DescriptionsApi getPropertyDescriptionWithFallback GET /v1/entities/properties/{property_id}/descriptions_with_language_fallback/{language_code} Retrieve a Property's description in a specific language, with language fallback
WmdeWikibaseRestApi.DescriptionsApi getPropertyDescriptions GET /v1/entities/properties/{property_id}/descriptions Retrieve a Property's descriptions
WmdeWikibaseRestApi.DescriptionsApi patchItemDescriptions PATCH /v1/entities/items/{item_id}/descriptions Change an Item's descriptions
WmdeWikibaseRestApi.DescriptionsApi patchPropertyDescriptions PATCH /v1/entities/properties/{property_id}/descriptions Change a Property's descriptions
WmdeWikibaseRestApi.DescriptionsApi replaceItemDescription PUT /v1/entities/items/{item_id}/descriptions/{language_code} Add / Replace an Item's description in a specific language
WmdeWikibaseRestApi.DescriptionsApi setPropertyDescription PUT /v1/entities/properties/{property_id}/descriptions/{language_code} Add / Replace a Property's description in a specific language
WmdeWikibaseRestApi.ItemSearchApi simpleItemSearch GET /v0/search/items [WIP] Simple Item search by label and aliases
WmdeWikibaseRestApi.ItemsApi addItem POST /v1/entities/items Create a Wikibase Item
WmdeWikibaseRestApi.ItemsApi getItem GET /v1/entities/items/{item_id} Retrieve a single Wikibase Item by ID
WmdeWikibaseRestApi.ItemsApi patchItem PATCH /v1/entities/items/{item_id} Change a single Wikibase Item by ID
WmdeWikibaseRestApi.LabelsApi deleteItemLabel DELETE /v1/entities/items/{item_id}/labels/{language_code} Delete an Item's label in a specific language
WmdeWikibaseRestApi.LabelsApi deletePropertyLabel DELETE /v1/entities/properties/{property_id}/labels/{language_code} Delete a Property's label in a specific language
WmdeWikibaseRestApi.LabelsApi getItemLabel GET /v1/entities/items/{item_id}/labels/{language_code} Retrieve an Item's label in a specific language
WmdeWikibaseRestApi.LabelsApi getItemLabelWithFallback GET /v1/entities/items/{item_id}/labels_with_language_fallback/{language_code} Retrieve an Item's label in a specific language, with language fallback
WmdeWikibaseRestApi.LabelsApi getItemLabels GET /v1/entities/items/{item_id}/labels Retrieve an Item's labels
WmdeWikibaseRestApi.LabelsApi getPropertyLabel GET /v1/entities/properties/{property_id}/labels/{language_code} Retrieve a Property's label in a specific language
WmdeWikibaseRestApi.LabelsApi getPropertyLabelWithFallback GET /v1/entities/properties/{property_id}/labels_with_language_fallback/{language_code} Retrieve a Property's label in a specific language, with language fallback
WmdeWikibaseRestApi.LabelsApi getPropertyLabels GET /v1/entities/properties/{property_id}/labels Retrieve a Property's labels
WmdeWikibaseRestApi.LabelsApi patchItemLabels PATCH /v1/entities/items/{item_id}/labels Change an Item's Labels
WmdeWikibaseRestApi.LabelsApi patchPropertyLabels PATCH /v1/entities/properties/{property_id}/labels Change a Property's Labels
WmdeWikibaseRestApi.LabelsApi replaceItemLabel PUT /v1/entities/items/{item_id}/labels/{language_code} Add / Replace an Item's label in a specific language
WmdeWikibaseRestApi.LabelsApi replacePropertyLabel PUT /v1/entities/properties/{property_id}/labels/{language_code} Add / Replace a Property's label in a specific language
WmdeWikibaseRestApi.OpenAPIDocumentApi getOpenApiDoc GET /v1/openapi.json Retrieve the OpenAPI document
WmdeWikibaseRestApi.PropertiesApi addProperty POST /v1/entities/properties Create a Wikibase Property
WmdeWikibaseRestApi.PropertiesApi getProperty GET /v1/entities/properties/{property_id} Retrieve a single Wikibase Property by ID
WmdeWikibaseRestApi.PropertiesApi patchProperty PATCH /v1/entities/properties/{property_id} Change a single Wikibase Property by ID
WmdeWikibaseRestApi.PropertyDataTypesApi getPropertyDataTypes GET /v1/property-data-types Retrieve the map of Property data types to value types
WmdeWikibaseRestApi.PropertySearchApi simplePropertySearch GET /v0/search/properties [WIP] Simple Property search by label and aliases
WmdeWikibaseRestApi.SitelinksApi deleteSitelink DELETE /v1/entities/items/{item_id}/sitelinks/{site_id} Delete an Item's Sitelink
WmdeWikibaseRestApi.SitelinksApi getSitelink GET /v1/entities/items/{item_id}/sitelinks/{site_id} Retrieve an Item's Sitelink
WmdeWikibaseRestApi.SitelinksApi getSitelinks GET /v1/entities/items/{item_id}/sitelinks Retrieve an Item's Sitelinks
WmdeWikibaseRestApi.SitelinksApi patchSitelinks PATCH /v1/entities/items/{item_id}/sitelinks Change an Item's Sitelinks
WmdeWikibaseRestApi.SitelinksApi setSitelink PUT /v1/entities/items/{item_id}/sitelinks/{site_id} Add / Replace an Item's Sitelink
WmdeWikibaseRestApi.StatementsApi addItemStatement POST /v1/entities/items/{item_id}/statements Add a new Statement to an Item
WmdeWikibaseRestApi.StatementsApi addPropertyStatement POST /v1/entities/properties/{property_id}/statements Add a new Statement to a Property
WmdeWikibaseRestApi.StatementsApi deleteItemStatement DELETE /v1/entities/items/{item_id}/statements/{statement_id} Delete a single Statement from an Item
WmdeWikibaseRestApi.StatementsApi deletePropertyStatement DELETE /v1/entities/properties/{property_id}/statements/{statement_id} Delete a single Statement from a Property
WmdeWikibaseRestApi.StatementsApi deleteStatement DELETE /v1/statements/{statement_id} Delete a single Statement
WmdeWikibaseRestApi.StatementsApi getItemStatement GET /v1/entities/items/{item_id}/statements/{statement_id} Retrieve a single Statement from an Item
WmdeWikibaseRestApi.StatementsApi getItemStatements GET /v1/entities/items/{item_id}/statements Retrieve Statements from an Item
WmdeWikibaseRestApi.StatementsApi getPropertyStatement GET /v1/entities/properties/{property_id}/statements/{statement_id} Retrieve a single Statement from a Property
WmdeWikibaseRestApi.StatementsApi getPropertyStatements GET /v1/entities/properties/{property_id}/statements Retrieve Statements from a Property
WmdeWikibaseRestApi.StatementsApi getStatement GET /v1/statements/{statement_id} Retrieve a single Statement
WmdeWikibaseRestApi.StatementsApi patchItemStatement PATCH /v1/entities/items/{item_id}/statements/{statement_id} Change elements of a single Statement of an Item
WmdeWikibaseRestApi.StatementsApi patchPropertyStatement PATCH /v1/entities/properties/{property_id}/statements/{statement_id} Change elements of a single Statement of a Property
WmdeWikibaseRestApi.StatementsApi patchStatement PATCH /v1/statements/{statement_id} Change elements of a single Statement
WmdeWikibaseRestApi.StatementsApi replaceItemStatement PUT /v1/entities/items/{item_id}/statements/{statement_id} Replace a single Statement of an Item
WmdeWikibaseRestApi.StatementsApi replacePropertyStatement PUT /v1/entities/properties/{property_id}/statements/{statement_id} Replace a single Statement of a Property
WmdeWikibaseRestApi.StatementsApi replaceStatement PUT /v1/statements/{statement_id} Replace a single Statement

Documentation for Models

Documentation for Authorization

Endpoints do not require authorization.

Readme

Keywords

none

Package Sidebar

Install

npm i @wmde/wikibase-rest-api

Weekly Downloads

36

Version

1.1.19

License

BSD-3-Clause license

Unpacked Size

486 kB

Total Files

55

Last publish

Collaborators

  • tarrow
  • manicki
  • thiemowmde
  • lucaswerkmeister
  • mariushoch
  • wmdebot
  • jakob_wmde
  • darthmon
  • itamar.wmde
  • noa_wmde
  • arthurtaylorwmde