Repository navigation
New card with Python3 and REST API
Lauri Ojansivu edited this page Mar 20, 2020
·
19 revisions
Also see:
- API Login to get Bearer token
- API docs and examples for various programming languages, there is Boards / Export for exporting board with API
- In the right menu, scroll down REST API Docs etc links =====>
- https://github.com/pycurl/pycurl/tree/master/examples/quickstart
- Wekan-Gogs integration with Node.js https://github.com/wekan/wekan-gogs
Windows
choco install python3
# REBOOT
pip3 install pip --upgrade
pip3 install pycurl certifi json
python3 newcard.py
Debian/Ubuntu
sudo apt-get install python3 python3-pip python3-pycurl
sudo pip3 install pip --upgrade
sudo pip3 install certifi json
chmod +x newcard.py
./newcard.py
Change these:
- https://example.com => Your Wekan URL
- username: joe
- password: topsecret
- BOARD-ID-HERE
- LIST-ID-HERE
- USER-ID-HERE
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# vi:ts=4:et
import pycurl
try:
# python 3
from urllib.parse import urlencode
except ImportError:
# python 2
from urllib import urlencode
import certifi
import json
from io import BytesIO
buffer = BytesIO()
c = pycurl.Curl()
c.setopt(c.URL, 'https://example.com/users/login')
c.setopt(c.WRITEDATA, buffer)
c.setopt(c.CAINFO, certifi.where())
post_data = {"username": "joe", "password": "topsecret"}
# Form data must be provided already urlencoded.
postfields = urlencode(post_data)
# Sets request method to POST,
# Content-Type header to application/x-www-form-urlencoded
# and data to send in request body.
c.setopt(c.POSTFIELDS, postfields)
c.perform()
c.close()
body = buffer.getvalue()
# Body is a byte string.
# We have to know the encoding in order to print it to a text file
# such as standard output.
data = body.decode('iso-8859-1')
#print(data)
d = json.loads(data)
#print(list(d.keys()))
#print(d['token'])
apikey = d['token']
# Lists of board
c = pycurl.Curl()
c.setopt(c.URL, 'https://example.com/api/boards/BOARD-ID-HERE/lists')
c.setopt(c.WRITEDATA, buffer)
c.setopt(c.CAINFO, certifi.where())
c.setopt(c.HTTPHEADER, ['Accept: application/json', 'Authorization: Bearer {}'.format(apikey)])
##post_data = {"authorId": "joe", "password": "topsecret"}
# Form data must be provided already urlencoded.
#postfields = urlencode(post_data)
# Sets request method to POST,
# Content-Type header to application/x-www-form-urlencoded
# and data to send in request body.
#c.setopt(c.POSTFIELDS, postfields)
c.perform()
c.close()
body = buffer.getvalue()
data = body.decode('iso-8859-1')
print("=== LISTS ===\n")
print(data)
print("\n")
data = ""
# Swimlanes of board
c = pycurl.Curl()
c.setopt(c.URL, 'https://example.com/api/boards/BOARD-ID-HERE/swimlanes')
c.setopt(c.WRITEDATA, buffer)
c.setopt(c.CAINFO, certifi.where())
c.setopt(c.HTTPHEADER, ['Accept: application/json', 'Authorization: Bearer {}'.format(apikey)])
##post_data = {"authorId": "joe", "password": "topsecret"}
# Form data must be provided already urlencoded.
#postfields = urlencode(post_data)
# Sets request method to POST,
# Content-Type header to application/x-www-form-urlencoded
# and data to send in request body.
#c.setopt(c.POSTFIELDS, postfields)
c.perform()
c.close()
body = buffer.getvalue()
data = body.decode('iso-8859-1')
print("=== SWIMLANES ===\n")
print(data)
print("\n")
data = ""
# Board info
c = pycurl.Curl()
c.setopt(c.URL, 'https://example.com/api/boards/BOARD-ID-HERE')
c.setopt(c.WRITEDATA, buffer)
c.setopt(c.CAINFO, certifi.where())
c.setopt(c.HTTPHEADER, ['Accept: application/json', 'Authorization: Bearer {}'.format(apikey)])
##post_data = {"authorId": "joe", "password": "topsecret"}
# Form data must be provided already urlencoded.
#postfields = urlencode(post_data)
# Sets request method to POST,
# Content-Type header to application/x-www-form-urlencoded
# and data to send in request body.
#c.setopt(c.POSTFIELDS, postfields)
c.perform()
c.close()
body = buffer.getvalue()
data = body.decode('iso-8859-1')
print("=== BOARD ===\n")
print(data)
print("\n")
data = ""
# Write to card
c = pycurl.Curl()
c.setopt(c.URL, 'https://example.com/api/boards/BOARD-ID-HERE/lists/LIST-ID-HERE/cards')
c.setopt(c.WRITEDATA, buffer)
c.setopt(c.CAINFO, certifi.where())
c.setopt(c.HTTPHEADER, ['Accept: application/json', 'Authorization: Bearer {}'.format(apikey)])
post_data = {"authorId": "USER-ID-HERE", "title": "Test API", "description": "Testing Description", "swimlaneId": "SWIMLANE-ID-HERE"}
# Form data must be provided already urlencoded.
postfields = urlencode(post_data)
# Sets request method to POST,
# Content-Type header to application/x-www-form-urlencoded
# and data to send in request body.
c.setopt(c.POSTFIELDS, postfields)
c.perform()
c.close()
body = buffer.getvalue()
data = body.decode('iso-8859-1')
print(data)
"""
authorId: string
members: string
assignees: string
title: string
description: string
swimlaneId: string
"""
Wekan - OpenSource Kanban
- Deep Dive Into WeKan
- Meteor WeKan Roadmap - board at Wekan demo
- Multiverse WeKan Roadmap
- Docs/Manual
- Change Language
- Forgot Password
- About
- Test Edge
- WeKan Design Principles
- FAQ
- IRC FAQ - answers to questions asked at IRC
- Team
- Press
- Blog
- NOT related to Wekan
- Wekan vs Trello vs Restyaboard
- Results of Survey 2020-01
- Allow private boards only: Disable Public Boards
- Security Disclosure and details of Security in Wekan
- Security issues
- Password Hashing
- Add more RAM to Node.js to prevent crash
- Clustering AWS etc
- Scaling
- Kubernetes
- Redis Oplog
- Meteor Scaling at Meteor Cloud
- Scaling at Meteor forums
- Progress: Import/Export/Sync
- From CSV/TSV
- From Trello
- From Jira
- From Asana
- From Zenkit
- From old Wekan manually
- Converting Meteor Stylus to CSS
- Repair MongoDB
- Using Meteor MongoDB to repair files
- If board does not open and keeps loading
- Repair Docker
- Wekan Markdown
- Emoji
- Mermaid Diagram DOES NOT WORK ANYMORE
- Numbered text
- Automatic login
- Forgot Password
- Admin: Impersonate user
- Adding Users
- Active users Presence
- Accounts Lockout: Brute force login protection
- LDAP
- LDAP AD Simple Auth
- Keycloak
- Google login
- Azure
- OAuth2, Auth0, GitLab, RocketChat
- Oracle OIM on premise using OAuth2
- ADFS 4.0 using OAuth2 and OpenID
- Nextcloud
- CAS Please test
- SAML Please test
- Drag Drop on Mobile and Desktop
- Rclone: Store attachments to cloud storage like S3, MinIO, etc
- Python based features
- Burndown and Velocity Chart
- Wait Spinners
- Translations
- Default Language for All Users
- Roadmap
- Features
- Planning Poker
- Scaling
- Custom Logo
- Subtasks <== Has fix
- Templates
- Cover
- Archive and Delete
- Custom Fields
- Fix Export board menu not visible on some boards
- RAM usage
- Demo
- Swimlane Documentation
- Customize Translations
- Download Wekan for various Platforms: Supported by xet7, Operating Systems, NAS, Cloud
- Helm Chart for Kubernetes
- Caddy
- Nginx
- Apache
- OpenLiteSpeed
- Local self signed TLS
- Let's Encrypt and Google Auth
- TLS with Node.js
- Traefik and self-signed SSL certs
- Example: New card with Python3 and REST API
- Python client to REST API
- Go client to REST API
- Java
- Wekan Sandstorm cards to CSV using Python
- Excel and VBA
- Global Webhook
- Limiting Webhook data
- Receiving Webhooks
- Outgoing Webhook to Discord/Slack/RocketChat/Riot
- Outgoing Webhook to NodeRed
- Outgoing Webhook to PowerShell
- Security: Webhook and CA
- Outgoing Webhooks Data
- Outgoing Webhooks and Let's Encrypt
- Outgoing Webhooks Original Pull Request, multiple Webhooks, more parameters and response order