Notes on Wikipedia / Artsy APIs

I wanted to take some notes on Wikipedia / Artsy AIs that I may use in the future.

1 23

I want to go over some APIs that I may want to use for projects in the future.

References

Wikipedia API

The MediaWiki Action API is a web service that allows access to some wiki features like authentication, page operations, and search. It can provide meta information about the wiki and the logged-in user.

Example uses:

Examples of Wikimedia Wiki Endpoints

API Endpoint Wiki
https://www.mediawiki.org/w/api.php MediaWiki API
https://meta.wikimedia.org/w/api.php Meta-Wiki API
https://en.wikipedia.org/w/api.php English Wikipedia API
https://commons.wikimedia.org/w/api.php Wikimedia Commons API
https://test.wikipedia.org/w/api.php Test Wiki API

API Etiquette and Usage Guidelines

There is no hard speed limit on read requests, but be considerate and try not to take a site down. Most system administrators reserve the right to unceremoniously block you if you do endanger the stability of their site. Making your requests in series rather than in parallel, by waiting for one request to finish before sending a new request, should result in a safe request rate. You can include multiple items in one request by:

Requests that make edits are subject to rate limiting. When you hit the request rate limit you will receive a API error response with the error code ratelimited. It is best practice to set a descriptive User Agent header. If you are using the API from the browser, you should set the Api-User-Agent header. All new API users should use JSON.

Frequently Asked Questions

What can the MediaWiki Action API be used for?

The MediaWiki Action API can be used to:

How to use the API

HTTP requests are usually used to call the Action API. You can try out the API in this sandbox.

What is a module, a submodule, and a parameter?

The MediaWiki Action API has numerous modules that we use to perform different tasks. In technical terms, a module is a subclass of ApiBase. A module requires paramaters. These parameters may (or may not be) submodules.

In this request: https://www.mediawiki.org/w/api.php?action=query&list=search&srsearch=abc&format=json

How do I know which module and submodule to call?

The self-documenting API pages contain a list of all modules and submodules with brief descriptions. You can start at the main module and follow the links to different submodules.

Do I need an access token?

You will require an access token to perform data modifying actions like logging in, editing, moving, page, etc.

Input and Output Formats

The API takes its input through parameters provided by the HTTP request in application/x-www-form-urlencoded or multipart/form-data format. Every module and submodule has its own set of parameters, which are listed in the documentation and in action=help. All encoding should be valid UTF-8. Parameters that take multiple values are normally submitted with the values separated using the pipe character |. If a value contains the pipe character itself, use U+001F as the separator and prefix the value with U+001F, e.g. param=%1Fvalue1%1Fvalue2. If a boolean parameter is specified in an HTTP request, it is considered true regardless of its value. For a false value, omit the parameter entirely. Parameters that take timestamp values accept the timestamp in UNIX timestamp format. The standard and default output format in MediaWiki is JSON.

Errors and Warnings

If something goes wrong in an API request, an error or a warning will be thrown although the HTTP response will usually still be 200 OK. Warnings are thrown for non-fatal conditions such as invalid parameters, whereas errors are only thrown for fatal conditions.

Artsy API

  1. Create an artsy account
  2. Sign in to the developer website
  3. Use your app.
    1. Create an app and get a Client ID and Client Secret.
  4. Get a Token:

bash $ curl -v -X POST "https://api.artsy.net/api/tokens/xapp_token?client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET"

```javascript var request = require('superagent');

var clientID = '49d6d75ce4b97878154f', clientSecret = '169814560f096e4b39654dfdd6160189', apiUrl = 'https://api.artsy.net/api/tokens/xapp_token', xappToken;

request .post(apiUrl) .send({ client_id: clientID, client_secret: clientSecret }) .end(function(res) { xappToken = res.body.token; }); ```

  1. Make Requests.

The base URL of the API is https://api.artsy.net/api. All response bodies are in the JSON+HAL Hypermedia format. Timestamps are in the IDO 8601 format. Links are always contained directly within a resource under the "_links" key. Artsy API s currently rate-limited to 5 requests per second per client application ID. Many content fields in the Artsy API, such as artist bios and gene descriptions, will return data in markdown format. You can use the Artsy API to get information about artists, artworks, collections, and get images.

Comments

You have to be logged in to add a comment

User Comments

Insert Math Markup

ESC
About Inserting Math Content
Display Style:

Embed News Content

ESC
About Embedding News Content

Embed Youtube Video

ESC
Embedding Youtube Videos

Embed TikTok Video

ESC
Embedding TikTok Videos

Embed X Post

ESC
Embedding X Posts

Embed Instagram Post

ESC
Embedding Instagram Posts

Insert Details Element

ESC

Example Output:

Summary Title
You will be able to insert content here after confirming the title of the <details> element.

Insert Table

ESC
Customization
Align:
Preview:

Insert Horizontal Rule

#000000

Preview:


View Content At Different Sizes

ESC

Edit Style of Block Nodes

ESC

Edit the background color, default text color, margin, padding, and border of block nodes. Editable block nodes include paragraphs, headers, and lists.

#ffffff
#000000

Edit Selected Cells

Change the background color, vertical align, and borders of the cells in the current selection.

#ffffff
Vertical Align:
Border
#000000
Border Style:

Edit Table

ESC
Customization:
Align:

Upload Lexical State

ESC

Upload a .lexical file. If the file type matches the type of the current editor, then a preview will be shown below the file input.

Upload 3D Object

ESC

Upload Jupyter Notebook

ESC

Upload a Jupyter notebook and embed the resulting HTML in the text editor.

Insert Custom HTML

ESC

Edit Image Background Color

ESC
#ffffff

Insert Columns Layout

ESC
Column Type:

Select Code Language

ESC
Select Coding Language

Insert Chart

ESC

Use the search box below

Upload Previous Version of Article State

ESC