This Python script retrieves all issues closed in the last 12 months from the Linear API and exports them to a CSV file for audit evidence.
Developed by 24Slides | License: MIT
- Authentication: Uses
LINEAR_API_KEYenvironment variable (API key format, not Bearer token) - Date Filtering: Calculates date exactly 12 months ago (365 days) and filters issues completed after that date
- Status Filtering: Only retrieves issues with state type "completed" or "canceled"
- Pagination: Handles multiple pages of results automatically using Linear's GraphQL pagination
- Rate Limiting: Automatically handles API rate limits with exponential backoff retry (up to 5 attempts)
- Network Resilience: Retries on timeouts and connection errors
- Complete Data: Exports identifier, title, completedAt, creator name, assignee name, URL, and team name
- CSV Output: Saves results to
linear_closed_issues_last_12mo.csv
- Python 3.6 or higher
- Linear API key with read access to issues
-
Clone or download this repository
-
Install dependencies:
pip install -r requirements.txt
- Go to Linear Settings → API
- Create a new Personal API Key
- Copy the key (it starts with
lin_api_...)
Option 1: Using .env file (Recommended)
-
Copy the template file:
cp env.template .env
-
Edit
.envand replaceyour-api-key-herewith your actual API key:LINEAR_API_KEY=lin_api_xxxxxxxxxxxxxx
The script will automatically load the .env file when you run it.
Option 2: Set environment variable directly
On macOS/Linux:
export LINEAR_API_KEY='your-api-key-here'On Windows (PowerShell):
$env:LINEAR_API_KEY='your-api-key-here'On Windows (Command Prompt):
set LINEAR_API_KEY=your-api-key-hereRun the script:
python export_linear_issues.pyThe script will:
- Calculate the date 12 months ago from today
- Connect to the Linear API using your API key
- Fetch all closed issues (completed or canceled) from the last 12 months
- Display progress as it fetches paginated results
- Export the data to
linear_closed_issues_last_12mo.csv
The CSV file will contain the following columns:
identifier- Issue identifier (e.g., ENG-123)title- Issue titlecompletedAt- Timestamp when the issue was completedcreator_name- Name of the person who created the issueassignee_name- Name of the person assigned to the issueurl- Direct URL to the issue in Linearteam_name- Name of the team the issue belongs to
Linear Issues Export - Last 12 Months
============================================================
Fetching issues completed after: 2024-10-15T12:34:56.789012
============================================================
Page 1: Fetched 100 issues (Total: 100)
Page 2: Fetched 100 issues (Total: 200)
Page 3: Fetched 45 issues (Total: 245)
============================================================
Total issues fetched: 245
Successfully exported 245 issues to linear_closed_issues_last_12mo.csv
============================================================
Export completed successfully!
This script includes:
- Type hints: Full type annotations for better code clarity and IDE support
- Error handling: Comprehensive exception handling with specific error types
- Rate limiting: Automatic retry with exponential backoff for API rate limits (HTTP 429)
- Network resilience: Retry logic for timeouts and connection errors
- Constants: Configuration values defined as constants for easy customization
- Helper functions: Utility functions like
safe_get_nested()for robust data access - Timeout handling: 30-second timeout on API requests to prevent hanging
- Keyboard interrupt: Graceful handling of Ctrl+C
- Standards compliant: Uses Linear's required API key format (without Bearer prefix) and ISO 8601 datetime format
Make sure you've either:
- Created a
.envfile with your API key (recommended), or - Set the environment variable in your current shell session
You can verify it's set by running:
echo $LINEAR_API_KEY # macOS/Linux
echo %LINEAR_API_KEY% # Windows CMD
echo $env:LINEAR_API_KEY # Windows PowerShellYour API key is invalid or expired. Generate a new key from Linear Settings → API.
Your API key doesn't have permission to read issues. Check your API key permissions in Linear.
If you see "Rate limit hit. Retrying..." messages, the script is working correctly. Linear's API has rate limits to prevent abuse. The script will automatically:
- Wait with exponential backoff (1s, 2s, 4s, 8s, 16s)
- Retry up to 5 times
- Continue fetching once the rate limit clears
This is normal behavior for large workspaces with many issues.
Possible causes:
- No issues were completed in the last 12 months
- All completed issues are in states other than "completed" or "canceled"
- API key doesn't have access to the workspace/teams with issues
MIT License - see LICENSE file for details.
Copyright (c) 2025 24Slides. This software is provided "as is" without warranty of any kind. You are free to use, modify, and distribute this software for any purpose, commercial or non-commercial.