#wikipedia #wikidata #wikimedia #api #api-bindings

bin+lib tools_interface

Abstractions of serveral Wikipedia/Wikimedia/Wikidata-related tools

7 releases

0.1.6 Jun 3, 2024
0.1.5 Jun 3, 2024
0.1.4 May 31, 2024

#311 in Asynchronous

Download history 25/week @ 2024-07-27 6/week @ 2024-09-21 1/week @ 2024-09-28

309 downloads per month

MIT/Apache

9MB
11K SLoC

TypeScript 5.5K SLoC // 0.2% comments Rust 3K SLoC // 0.0% comments Python 1.5K SLoC // 0.2% comments HCL 292 SLoC // 0.0% comments Shell 165 SLoC // 0.2% comments JavaScript 157 SLoC // 0.0% comments Java 145 SLoC // 0.1% comments Go 143 SLoC // 0.2% comments C++ 128 SLoC // 0.3% comments Kotlin 100 SLoC // 0.1% comments PowerShell 88 SLoC // 0.1% comments Batch 71 SLoC SQL 31 SLoC C# 30 SLoC // 0.3% comments Visual Studio Solution 28 SLoC Ruby 25 SLoC Swift 18 SLoC // 0.1% comments Open Policy Agent 16 SLoC Jinja2 15 SLoC Lua 13 SLoC Dart 13 SLoC PHP 8 SLoC CUDA 7 SLoC CUE 6 SLoC Bazel 5 SLoC VB6 5 SLoC Scala 4 SLoC Haml 3 SLoC Jupyter Notebooks 3 SLoC // 0.5% comments Perl 2 SLoC // 0.5% comments

Contains (Zip file, 8.5MB) ticket-monster.war, (JAR file, 62KB) gradle-wrapper.jar, (Zip file, 8KB) jboss-helloworld.war

Tools Interface

This rust crate implements structs to easily interface with several Wikipedia/Wikidata/Wikimedia tools and APIs.

Supported tools

If you would like to see other tools supported, add a request to the Issue tracker.

Binary

The is a ti binary, working as a command-line interface to the tools_interface library. It allows you to run queries against various Wikimedia tools from shell.

Use ti help to get the list of subommands, and ti help <subcommand> to get help on a specific subcommand.

Default output format is JSON, so you can pipe the output to jq for downstream processing. Pages are listed in the .pages array, with each page having a title, a prefixed_title, and a namespace_id. Each page can have additional fields, depending on the tool used. The .site object contains the result site's wiki, language and project.

Example: Run a PetScan query with a known PSID, and override two parameters:

ti petscan --id 28348714 --params "foo=bar" "baz=123"

Example: Run Missing Topics on German Wikipedia for the article "Biologie", without template links:

ti missing_topics --wiki dewiki --article Biologie --no_template_links

To convert the output to a more human-readable format, you can use jq:

# First, pipe your output to a file:
ti SOME_COMMAND > test.json
# Assuming you just want the page titles:
jq -r '.pages[].prefixed_title' < test.json
# Assuming the output has additional `counter` fields:
jq -r '.pages[] | "\(.prefixed_title)\t\(.counter)"' < test.json

Dependencies

~14–27MB
~387K SLoC