[python] Read information with Redmine API

at first

Regarding Redmine, which is a project management SW, the operation to read information using Python is summarized. It was carried out in the following environment.

os windows
python 3.7.1
python-redmine 2.3.0
anaconda 4.8.5

What is python-redmine

API that can operate Redmine from Python. Tickets and projects can be created, loaded, updated and deleted. This article is for reading only.

Installation method

Install from anaconda cloud.

$ conda install -c auto python-redmine

Connection settings

To connect to Redmine, you need to set it on Remine side and python side.

Redmine side

A user with administrator privileges configures Redmine. Enable [Administration] → [Settings] → [Enable Web Services by REST API].

Python side

Use the information of the accessing user (user name and password) or API access key.

from redminelib import Redmine
REDMINE_URL = r'http://user/redmine' #Redmine path
REDMINE_KEY = 'xxxxxx' #API access key
redmine = Redmine(REDMINE_URL, key = REDMINE_KEY)

Or

from redminelib import Redmine
REDMINE_URL = r'http://user/redmine' #Redmine path
USER = 'hoge' #User name
PASS = 'hogehoge' #password
redmine = Redmine(REDMINE_URL, username = USER, password = PASS)

Get ticket information

There are three ways to get Redmine ticket information: get (), all (), and filter (). If you want to get only a specific ticket, get it with redmine.issue.get (ticket ID). The information in the acquired ticket is in the object that is the return value. If the ticket with the target ticket ID does not exist, a redmine.exceptions.ResourceNotFoundError exception will be thrown.

from redminelib import Redmine
from redminelib.exceptions import ResourceNotFoundError
REDMINE_URL = r'http://user/redmine' #Redmine path
REDMINE_KEY = 'xxxxxx' #API access key
redmine = Redmine(REDMINE_URL, key = REDMINE_KEY)

ticket_id = 4
try:
    issue = redmine.issue.get(ticket_id)
except(ResourceNotFoundError):
    print('Ticket ID %s not found' % ticket_id)

Summary of ticket information

Summarize the contents described in detail in python-redmine. https://python-redmine.com/resources/issue.html If the corresponding information is not registered in the ticket, the ISSUE property itself does not exist. Therefore, it is necessary to determine whether or not the property is possessed for information acquisition.

info = issue.property if hasattr(issue, 'property') else None
Redmine information Information in ISSUE
Ticket ID issue.id
Ticket URL issue.url
Tracker ID issue.tracker.id
Tracker issue.tracker.name
Title issue.subject
Explanation issue.description
Status ID issue.status.id
status issue.status.name
Priority ID issue.priority.id
priority issue.priority.name
Person in charge ID issue.assigned_to.id
Person in charge name issue.assigned_to.name
Parent ticket ID issue.parent
start date issue.start_date
Deadline issue.due_date
Estimated time issue.estimated_hours
Project ID issue.project.id
project issue.project.name
Creator ID issue.author.id
Creator name issue.author.name
Progress rate issue.done_ratio
Created date issue.created_on
Update date issue.updated_on
Working hours issue.spent_hours

If there is a plurality of information, each information is included in each object.

Watcher issue.watchers
Watcher ID .id
Watcher name .name
Custom area issue.custom_fields
Custom ID .id
Custom name .name
Custom value .value
Send file issue.attachments
File ID .id
file name .filename
File description .description
file size .filesize
File author .author
File URL .content_url
File creation date .created_on
Commit log issue.changesets
Child ticket issue.children
Child ticket ID .id
Child ticket title .subject
Related tickets issue.relations
Related ID .id
Related own ID .issue_id
Related partner's ID .issue_to_id
Related type .relation_type

reference

https://qiita.com/mima_ita/items/1a939db423d8ee295c85 https://python-redmine.com/resources/issue.html

Recommended Posts

[python] Read information with Redmine API
Collecting information from Twitter with Python (Twitter API)
[Python] Get Python package information with PyPI API
Use Trello API with python
Get information with zabbix api
Play RocketChat with API / Python
Call the API with python3.
Use subsonic API with python3
Get Alembic information with Python
Read json data with python
Register a ticket with redmine API using python requests
[Python] Get user information and article information with Qiita API
Text extraction (Read API) with Azure Computer Vision API (Python3.6)
Get reviews with python googlemap api
Run Rotrics DexArm with python API
Quine Post with Qiita API (Python)
Hit the Etherpad-lite API with Python
Read files in parallel with Python
Read fbx from python with cinema4d
Get weather information with Python & scraping
Python: Extract file information from shared drive with Google Drive API
Get property information by scraping with python
Automatically create Python API documentation with Sphinx
Simple Slack API client made with Python
Retrieving food data with Amazon API (Python)
Map rent information on a map with python
[C] [python] Read with AquesTalk on Linux
Let's read the RINEX file with Python ①
[Python] Read images with OpenCV (for beginners)
[Python] Quickly create an API with Flask
[Automation] Read a Word document with Python
Serverless face recognition API made with Python
Stream redmine updates to hipchat with python
Get coincheck virtual currency information with API ♪
Read text in images with python OCR
[Automation] Read mail (msg file) with Python
FizzBuzz with Python3
Scraping with Python
Statistics with python
Collect video information of "Singing with XX people" [Python] [Youtube Data API]
Scraping with Python
Python with Go
Twilio with Python
Integrate with Python
Play with 2016-Python
AES256 with python
Tested with Python
python starts with ()
with syntax (Python)
Bingo with python
Zundokokiyoshi with python
I tried to get the movie information of TMDb API with Python
Excel with Python
[python] Read data
Microcomputer with Python
Cast with python
Collecting information from Twitter with Python (Environment construction)
How to read a CSV file with Python 2/3
Read data with python / netCDF> nc.variables [] / Check data size
Text extraction with GCP Cloud Vision API (Python3.6)
Read JSON with Python and output as CSV