Giter Club home page Giter Club logo

python-api-client's Introduction

Python API Client for Kanboard

Client library for Kanboard API.

  • Author: Frédéric Guillot
  • License: MIT

Installation

python3 -m pip install kanboard

This library is compatible with Python >= 3.5.

Note: Support for Python 2.7 has been dropped since version 1.1.0.

On Fedora (36 and later), you can install the package using DNF:

dnf install python3-kanboard

Examples

Methods and arguments are the same as the JSON-RPC procedures described in the official documentation.

Python methods are dynamically mapped to the API procedures: You must use named arguments.

By default, calls are made synchronously, meaning that they will block the program until completed.

Creating a new team project

import kanboard

kb = kanboard.Client('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token')
project_id = kb.create_project(name='My project')

Authenticate as user

import kanboard

kb = kanboard.Client('http://localhost/jsonrpc.php', 'admin', 'secret')
kb.get_my_projects()

Create a new task

import kanboard

kb = kanboard.Client('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token')
project_id = kb.create_project(name='My project')
task_id = kb.create_task(project_id=project_id, title='My task title')

Use a personalized user agent

import kanboard

kb = kanboard.Client(url='http://localhost/jsonrpc.php',
                     username='admin',
                     password='secret',
                     user_agent='My Kanboard client')

SSL connection and self-signed certificates

Example with a valid certificate:

import kanboard

kb = kanboard.Client('https://example.org/jsonrpc.php', 'admin', 'secret')
kb.get_my_projects()

Example with a custom certificate:

import kanboard

kb = kanboard.Client(url='https://example.org/jsonrpc.php',
                     username='admin',
                     password='secret',
                     cafile='/path/to/my/cert.pem')
kb.get_my_projects()

Example with a custom certificate and hostname mismatch:

import kanboard

kb = kanboard.Client(url='https://example.org/jsonrpc.php',
                     username='admin',
                     password='secret',
                     cafile='/path/to/my/cert.pem',
                     ignore_hostname_verification=True)
kb.get_my_projects()

Ignore invalid/expired certificates and hostname mismatches, which will make your application vulnerable to man-in-the-middle (MitM) attacks:

import kanboard

kb = kanboard.Client(url='https://example.org/jsonrpc.php',
                     username='admin',
                     password='secret',
                     insecure=True)
kb.get_my_projects()

Asynchronous I/O

The client also exposes async/await style method calls. Similarly to the synchronous calls (see above), the method names are mapped to the API methods.

To invoke an asynchronous call, the method name must be appended with _async. For example, a synchronous call to create_project can be made asynchronous by calling create_project_async instead.

import asyncio
import kanboard

kb = kanboard.Client('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token')

loop = asyncio.get_event_loop()
project_id = loop.run_until_complete(kb.create_project_async(name='My project'))
import asyncio
import kanboard

async def call_within_function():
    kb = kanboard.Client('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token')
    return await kb.create_project_async(name='My project')

loop = asyncio.get_event_loop()
project_id = loop.run_until_complete(call_within_function())

See the official API documentation for the complete list of methods and arguments.

python-api-client's People

Contributors

cinek810 avatar fguillot avatar horacioibrahim avatar jimcircadian avatar karthanistyr avatar loonies avatar matthew-mcallister avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.