Cloudsmith API Client

2.0.25 · active · verified Thu Apr 16

The `cloudsmith-api` library is an auto-generated Python client for interacting with the Cloudsmith package management API (version 1). It provides programmatic access to manage repositories, packages, users, and more. As of May 2024, the latest version is 2.0.25, with frequent releases reflecting updates to the underlying OpenAPI specification.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to authenticate using an API key from an environment variable and list all accessible Cloudsmith repositories. Ensure the `CLOUDSMITH_API_KEY` environment variable is set.

import os
import cloudsmith_api
from cloudsmith_api.rest import ApiException

# Configure API key authorization:
X-Api-Key = os.environ.get('CLOUDSMITH_API_KEY', '')

if not X_Api_Key:
    print("Error: CLOUDSMITH_API_KEY environment variable not set.")
    exit(1)

configuration = cloudsmith_api.Configuration(api_key={'X-Api-Key': X_Api_Key})

# Enter a context with an instance of the API client
with cloudsmith_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    repositories_api = cloudsmith_api.RepositoriesApi(api_client)

    try:
        # List repositories
        print("Listing Cloudsmith repositories...")
        api_response = repositories_api.repos_list()
        for repo in api_response.data:
            print(f"  - {repo.name} (Slug: {repo.slug}) by {repo.owner}")
    except ApiException as e:
        print(f"Exception when calling RepositoriesApi->repos_list: {e}")
    except Exception as e:
        print(f"An unexpected error occurred: {e}")

view raw JSON →