{
  "slug": "aggregate-weather-and-geocoding-apis",
  "title": "Aggregate Weather API and Geocoding API into One Response",
  "metaTitle": "Aggregate Weather API and Geocoding - RealComposer",
  "metaDescription": "Aggregate weather api and geocoding api into one response. Merge OpenWeather in one Frontend / Web call with parallel Worker steps.",
  "headline": "Parallel OpenWeather fetch merged before Frontend / Web hydrates",
  "category": "aggregation",
  "categoryLabel": "Multi-API Aggregation",
  "urgency": 8,
  "clientPlatform": "Frontend / Web",
  "upstreamServices": [
    "OpenWeather"
  ],
  "searchIntentQuery": "aggregate weather api and geocoding api into one response",
  "directAnswerSummary": "Instead of Frontend / Web firing serial fetches to OpenWeather, one pipeline hits https://api.openweathermap.org/data/2.5/weather?q={{query.city}}&appid={{secrets.OPENWEATHER_API_KEY}} (and sibling steps) in parallel and returns mapped JSON.",
  "problem": {
    "title": "Waterfall latency from multiple OpenWeather requests",
    "explanation": "Frontend / Web widgets often await OpenWeather sequentially, multiplying TLS handshakes on cellular networks and amplifying failure rates.",
    "risks": [
      "Race conditions between parallel manual fetches",
      "Higher mobile data usage from redundant JSON",
      "Timeouts when any upstream exceeds cellular RTT"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Bind vault keys to the Worker",
      "description": "Add OPENWEATHER_API_KEY to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream."
    },
    {
      "stepNumber": 2,
      "title": "Set headers, mapping, and cache TTL",
      "description": "Configure headersTemplate to inject vault secrets, target https://api.openweathermap.org/data/2.5/weather?q={{query.city}}&appid={{secrets.OPENWEATHER_API_KEY}}, and Add output mapping fields that mirror the JSON contract your screen already expects."
    },
    {
      "stepNumber": 3,
      "title": "Call from Frontend / Web",
      "description": "Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.",
      "codeSnippet": "const res = await fetch('https://realcomposer.com/v1/workspace/aggregate-weather-and-geocoding-apis', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "Aggregate Weather API and Geocoding API into One Response",
    "method": "GET",
    "cacheTtlSeconds": 0,
    "authMode": "client_token",
    "steps": [
      {
        "stepKey": "weather",
        "upstreamUrlTemplate": "https://api.openweathermap.org/data/2.5/weather?q={{query.city}}&appid={{secrets.OPENWEATHER_API_KEY}}",
        "httpMethod": "GET",
        "headersTemplate": {},
        "timeoutMs": 3000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "temp",
          "sourcePath": "main.temp",
          "type": "number",
          "sourceStep": "weather"
        },
        {
          "targetPath": "city",
          "sourcePath": "name",
          "type": "string",
          "sourceStep": "weather"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_aggregat",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "aggregate-weather-and-geocoding-apis"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "temp": "sample",
    "city": "sample"
  },
  "curlSnippet": "curl -X GET \"https://realcomposer.com/v1/workspace/aggregate-weather-and-geocoding-apis\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "What should Frontend / Web store instead of OpenWeather secrets?",
      "answer": "Point Frontend / Web at /recipes/aggregate-weather-and-geocoding-apis edge URL. RealComposer answers OPTIONS with Access-Control headers for allowed origins."
    },
    {
      "question": "Will Anthropic or Linear prompt bodies be rewritten?",
      "answer": "Cache key for aggregate-weather-and-geocoding-apis: internal edge-cache path plus sorted query. Identical params hit; vary userId per user."
    },
    {
      "question": "What happens if an upstream step times out?",
      "answer": "Rotate vault secrets for aggregate-weather-and-geocoding-apis anytime; clients keep the same rc_live_ token."
    }
  ],
  "relatedRecipeSlugs": [
    "mobile-friendly-api-from-legacy-rest",
    "combine-multiple-apis-into-single-json",
    "slim-github-api-response-mobile-widgets"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/aggregate-weather-and-geocoding-apis",
    "markdown": "https://realcomposer.com/recipes/aggregate-weather-and-geocoding-apis.md",
    "json": "https://realcomposer.com/recipes/aggregate-weather-and-geocoding-apis.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=aggregate-weather-and-geocoding-apis&via=agent"
  }
}