Quick Start

This guide will get you up and running with the Slingshot SDK in just a few minutes.

Installation

Install the SDK using pip:

pip install c1s-slingshot-sdk-py

Authentication

The Slingshot SDK requires an API key for authentication. You can provide this in several ways:

Direct Initialization

Pass the API key directly when creating the client:

from slingshot import SlingshotClient

client = SlingshotClient(api_key="your-api-key-here")

Basic Usage

Working with Projects

from slingshot import SlingshotClient

# Initialize the client
client = SlingshotClient()

# List all projects
all_projects = []
for project in client.projects.iterate_projects(include=[]):
    all_projects.append(project)
print(f"Found {len(all_projects)} projects.")

# Get a specific project
project = client.projects.get_project(project_id="project-id", include=["name"])
print(f"Project: {project['name']}")

# Create a new project
new_project = client.projects.create(
    name="My New Project"
)

Error Handling

Slingshot SDK executes the raise_for_status() for all Slingshot API requests which will raise an HTTPStatusError in the case of non-successful requests. Example response handling may look like the following:

from slingshot import SlingshotClient
import logging
from httpx import HTTPStatusError

# Set up logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

def main():
    client = SlingshotClient()

    try:
        project = client.projects.get_project(project_id="project-id", include=["name"])
        logger.info(f"Successfully fetched project: {project['name']}")
        return project

    except HTTPStatusError as e:
        logger.error(f"API error when fetching project {project_id}: {e.message}")
        return None

    except Exception as e:
        logger.error(f"Unexpected error fetching Slingshot project: {str(e)}")
        return None

if __name__ == "__main__":
    main()

Next Steps