Skip to main content

Official Python SDK for the OdeCloud API

Project description

OdeCloud Python SDK

Official Python client for the OdeCloud API.

Installation

pip install odecloud-python

Quick Start

from odecloud import OdeCloud

# Initialize the client
client = OdeCloud(api_key="ode_live_your_api_key")

# List your time entries
entries = client.time_entries.list()
for entry in entries:
    print(f"{entry.task_title}: {entry.total_hours}h")

# Get your profile
profile = client.profile.get()
print(f"Hello, {profile.full_name}!")

Async Support

import asyncio
from odecloud import AsyncOdeCloud

async def main():
    async with AsyncOdeCloud(api_key="ode_live_your_api_key") as client:
        entries = await client.time_entries.list()
        for entry in entries:
            print(f"{entry.task_title}: {entry.total_hours}h")

asyncio.run(main())

Resources

Time Entries

# List time entries with filters
entries = client.time_entries.list(
    page=1,
    page_size=20,
    project_id="project-123",
    billable=True,
    start_date="2024-01-01",
    end_date="2024-01-31"
)

# Auto-paginate through all entries
for entry in client.time_entries.list_all():
    print(entry.id)

# Get a specific entry
entry = client.time_entries.get("entry-123")

# Create a time entry
entry = client.time_entries.create(
    task_id="task-123",
    times=[{"startedAt": 1704067200000, "endedAt": 1704070800000}],
    billable=True,
    notes="Worked on feature X"
)

# Update a time entry
entry = client.time_entries.update(
    "entry-123",
    notes="Updated notes",
    billable=False
)

# Delete a time entry
client.time_entries.delete("entry-123")

# Get time summary
summary = client.time_entries.summary(
    start_date="2024-01-01",
    end_date="2024-01-31",
    project_id="project-123"
)
print(f"Total: {summary.total_time_hours}h")
print(f"Billable: {summary.billable_time_hours}h")

Projects

# List projects
projects = client.projects.list(search="ERP")

# Auto-paginate through all projects
for project in client.projects.list_all():
    print(f"{project.title}: {project.total_time_hours}h")

# Get project details with members
project = client.projects.get("project-123")
for member in project.members:
    print(f"  - {member.full_name}")

# List tasks for a project
tasks = client.projects.list_tasks("project-123", status="in_progress")
for task in tasks:
    print(f"  {task.title}: {task.current_time_hours}h")

Profile

# Get your profile
profile = client.profile.get()
print(f"Name: {profile.full_name}")
print(f"Email: {profile.email}")
print(f"Tagline: {profile.tagline}")

# Update your profile
updated = client.profile.update(
    tagline="Senior ERP Consultant | NetSuite Expert",
    location="San Francisco, CA",
    social_links={
        "linkedin": "https://linkedin.com/in/yourname",
        "github": "https://github.com/yourname"
    }
)

Error Handling

from odecloud import OdeCloud, AuthenticationError, RateLimitError, NotFoundError

client = OdeCloud(api_key="ode_live_your_api_key")

try:
    entry = client.time_entries.get("invalid-id")
except NotFoundError:
    print("Entry not found")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds")

Configuration

client = OdeCloud(
    api_key="ode_live_your_api_key",
    base_url="https://server.odecloud.app/api/v1/public",  # Optional
    timeout=30.0,  # Request timeout in seconds
    max_retries=3,  # Max retries for rate-limited requests
)

API Scopes

Your API key needs the appropriate scopes to access different resources:

Resource Required Scope
time_entries.list(), time_entries.get(), time_entries.summary() time:read
time_entries.create(), time_entries.update(), time_entries.delete() time:write
projects.list(), projects.get(), projects.list_tasks() projects:read
profile.get() profile:read
profile.update() profile:write

Publishing to PyPI

Prerequisites

  1. Create a PyPI account at https://pypi.org/account/register/
  2. Generate an API token at https://pypi.org/manage/account/#api-tokens
  3. Install build tools:
pip install build twine

Build and Publish

# Navigate to the SDK directory
cd odecloud-python

# Build the package
python -m build

# Upload to PyPI (you'll be prompted for your API token)
python -m twine upload dist/*

Using API Token

You can configure twine to use your API token:

# Option 1: Environment variable
export TWINE_USERNAME=__token__
export TWINE_PASSWORD=pypi-your-api-token

# Option 2: .pypirc file (~/.pypirc)
cat > ~/.pypirc << EOF
[pypi]
username = __token__
password = pypi-your-api-token
EOF

Test on TestPyPI First (Recommended)

# Upload to TestPyPI
python -m twine upload --repository testpypi dist/*

# Install from TestPyPI to verify
pip install --index-url https://test.pypi.org/simple/ odecloud-python

Version Management

Update the version in pyproject.toml before each release:

[project]
version = "1.0.1"  # Increment this

GitHub Actions (Optional)

Add .github/workflows/publish.yml for automated publishing:

name: Publish to PyPI

on:
  release:
    types: [published]

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.11'
      - name: Install dependencies
        run: pip install build twine
      - name: Build package
        run: python -m build
      - name: Publish to PyPI
        env:
          TWINE_USERNAME: __token__
          TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
        run: python -m twine upload dist/*

License

MIT

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

odecloud_python-0.1.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

odecloud_python-0.1.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file odecloud_python-0.1.0.tar.gz.

File metadata

  • Download URL: odecloud_python-0.1.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for odecloud_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d602ecbd74ad652698710ea67cbb80f6d6381c857835832a9da190e82fea3641
MD5 9e5e99165634ae2a18ae8624e0ef1269
BLAKE2b-256 ab503cdb6f46f5b174bbda7d4a2a5b68b231399d68863c2cf631d7f27e3214c5

See more details on using hashes here.

File details

Details for the file odecloud_python-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for odecloud_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29d89f7c4729f081f99d1958c6681195d46b88c5a32fe5651d4be341972d9712
MD5 128f20b68ebc1446c9a3f41015c3a819
BLAKE2b-256 3f3b15f03521f81ad6ccf636bf8f3b75c72b238f4b18c5931b80bfaa21417ff2

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