{
  "slug": "parallel-api-fetch-merge-payload",
  "title": "Call Two REST Apis in Parallel and Return Merged Payload",
  "metaTitle": "Call Two REST Apis in Parallel and - RealComposer",
  "metaDescription": "Call two rest apis in parallel and return merged payload. Merge REST API in one Frontend / Web call with parallel Worker steps.",
  "headline": "One edge call merges REST API for Frontend / Web",
  "category": "aggregation",
  "categoryLabel": "Multi-API Aggregation",
  "urgency": 9,
  "clientPlatform": "Frontend / Web",
  "upstreamServices": [
    "REST API"
  ],
  "searchIntentQuery": "call two rest apis in parallel and return merged payload",
  "directAnswerSummary": "To call two rest apis in parallel and return merged payload, configure parallel steps for REST API. Frontend / Web performs one authorized GET/POST to RealComposer and receives a merged payload.",
  "problem": {
    "title": "Serial REST API calls slow Frontend / Web pages",
    "explanation": "Each extra REST API hop adds hundreds of milliseconds and another OAuth refresh path your UI must manage.",
    "risks": [
      "One slow upstream blocking an entire page",
      "Partial failures leaving UI in inconsistent states",
      "Duplicate auth refresh logic per service"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Add vault secrets for this pipeline",
      "description": "Create API_BEARER_TOKEN vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders."
    },
    {
      "stepNumber": 2,
      "title": "Target the real upstream URL",
      "description": "Use GET against https://jsonplaceholder.typicode.com/posts/1. Allowed origins on the client token should match leave cache ttl at 0 when each response is user-specific (include userid or record id in query params before enabling cache)."
    },
    {
      "stepNumber": 3,
      "title": "Call from Frontend / Web",
      "description": "Allowed origins on the token should list every Frontend / Web host that calls this URL.",
      "codeSnippet": "const res = await fetch('https://realcomposer.com/v1/workspace/parallel-api-fetch-merge-payload', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "Call Two REST Apis in Parallel and Return Merged Payload",
    "method": "GET",
    "cacheTtlSeconds": 0,
    "authMode": "client_token",
    "steps": [
      {
        "stepKey": "posts",
        "upstreamUrlTemplate": "https://jsonplaceholder.typicode.com/posts/1",
        "httpMethod": "GET",
        "headersTemplate": {},
        "timeoutMs": 3000
      },
      {
        "stepKey": "user",
        "upstreamUrlTemplate": "https://jsonplaceholder.typicode.com/users/1",
        "httpMethod": "GET",
        "headersTemplate": {},
        "timeoutMs": 3000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "posts.userId",
          "sourcePath": "id",
          "type": "number",
          "sourceStep": "posts"
        },
        {
          "targetPath": "posts.name",
          "sourcePath": "name",
          "type": "string",
          "sourceStep": "posts"
        },
        {
          "targetPath": "user.userId",
          "sourcePath": "id",
          "type": "number",
          "sourceStep": "user"
        },
        {
          "targetPath": "user.name",
          "sourcePath": "name",
          "type": "string",
          "sourceStep": "user"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_parallel",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "parallel-api-fetch-merge-payload"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "posts_userId": "sample",
    "posts_name": "sample",
    "user_userId": "sample",
    "user_name": "sample"
  },
  "curlSnippet": "curl -X GET \"https://realcomposer.com/v1/workspace/parallel-api-fetch-merge-payload\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "What should Frontend / Web store instead of REST API secrets?",
      "answer": "Yes for parallel-api-fetch-merge-payload. Ship only an rc_live_ client token in Frontend / Web; RealComposer injects API_BEARER_TOKEN on https://jsonplaceholder.typicode.com/posts/1."
    },
    {
      "question": "Will Anthropic or Linear prompt bodies be rewritten?",
      "answer": "parallel-api-fetch-merge-payload forwards client JSON to POST upstreams unchanged; secrets interpolate only in URLs and header templates."
    },
    {
      "question": "Can I restrict which domains call this pipeline?",
      "answer": "Rotate vault secrets for parallel-api-fetch-merge-payload anytime; clients keep the same rc_live_ token."
    }
  ],
  "relatedRecipeSlugs": [
    "flutterflow-backend-for-frontend-tutorial",
    "sendgrid-frontend-proxy",
    "plaid-api-proxy-flutter"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/parallel-api-fetch-merge-payload",
    "markdown": "https://realcomposer.com/recipes/parallel-api-fetch-merge-payload.md",
    "json": "https://realcomposer.com/recipes/parallel-api-fetch-merge-payload.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=parallel-api-fetch-merge-payload&via=agent"
  }
}