Documentation
¶
Overview ¶
Package wikiprov provides functions to enable simple reification, i.e. provenance/fixity of Wikidata entities. The module can be extended to other Wikibase sites in the future.
The package constructs an API call for the Wikibase Query endpoint and then uses that data to create a normalized "provenance" struct that should be easier to work with for the caller.
An example API query we need to construct:
https://www.wikidata.org/w/api.php?action=query&format=json&prop=revisions&titles=Q5381415&rvlimit=200&rvprop=ids|user|comment|timestamp|sha1
We'll also use some of these values to build a permalink for that provenance struct which looks as follows:
https://www.wikidata.org/w/index.php?title=Q178051&oldid=1301912874&format=json https://www.wikidata.org/w/index.php?title=<QID>&oldid=<REVISION>&format=json
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetWikibaseAPIURL ¶ added in v0.2.0
func GetWikibaseAPIURL() string
GetWikibaseAPIURL lets the caller configure its own Wikibase API service to connect to.
func GetWikibaseIndexURL ¶ added in v0.2.0
func GetWikibaseIndexURL() string
GetWikibaseIndexURL lets the caller configure its own Wikibase API service to connect to.
func SetWikibaseAPIURL ¶
func SetWikibaseAPIURL(newURL string)
SetWikibaseAPIURL lets the caller configure its own Wikibase API service to connect to.
func SetWikibasePermalinkBaseURL ¶
func SetWikibasePermalinkBaseURL(newURL string)
SetWikibasePermalinkBaseURL lets the caller configure the Wikibase base URL for the permalink that needs to be built.
func SetWikibaseURLs ¶ added in v0.2.0
func SetWikibaseURLs(newURL string)
SetWikibaseURLs sets the URL for this package to connect to. E.g. newURL would point to Wikidata or a custom Wikibase instance.
Types ¶
type Provenance ¶
type Provenance struct { Title string `json:"Title,omitempty"` Entity string `json:"Entity,omitempty"` Revision int `json:"Revision,omitempty"` Modified string `json:"Modified,omitempty"` Permalink string `json:"Permalink,omitempty"` History []string `json:"History,omitempty"` Error error `json:"-"` }
Provenance provides simplified provenance information about a Wikidata record.
func GetWikidataProvenance ¶
func GetWikidataProvenance(id string, lenHistory int) (Provenance, error)
GetWikidataProvenance requests the entity data we need from the Wikibase API and returns a structure containing the information that we're interested in, augmented with a permalink to the record.
func (Provenance) String ¶
func (prov Provenance) String() string
String creates a human readable representation of the provenance struct.