Skip to main content

Backlog API v2 Client

Project description

pybacklog

Backlog API v2 Client Library for Python

CI

Requirements

  • Python 3.10+
  • requests 2.x

Usage: install

pip install pybacklog

Usage: code

from pybacklog import BacklogClient
import os

YOUR_SPACE_NAME = os.getenv("BACKLOG_SPACE_NAME", "")
YOUR_API_KEY = os.getenv("BACKLOG_API_KEY", "")
YOUR_PROJECT = os.getenv("BACKLOG_PROJECT", "")
YOUR_ISSUE_KEY = os.getenv("BACKLOG_ISSUE_KEY", "")

client = BacklogClient(YOUR_SPACE_NAME, YOUR_API_KEY)

# space
space = client.space()
print(space.get("spaceKey"))

# project
projects = client.projects()

# activity
activities = client.project_activities(YOUR_PROJECT, {"activityTypeId[]": [1, 2]})

# list issue
project_id = client.get_project_id(YOUR_PROJECT)
issues = client.issues({"projectId[]": [project_id], "sort": "dueDate"})

# specified issue
issue = client.issue(YOUR_ISSUE_KEY)

# create issue
project_id = client.get_project_id(YOUR_PROJECT)
issue_type_id = client.project_issue_types(YOUR_PROJECT)[0]["id"]
priority_id = client.priorities()[0]["id"]

if project_id and issue_type_id and priority_id:
    client.create_issue(project_id, "some summary", issue_type_id, priority_id, {"description": "a is b and c or d."})

# add comment
client.add_issue_comment(YOUR_ISSUE_KEY, "or ... else e.")

# top 10 star collector
star_collectors = [
    (client.user_stars_count(u["id"], {"since": "2017-06-01", "until": "2017-06-30"})["count"], u["name"])
    for u in client.users()
]
star_collectors.sort()
star_collectors.reverse()

for i, (c, u) in enumerate(star_collectors[:10]):
    print(i + 1, c, u)

supported operations are pydoc pybacklog.BacklogClient

extra parameters are here => Backlog API Overview | Backlog Developer API | Nulab

Unsupported operations ?

Use do or let's write code and Pull Request.

from pybacklog import BacklogClient
import os

YOUR_SPACE_NAME = os.getenv("BACKLOG_SPACE_NAME", "")
YOUR_API_KEY = os.getenv("BACKLOG_API_KEY", "")
YOUR_PROJECT = os.getenv("BACKLOG_PROJECT", "")

client = BacklogClient(YOUR_SPACE_NAME, YOUR_API_KEY)
space = client.do("GET", "space")  # GET /api/v2/space
projects = client.do("GET", "projects", query_params={"archived": False})  # GET /api/v2/projects?archived=false
activities = client.do(
    "GET",
    "projects/{project_id_or_key}/activities",
    url_params={"project_id_or_key": YOUR_PROJECT},
    query_params={"activityTypeId[]": [1, 2]},
)  # GET /api/v2/projects/myproj/activities?activityTypeIds%5B%5D=1&activityTypeIds%5B%5D=2

see also Backlog API Overview | Backlog Developer API | Nulab

Development

uv sync --group dev
uv run python3 -m unittest tests

License

Copyright 2017 Toshiaki Baba

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybacklog-1.0.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pybacklog-1.0.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file pybacklog-1.0.0.tar.gz.

File metadata

  • Download URL: pybacklog-1.0.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pybacklog-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7ae749df13ee5531962edc75163e5fba35b635ea3feb9a642c434e7c1971f9b1
MD5 2158ddc119386b78109248d93fae0e22
BLAKE2b-256 143d623a774c6a2af45f13c023a71cafdd44f413411533e4f0d58fc50cfb3f4b

See more details on using hashes here.

File details

Details for the file pybacklog-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pybacklog-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pybacklog-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d0ec31483c73f41e7f89cbf2f25961e5acb9c06ced769d561a07f9196b7afcc
MD5 66d3789fb6d7bb0ac15f9e3e109db529
BLAKE2b-256 de38bf2ef4cefbd452e88eef2e89460d80041411090963c86041c7e444ba962b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page