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.3.0.tar.gz (27.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.3.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for granola_client-0.3.0.tar.gz
Algorithm Hash digest
SHA256 84e6025a6035068bf651847e2b5ed9f6837bf6acf72a11cbd10998d2378c3bcb
MD5 f093e36bde7bfec25bd54e768680cdf6
BLAKE2b-256 e0f3110f832bfe50901516e119f5c0cf384b04e3192f106fb2f363893d24de9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for granola_client-0.3.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.3.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for granola_client-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 827489ec15805b43d6ed8ef63f706e1ddeb73263d02b1ab7b5a4773386a136a6
MD5 1bf53578e45502a43e343c389f1af767
BLAKE2b-256 f974d76fbe5e5cdfefe8438605555f1c94243661deaeb6db8fa9dfaf6399bf3f

See more details on using hashes here.

Provenance

The following attestation bundles were made for granola_client-0.3.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