Limitless API Examples

repository·main·Indexed 40 days ago

https://github.com/limitless-ai-inc/limitless-api-examples

Practical, LLM-powered code examples for interacting with the Limitless Developer API. Includes implementations in Python and TypeScript for common use cases such as exporting transcript data as Markdown, generating daily summaries via OpenAI, and visualizing lifelog data usage trends.

Tokens
1.9K
Snippets
9
Records
13
Agent score
50%

What's inside Limitless

  1. Setup the Limitless API TypeScript Examples

    main

    To use these examples, install the dependencies and configure your environment variables.

    1. Install dependencies using npm:

      npm install
    2. Create a .env file in the root directory with the following keys:

      • LIMITLESS_API_KEY: Your Limitless API key.
      • OPENAI_API_KEY: Your OpenAI API key (required for summarization examples).
      • LIMITLESS_API_URL: The API endpoint (defaults to https://api.limitless.ai).
    npm install
  2. Generate a daily summary from transcripts

    main

    The summarize_day.py script generates a summary of your transcripts. This script requires both your LIMITLESS_API_KEY and an OPENAI_API_KEY for the LLM processing. The output will stream directly to the console in Markdown format.

    LIMITLESS_API_KEY="your_api_key" OPENAI_API_KEY="sk-..." python summarize_day.py
  3. Available Scripts for TypeScript Examples

    main

    Use the following npm scripts to manage the project and run specific examples:

    • npm run build: Compiles the TypeScript source code into JavaScript.
    • npm run export-markdown: Executes the export_markdown.ts example.
    • npm run summarize-day: Executes the summarize_day.ts example.
    npm run build
    npm run export-markdown
    npm run summarize-day
  4. Visualize lifelog data usage trends

    main

    You can visualize your recording periods throughout the day by downloading lifelog data from the Limitless API and plotting the start and end timestamps using pandas and matplotlib. This process involves fetching lifelogs for a specific date, extracting the startTime from the contents array of each lifelog, and generating a timeline chart showing when recording sessions occurred.

    import pandas as pd
    import matplotlib.pyplot as plt
    import requests
    from datetime import date
    
    # 1. Setup API Key
    API_KEY = "< your api key >"
    
    # 2. Define download function (simplified logic)
    def download_lifelogs(date_str=None, page_size=10):
        url = "https://api.limitless.ai/v1/lifelogs"
        params = {
            "date": date_str or date.today().isoformat(),
            "timezone": "America/Chicago",
            "includeMarkdown": "false",
            "direction": "asc",
            "limit": page_size,
            "includeHeadings": "false"
        }
        headers = {"X-API-Key": API_KEY}
        # ... (pagination logic using nextCursor) ...
        return df
    
    # 3. Download and Plot
    df = download_lifelogs()
    if not df.empty:
        plt.figure(figsize=(12, 6))
        for i, row in df.iterrows():
            start_hour = row['first_timestamp'].hour + row['first_timestamp'].minute/60
            end_hour = row['last_timestamp'].hour + row['last_timestamp'].minute/60
            plt.plot([start_hour, end_hour], [i, i], linewidth=3, color='blue')
        plt.show()