Movatterモバイル変換


[0]ホーム

URL:


Jump to content
MediaWiki
Search

API:REST API/sv

From mediawiki.org
This page is atranslated version of the pageAPI:REST API and the translation is 1% complete.
Outdated translations are marked like this.
Languages:
This page is part of theMediaWiki REST API documentation.
MediaWiki REST API

Documentation

Tutorials

See also

  • CORS (Action and REST APIs)
v · d · r

The MediaWikiREST API lets you interact with MediaWiki by sendingHTTP requests torest.php URLs.You can use the API to build apps and scripts that search and display wiki pages, get media files, and explore page history.

Quick start

# Search English Wikipedia for an article about Earth$ curl"https://en.wikipedia.org/w/rest.php/v1/search/page?q=earth&limit=1"

Try it out

Data format

REST API endpoints return data inJSON orHTML format.See theAPI reference for the content type supported by each endpoint.

Methods

The API supports standardHTTP request methods.

GETRetrieve resource
HEADReturnHTTP headers for a GET request without response data
POSTCreate resource
PUTUpdate or create resource

URL structure

API endpoints share a consistent URL structure that includes the wiki's base URL, the wiki'sscript path, and the API version.

# URL structure[projecturl]/[scriptpath]/rest.php/v[versionnumber]/# Example URL: Get the history of the Main Page of English Wikipediahttps://en.wikipedia.org/w/rest.php/v1/page/Main_Page/history

Versioning

Designed to provide long-term stability for developers, the MediaWiki REST API is versioned using a global version number in the API path (for example:/v1/).

For additional details about how versions and deprecations are managed for this API, seeAPI/Deprecation.

Permissions and authorisation

The REST API is designed to be used with theOAuth extension for user authentication and authorisation.However, regardless of the authentication method, the API responds to the presence of a logged-in user and returns content appropriate to that user's permissions.

Accessing Wikimedia projects using the REST API

You can use the REST API to accessWikipedia,Wiktionary, and other Wikimedia projects in multiple languages.For a complete list of Wikimedia project URLs, seeMeta-Wiki’s site matrix.

Request limit

There is no fixed limit on requests to the API, but your client may be blocked if you endanger the stability of a site.To stay within a safe request rate, wait for each request to finish before sending another request.

Client identification

Wikimedia sites require an HTTP User-Agent header for all API requests.This helps identify your app and ensures that system administrators can contact you if a problem arises.Clients making requests without a User-Agent header may be IP-blocked without notice.

The User-Agent header can include a user page on the local wiki, a user page on a related wiki usinginterwiki linking syntax, a URL for a relevant external website, or an email address.

# Preferred format for User-Agent headers<clientname>/<version>(<contactinformation>)<library/frameworkname>/<version>

If you are calling the API from browser-based JavaScript, you may not be able to influence the User-Agent header, depending on the browser.To work around this, use the Api-User-Agent header.See theUser-Agent policy for more information.

Authorisation

To authorise your app to act on behalf of a user, follow theOAuth developer guide to register your app and make requests using OAuth tokens.

Licensing and trademarks

Wikimedia content is free to reuse within the terms specified by the applicable license.Licenses can differ between projects, so see the individual project for information about licenses and content reuse.For example, English Wikipedia’s text can be used under the terms of theCreative Commons Attribution Share-Alike license, while media files onWikimedia Commons are licensed individually as indicated on the file’s information page.For more information about licensing and trademark use, seeMeta-Wiki’s developer app guidelines.

Limitations on Wikidata

While the REST API is available on Wikimedia projects, it is not fully supported by Wikidata.As of writing, some of the endpoints may return unexpected errors.Instead, use theWikidata REST API.

Code libraries

Extension endpoints

MediaWiki extensions can provide extension-specific API endpoints using the REST API interface.See theREST API extension interface docs to get started.REST API-extension gränssnittet finns tillgängligt i $1 via $2 och iMediaWiki 1.35 och senare som standard.

API comparison

This table:visning · diskutera · redigera
APIAvailabilityURL baseExample
MediaWiki Action APIIncluded with MediaWiki

Enabled onWikimedia projects

/api.phphttps://en.wikipedia.org/w/api.php?action=query&prop=info&titles=Earth
MediaWiki REST APIIncluded with MediaWiki 1.35+

Enabled onWikimedia projects

/rest.phphttps://en.wikipedia.org/w/rest.php/v1/page/Earth
Wikimedia REST APINot included with MediaWiki

Available forWikimedia projects only

/api/resthttps://en.wikipedia.org/api/rest_v1/page/title/Earth
For commercial-scale APIs for Wikimedia projects, seeWikimedia Enterprise

About these docs

These docs are written manually based on theMediaWiki Core source code.Corrections and additions are welcome!To share a tutorial or app that uses the MediaWiki REST API, add a link to theREST API template.

Code stewardship

See also

Retrieved from "https://www.mediawiki.org/w/index.php?title=API:REST_API/sv&oldid=8008891"

[8]ページ先頭

©2009-2025 Movatter.jp