Skip to content

APIGatewayProxyEvent

reference
1 min readUpdated

Kind: Interface

Source: src/adapter/aws-lambda/handler.ts

Part of: Adapter

APIGatewayProxyEvent describes the request payload passed from Amazon API Gateway to an AWS Lambda handler. It contains HTTP request data, headers, query parameters, body encoding details, route information, and API Gateway request context.

Properties

PropertyType
versionstring
httpMethodstring
headers`Record<string, string
multiValueHeaders{ [headerKey: string]: string[] }
pathstring
body`string
isBase64Encodedboolean
queryStringParameters`Record<string, string
requestContextApiGatewayRequestContext
resourcestring
multiValueQueryStringParameters{ [parameterKey: string]: string[] }
pathParametersRecord<string, string>
stageVariablesRecord<string, string>

Diagram

mermaid
graph LR
  APIGateway[API Gateway] --> Event[APIGatewayProxyEvent]
  Event --> Method[httpMethod]
  Event --> Route[path and resource]
  Event --> Headers[headers and multiValueHeaders]
  Event --> Query[queryStringParameters]
  Event --> Body[body and isBase64Encoded]
  Event --> Context[requestContext]
  Event --> Lambda[AWS Lambda Handler]

Usage

ts
import type { APIGatewayProxyEvent } from "./adapter/aws-lambda/handler";

export function readRequest(event: APIGatewayProxyEvent) {
  const body =
    event.body === null
      ? undefined
      : event.isBase64Encoded
        ? Buffer.from(event.body, "base64").toString("utf8")
        : event.body;

  return {
    method: event.httpMethod,
    path: event.path,
    contentType: event.headers["content-type"],
    query: event.queryStringParameters,
    body,
    requestContext: event.requestContext,
  };
}

AI Coding Instructions

  • Treat body as nullable and check isBase64Encoded before reading or parsing its contents.
  • Read single-value headers from headers; preserve repeated header values from multiValueHeaders.
  • Handle missing query string and header values because their record values may be undefined.
  • Pass requestContext through to logging, tracing, or authorization code without assuming fields not defined by ApiGatewayRequestContext.

Was this page helpful?

Download as PDF
APIGatewayProxyEvent — Hono (narrator proof)