DEV Community

Alex Spinov
Alex Spinov

Posted on

Linear Has a Free API — Manage Issues and Projects From Your Terminal

Jira Alternative With a Better API

Linear is a project management tool loved by startups. Free for teams up to 250 issues. Their GraphQL API is clean and well-documented.

Setup

import requests

API_KEY = "lin_api_your_key"  # Settings > API > Personal API Keys
HEADERS = {"Authorization": API_KEY, "Content-Type": "application/json"}
Enter fullscreen mode Exit fullscreen mode

List Your Issues

def my_issues():
    query = """{ issues(filter: { assignee: { isMe: { eq: true } } }) { nodes { title state { name } priority createdAt } } }"""
    r = requests.post("https://api.linear.app/graphql",
                      headers=HEADERS, json={"query": query})
    return r.json()["data"]["issues"]["nodes"]

for issue in my_issues():
    print(f"[{issue[state][name]}] {issue[title]}")
Enter fullscreen mode Exit fullscreen mode

Create an Issue

def create_issue(title, team_id, description="", priority=0):
    mutation = """mutation($input: IssueCreateInput!) { issueCreate(input: $input) { success issue { id title url } } }"""
    variables = {"input": {"title": title, "teamId": team_id, "description": description, "priority": priority}}
    r = requests.post("https://api.linear.app/graphql",
                      headers=HEADERS, json={"query": mutation, "variables": variables})
    return r.json()["data"]["issueCreate"]["issue"]

issue = create_issue("Fix login bug", "team-id-here", "Users report 500 error on login")
print(f"Created: {issue[url]}")
Enter fullscreen mode Exit fullscreen mode

Search Issues

def search_issues(query_text):
    query = """query($q: String!) { searchIssues(term: $q, first: 10) { nodes { title state { name } team { name } } } }"""
    r = requests.post("https://api.linear.app/graphql",
                      headers=HEADERS, json={"query": query, "variables": {"q": query_text}})
    return r.json()["data"]["searchIssues"]["nodes"]
Enter fullscreen mode Exit fullscreen mode

Real Use Cases

  1. CLI tool — create/manage issues from terminal
  2. Slack bot — create issues from Slack messages
  3. GitHub integration — auto-link PRs to issues
  4. Sprint reports — query completed issues per week
  5. Triage automation — auto-assign issues by label

Linear vs Jira API

Feature Linear Jira
API type GraphQL REST
Auth API key OAuth 2.0
Documentation Excellent Complex
Rate limit 400/min Varies
Free tier 250 issues 10 users

More | GitHub


More from me: 10 Dev Tools I Use Daily | 77 Scrapers on a Schedule | 150+ Free APIs

Top comments (0)