launchpadlib

2.1.0 · active · verified Thu Apr 16

launchpadlib is an officially supported Python library for scripting Launchpad.net through its web services interfaces. It allows interaction with Launchpad objects like bugs, blueprints, and packages. The current version is 2.1.0, and it generally follows an as-needed release cadence for bug fixes and Python compatibility updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates both anonymous and authenticated access to the Launchpad API. Anonymous access is suitable for reading public data. Authenticated access (via `login_with_creds`) allows for private data access and write operations, often requiring interactive credential setup or pre-existing credential files for automated scripts. Remember to use a unique application name.

import os
from launchpadlib.launchpad import Launchpad

# Anonymous access (read-only for most public data)
# Use a unique application name, e.g., 'my-app-name-dev'
launchpad_anon = Launchpad.login_anonymously('my-checklist-day-app', 'production')
print(f"Logged in anonymously as {launchpad_anon.me}")

# Authenticated access (for writing data, private access)
# This will prompt for credentials if not already cached.
# Launchpad credentials are often stored in ~/.launchpadlib/creds

# To avoid interactive prompts in automated scripts, ensure credentials
# are pre-configured or use a 'testing' or 'staging' service root.
# For example, to avoid prompting, you could use:
# launchpad_auth = Launchpad.login_with_creds(
#    'my-checklist-day-app-auth',
#    'production', 
#    credentials_file='~/.launchpadlib/creds_my_app'
# )

try:
    # This may prompt for credentials interactively if not cached
    launchpad_auth = Launchpad.login_with_creds('my-checklist-day-app-auth', 'production')
    print(f"Logged in as {launchpad_auth.me}")
    # Example: Access your personal information
    # print(f"My email address: {launchpad_auth.me.preferred_email_address}")
except Exception as e:
    print(f"Could not log in with credentials: {e}")
    print("To enable authenticated access, run this script interactively once to cache credentials.")

# Example of using the anonymous connection to get a person:
person = launchpad_anon.people['canonical']
print(f"Canonical's display name: {person.display_name}")

view raw JSON →