Flarum is free, open-source forum software built with PHP and Mithril.js.
Flarum API CLI is a very simple and minimal python script to manage some features of Flarum forum software such as users, groups and tags from the command line.
Users | Groups | Tags |
---|---|---|
Create | Create | Create |
Delete | Delete | Delete |
View | View | View |
Modules: argparse, requests, prettytable, dateutil, httplib
$ pip install -r requirements.txt
- Clone the repository
- Edit
config.py
and insert your Flarum forum url inbase_url
- Retrieve the
Authorization Token
from your Flarum forum using administrator credentials.
$ ./flarum-api-cli.py token -u admin -p admin
+---------------------+
| Token |
+---------------------+
| ******************* |
+---------------------+
- Edit
config.py
and save token inauth_token
Get all users
$ flarum-api-cli.py users --get
Users in https://your.forum.url
+----+----------+--------------------+-----------+-------------------+-------------------+
| ID | Username | Email | Activated | Last Seen | Joined |
+----+----------+--------------------+-----------+-------------------+-------------------+
| 1 | admin | admin@forum.url | True | 09 Jan 2018 15:10 | 08 Jan 2018 16:19 |
| 2 | user1 | user1@forum.url | True | 10 Nov 2018 20:39 | 09 Jan 2018 16:04 |
+----+----------+--------------------+-----------+-------------------+-------------------+
Create user
$ flarum-api-cli.py users --create --username user2 --email user2@forum.url --password user2password
+----+----------+-----------------+---------+
| ID | Username | Email | Status |
+----+----------+-----------------+---------+
| 3 | user2 | user2@forum.url | created |
+----+----------+-----------------+---------+
Get all groups
$ ./flarum-api-cli.py groups --get
Groups in https://your.forum.url
+----+---------------+-------------+
| ID | Name singular | Name plural |
+----+---------------+-------------+
| 1 | Admin | Admins |
| 2 | Guest | Guests |
| 3 | Member | Members |
| 4 | Mod | Mods |
+----+---------------+-------------+
Create group
$ ./flarum-api-cli.py groups --create --singular test --plural tests
+----+---------------+-------------+---------+
| ID | Name singular | Name plural | Status |
+----+---------------+-------------+---------+
| 12 | test | tests | created |
+----+---------------+-------------+---------+
Get all tags
$ ./flarum-api-cli.py tags --get
Tags in https://your.forum.url
+----+-----------+
| ID | Name |
+----+-----------+
| 3 | tag1 |
| 5 | tag2 |
+----+-----------+
Create tag
$ ./flarum-api-cli.py tags --create --name tag1 --slug tag1
+----+----------+----------+---------+
| ID | Tag name | Tag slug | Status |
+----+----------+----------+---------+
| 57 | tag1 | tag1 | created |
+----+----------+----------+---------+