Skip to content

Lakelimbo/mwgo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MediaWiki REST API client for Go

A simple client that implements MediaWiki's REST API.

To install:

go get https://github.com/Lakelimbo/mwgo

Usage

Create a new instance:

import "github.com/Lakelimbo/mwgo"

var wiki = mwgo.New(<--your url here-->)

The URL must have the /rest.php/v1 attached to it (or whatever is your endpoint), otherwise it will not be able to send requests.

Examples

Get article information

page, err := wiki.Page.GetPageBare("Venus")
if err != nil {
    return err
}

licenseTitle := page.License.Title // "Creative Commons Attribution-Share Alike 4.0"
licenseURL := page.License.URL // https://creativecommons.org/licenses/by-sa/4.0/deed.en"

Get article's HTML output

page, err := wiki.Page.GetHTML("Venus", "view", false)
if err != nil {
    return err
}

// now `page` has all of the HTML output as a string

Search for articles with "planet"

limit := 50
pages, err := wiki.Search.Pages("planet", limit)
if err != nil {
    return err
}

Get specific edit on history

edit, err := wiki.History.GetRevisionBare(1234567890)
if err != nil {
    return err
}

Get page's history with some filters

filter := mwgo.PageHistoryParams{
    OlderThan:  123,
    NewerThan:  456,
    Filter:     "bot"
}
page, err := wiki.History.GetPageHistory("Venus", &filter)
if err != nil {
    return err
}

Get file information

file, err := wiki.File.GetFile("File:UwU.png")
if err != nil {
    return err
}

width := file.Width
duration := file.Duration // if it was an audio or video

To-Do:

  • core integration tests
  • add ability to create and edit pages
  • improve error handling
  • add Wikidiff2 integration tests
  • add older/larger Action API endpoints

About

Client SDK for MediaWiki's REST API

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages