# Merge Linear Issues and Github Pull Requests into One Dashboard API

> Instead of Frontend / Web firing serial fetches to Linear and GitHub, one pipeline hits https://api.linear.app/graphql (and sibling steps) in parallel and returns mapped JSON.

- Canonical page: https://realcomposer.com/recipes/merge-linear-and-github-pr-api
- Client platform: Frontend / Web
- Upstream services: Linear, GitHub
- Category: Multi-API Aggregation
- JSON version: https://realcomposer.com/recipes/merge-linear-and-github-pr-api.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=merge-linear-and-github-pr-api&via=agent

## Problem: Waterfall latency from multiple Linear and GitHub requests

Frontend / Web widgets often await Linear and GitHub sequentially, multiplying TLS handshakes on cellular networks and amplifying failure rates.

- Race conditions between parallel manual fetches
- Higher mobile data usage from redundant JSON
- Timeouts when any upstream exceeds cellular RTT

## Solution steps

1. **Store upstream credentials in Secret Vault**: Add LINEAR_API_KEY, GITHUB_TOKEN to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream.

2. **Configure upstream steps and output mapping**: Configure headersTemplate to inject vault secrets, target https://api.linear.app/graphql, and Add output mapping fields that mirror the JSON contract your screen already expects.

3. **Call from Frontend / Web**: Allowed origins on the token should list every Frontend / Web host that calls this URL.

```
const res = await fetch('https://realcomposer.com/v1/workspace/merge-linear-and-github-pr-api', {
  headers: { Authorization: 'Bearer rc_live_your_token' }
});
```

## Pipeline config

Import this config into a RealComposer pipeline. `{{secrets.NAME}}` values are read from the encrypted Secret Vault at request time, so the client never sees them.

```json
{
  "name": "Merge Linear Issues and Github Pull Requests into One Dashboard API",
  "method": "POST",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "linear",
      "upstreamUrlTemplate": "https://api.linear.app/graphql",
      "httpMethod": "POST",
      "headersTemplate": {
        "Authorization": "{{secrets.LINEAR_API_KEY}}",
        "Content-Type": "application/json"
      },
      "timeoutMs": 10000
    },
    {
      "stepKey": "github",
      "upstreamUrlTemplate": "https://api.github.com/user/repos?per_page=5",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.GITHUB_TOKEN}}",
        "Accept": "application/vnd.github+json"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "linear.issueId",
        "sourcePath": "data.issue.id",
        "type": "string",
        "sourceStep": "linear"
      },
      {
        "targetPath": "linear.title",
        "sourcePath": "data.issue.title",
        "type": "string",
        "sourceStep": "linear"
      },
      {
        "targetPath": "github.repoId",
        "sourcePath": "0.id",
        "type": "number",
        "sourceStep": "github"
      },
      {
        "targetPath": "github.fullName",
        "sourcePath": "0.full_name",
        "type": "string",
        "sourceStep": "github"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X POST "https://realcomposer.com/v1/workspace/merge-linear-and-github-pr-api" \
  -H "Authorization: Bearer rc_live_client_token" \
  -H "Content-Type: application/json" \
  -d '{"model":"example"}'
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_merge-li",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "merge-linear-and-github-pr-api"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "linear_issueId": "sample",
  "linear_title": "sample",
  "github_repoId": "sample",
  "github_fullName": "sample"
}
```

## FAQ

### Can Frontend / Web call Linear without holding the production key?

Log request IDs for merge-linear-and-github-pr-api, not raw Linear payloads, because upstream bodies may include PII.

### How do I forward JSON bodies to POST upstreams?

merge-linear-and-github-pr-api keeps cache TTL at 0 because it uses POST upstream calls or per-user responses. Add ids to query strings before enabling GET cache.

### Can I restrict which domains call this pipeline?

Allowed origins on the merge-linear-and-github-pr-api client token restrict which domains may call the edge URL.
