konstin / github-wikidata-bot

Updates Wikidata entries using metadata from github
https://www.wikidata.org/wiki/User:Github-wiki-bot
Other
41 stars 8 forks source link
bot github-api wikidata wikidata-bot

GitHub to Wikidata bot

Tests

Update Wikidata entries using metadata from GitHub.

For free software projects with a GitHub repository listed in Wikidata, this script will perform the following steps, using metadata collected from the GitHub API:

It is possible to exclude items from being edited by the bot, and also to allow using tags for projects without GitHub releases.

Setup and usage

First install python 3.12 and poetry, then run poetry install.

Generate a personal access token on GitHub. Create a config.json file with that token and your Wikidata username:

{
  "username": "my-wikidata-username",
  "github-oauth-token": "abcdedf1234567"
}

Then run main.py in a terminal and enter the password for your bot account.

Run pytest, ruff format and ruff check after making code changes.

Implementation notes

First, a SPARQL query gathers all the free software projects in Wikidata which have a GitHub repository specified in the source code repository property. For each entry, a cached request to the GitHub API is made, which is authenticated by the OAuth key. The wikidata entries are then inserted using a "exists or insert" logic. For each entry, the GitHub api link is added as reference.

Why does the bot not work for item Q…?

Statistics

You can find detailed statistics on wmflabs.