Skip to main content

A Python client for the Granola API

Project description

Granola Python Client

A Python client for the Granola API, inspired by the typescript client. This client allows programmatic interaction with Granola's note-taking and meeting management platform. It uses Pydantic for robust data validation and httpx for asynchronous HTTP requests. It can also mimic the official Granola desktop application headers to help bypass "Unsupported client" validation.

Features

  • Async operations using httpx and asyncio.
  • Runtime data validation and serialization using Pydantic models.
  • Automatic token retrieval from local Granola app (macOS only).
  • Mimics official client headers.
  • Retry mechanism for requests.
  • Pagination support for listing resources like documents.

Requirements

  • Python 3.13+
  • uv (for package management, recommended)

Installation

It's recommended to use uv for managing dependencies in a virtual environment.

  1. Install uv: Follow the official instructions: https://github.com/astral-sh/uv#installation

    # Example for macOS/Linux
    curl -LsSf https://astral.sh/uv/install.sh | sh
    
  2. Clone the repository (if developing or installing from source):

    git clone <repository_url> # Replace with your repo URL
    cd granola-python-client
    
  3. Create and activate a virtual environment using uv:

    uv venv
    source .venv/bin/activate  # macOS/Linux
    # .venv\Scripts\activate    # Windows
    
  4. Install the package and its dependencies using uv: For regular use:

    uv pip install -e .  # For editable install from local source
    

    For development (including test dependencies):

    uv pip install -e ".[dev]"
    

    Or, if published to PyPI in the future:

    # uv pip install granola-client
    

Quick Start

import asyncio
import platform
from granola_client import GranolaClient, ClientOpts, GranolaAuthError, DocumentsResponse

async def main():
    client = None
    try:
        api_token = "your-api-token" # Replace or use macOS auto-retrieval

        if platform.system() == "Darwin" and api_token == "your-api-token":
            print("Attempting to initialize client with automatic token retrieval (macOS)...")
            client = GranolaClient()
        else:
            if api_token == "your-api-token":
                 print("Placeholder token detected. Please set a real token or run on macOS for auto-retrieval.")
                 return
            client = GranolaClient(token=api_token)

        # Get documents
        print("\nRetrieving documents...")
        documents_response: DocumentsResponse = await client.get_documents()
        if documents_response and documents_response.docs:
            print(f"Found {len(documents_response.docs)} documents:")
            for doc in documents_response.docs:
                print(f"  - ID: {doc.document_id}, Title: {doc.title}")
        else:
            print("No documents found or response was empty.")

    except GranolaAuthError as e:
        print(f"Authentication Error: {e}")
    except Exception as e:
        print(f"An error occurred: {e}")
    finally:
        if client:
            await client.close()

if __name__ == "__main__":
    asyncio.run(main())

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

granola_client-0.4.0.tar.gz (40.1 kB view details)

Uploaded Source

Built Distribution

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

granola_client-0.4.0-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file granola_client-0.4.0.tar.gz.

File metadata

  • Download URL: granola_client-0.4.0.tar.gz
  • Upload date:
  • Size: 40.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for granola_client-0.4.0.tar.gz
Algorithm Hash digest
SHA256 b1f558ce34b9d89bd83bb5a7e4c16f0f800ece44bd0b80d96707fac6ea45f3d4
MD5 31e7f6cf0633b30951450476e0b07050
BLAKE2b-256 afa7900a500b918f6818c876e91eb384f5693fea0ac9ad59e876455a27246b90

See more details on using hashes here.

Provenance

The following attestation bundles were made for granola_client-0.4.0.tar.gz:

Publisher: publish.yml on anjor/granola-py-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file granola_client-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: granola_client-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for granola_client-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26daf5ca43877f24f28c2ce12d300488b2e72b2a9dd48169648be293914ca6ce
MD5 914a977893cf0016d524190568ffa102
BLAKE2b-256 b29b6a78d20f4a1c11eef4422e66d9a13742ad52b074ce7e40e39076d890576d

See more details on using hashes here.

Provenance

The following attestation bundles were made for granola_client-0.4.0-py3-none-any.whl:

Publisher: publish.yml on anjor/granola-py-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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