Kanboard Python API Client

1.1.8 · active · verified Thu Apr 16

The `kanboard` library is a Python client for interacting with the Kanboard API (version 1.1.8). It provides both synchronous and asynchronous access to all Kanboard API methods, dynamically mapping Python calls to JSON-RPC procedures. The library is actively maintained with regular releases and requires Python 3.9 or higher.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the Kanboard client and create a new project. It uses environment variables for the API URL, username, and token for secure credential management. It also includes basic error handling and a check to prevent duplicate project creation.

import os
import kanboard

KANBOARD_URL = os.environ.get('KANBOARD_API_URL', 'http://localhost/jsonrpc.php')
KANBOARD_USERNAME = os.environ.get('KANBOARD_API_USERNAME', 'jsonrpc') # Use 'jsonrpc' for application token
KANBOARD_API_TOKEN = os.environ.get('KANBOARD_API_TOKEN', 'your_api_token') # Or user password/personal access token

try:
    # Initialize the client, using 'jsonrpc' user and an API token
    with kanboard.Client(KANBOARD_URL, KANBOARD_USERNAME, KANBOARD_API_TOKEN) as kb:
        # Kanboard API calls expect named arguments
        # Check if project 'My Test Project' already exists to avoid creation error
        projects = kb.get_all_projects()
        project_exists = any(p.get('name') == 'My Test Project' for p in projects)

        if not project_exists:
            project_id = kb.create_project(name="My Test Project")
            print(f"Project 'My Test Project' created with ID: {project_id}")
        else:
            print("Project 'My Test Project' already exists.")

        # Example of getting current user information (requires user credentials, not 'jsonrpc' token)
        # If KANBOARD_USERNAME is an actual user, you could call:
        # me = kb.get_me()
        # print(f"Connected as: {me.get('username')}")

except kanboard.ClientError as e:
    print(f"An API or network error occurred: {e}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

view raw JSON →