A Python package to interact with the DokuWiki REST API.
Project description
DokuRestAPI
DokuRestAPI is a Python package that provides an easy-to-use interface for interacting with the DokuWiki web interface via its undocumented REST API. This package allows you to perform actions such as creating and deleting users, fetching user details, and managing other aspects of your DokuWiki instance programmatically.
If you would like to see other things added create an issue! I've just been adding things as I need them.
Features
- User Management: Create, delete, and fetch details of users.
- Session Management: Login and maintain sessions to interact with the API.
- Integration: Easily integrate with your DokuWiki instance using simple HTTP calls.
Installation
Install the package using pip:
pip install dokurestapi
Usage
First, make sure you have a .env file in your project directory with your DokuWiki credentials:
DOKUWIKI_USERNAME=your_dokuwiki_username
DOKUWIKI_PASSWORD=your_dokuwiki_password
DOMAIN=https://path.toyourdoku.domain/andorsubdir
Examples
Login
from dokurestapi.Login import Login
# Load credentials from .env file
import os
from dotenv import load_dotenv
load_dotenv()
username = os.getenv("DOKUWIKI_USERNAME")
password = os.getenv("DOKUWIKI_PASSWORD")
domain = os.getenv("DOMAIN")
with Login(username, password, domain) as login_session:
if login_session.is_logged_in():
print("Logged in successfully!")
else:
print("Login failed!")
User Management
from dokurestapi import Login, Users
# Load credentials from .env file
import os
from dotenv import load_dotenv
load_dotenv()
username = os.getenv("DOKUWIKI_USERNAME")
password = os.getenv("DOKUWIKI_PASSWORD")
domain = os.getenv("DOMAIN")
with Login(username, password, domain) as login_session:
if login_session.is_logged_in():
users = Users(login_session.session)
# Get all users
all_users = users.get_users()
print(all_users)
# Add a new user
new_user = users.add_user(
userid="newuser",
username="New User",
password="securepassword", # Leave blank to have it generate one!
email="newuser@example.com",
notify=True,
groups=["user"]
)
print(new_user)
else:
print("Login failed!")
API Reference
Login The Login class handles the login process and session management.
Login(username, password, domain): Initializes the login class with the given credentials.login(username=None, password=None): Logs in to DokuWiki. You can override the username and password.logout(): Logs out from DokuWiki and allows you to login as another user in the same script runis_logged_in(): Returns True if logged in, False otherwise.get_username(): Returns the username of the logged-in user.
Users The Users class provides methods for user management.
get_user(username): Fetches details of a specific user.get_users(): Fetches a list of all users.add_user(userid, username, password, email, notify=True, groups=["user"]): Adds a new user with the specified details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request or open an Issue.
License
This project is licensed under the MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dokurestapi-0.3.0.tar.gz.
File metadata
- Download URL: dokurestapi-0.3.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2f89110e61dab3e392738f70071a39789bf83bd16b76555a82295355ca294f4
|
|
| MD5 |
dae9ff003b6936197aa18e39c832de47
|
|
| BLAKE2b-256 |
343b7bc66730693c599ac465332ec5e98656bb0247bb637c082fee966af01d0e
|
File details
Details for the file dokurestapi-0.3.0-py3-none-any.whl.
File metadata
- Download URL: dokurestapi-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8139d43463c2c07014ed5dda0a356ad44a8fe90330eebc9b1504a1b936a9ab8a
|
|
| MD5 |
7be7e0e473582e93d7d22d7d301f409e
|
|
| BLAKE2b-256 |
88d702a53003e2c1c2225d09526dcd00f8a1943eafa92c627aec1632c6f6003b
|