go-wikimedia

go-wikimedia is an interface to the Wikimedia (Wikipedia, Wiktionary, etc.) API.

It is a work in progress, and currently used to build applications like Define that query Wikipedia and Wiktionary in different languages.

Installation

go get github.com/patrickmn/go-wikimedia

Usage

import (
	"fmt"
	"github.com/patrickmn/go-wikimedia"
	"net/url"
)

w, err := wikimedia.New("http://en.wikipedia.org/w/api.php")
if err != nil {
	...
}
f := url.Values{
	"action": {"query"},
	"prop":   {"extracts"},
	"titles": {"Osmosis|Procrastination"},
}
res, err := d.w.Query(f)
if err != nil {
	return nil, err
}
for _, v := range res.Query.Pages {
	fmt.Println(v.Title, "-", v.Extract)
}