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.2.0.tar.gz (26.3 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.2.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: granola_client-0.2.0.tar.gz
  • Upload date:
  • Size: 26.3 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.2.0.tar.gz
Algorithm Hash digest
SHA256 c8d4b7558e31ed8a406f2fa3027ecec048c4331ce5a104fc449e21c4d508786e
MD5 1d7f9094b4fff24f92c098f15283bcb0
BLAKE2b-256 3ce3740b0acd6130694ca1421fcfb80670ac3636ddbb9327451083d13f3c4949

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: granola_client-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5da3535f309fa6dad5e04b5c4203d3b9b9801f6638be35f9be4747476ad4931
MD5 7153c599d48b98ad7db0edb4bf8eaeba
BLAKE2b-256 63a3cfbd0889ec0f87f62f04ab8579e79d833c31dc97063f5e493159b9c68294

See more details on using hashes here.

Provenance

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