Amazon API Gateway REST API Reference

resource:by-id

Gets an API resource of the Resource type for a given resource identifier.

HTTP Request

GET /restapis/<restapi_id>/resources/{resource_id}{?embed}

Template Variable

Response

Resource

Remarks

Example: Get an API resource of a given resource identifier

Request

The following example request retrieves a given API resource:

GET /restapis/fugvjdxtri/resources/3kzxbg5sa2 HTTP/1.1
Content-Type: application/json
Host: apigateway.us-east-1.amazonaws.com
X-Amz-Date: 20170223T025309Z
Authorization: AWS4-HMAC-SHA256 Credential={access_key_ID}/20170223/us-east-1/apigateway/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature={sig4_hash}
Response

The successful response returns the 200 OK status code and a payload similar to the following:

{
  "_links": {
    "curies": [
      {
        "href": "http://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-method-{rel}.html&quot;,
        "name": "method",
        "templated": true
      },
      {
        "href": "http://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-resource-{rel}.html&quot;,
        "name": "resource",
        "templated": true
      }
    ],
    "self": {
      "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2"
    },
    "method:by-http-method": {
      "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/{http_method}",
      "templated": true
    },
    "method:put": {
      "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/{http_method}",
      "templated": true
    },
    "resource:create-child": {
      "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2"
    },
    "resource:methods": {
      "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET",
      "name": "GET",
      "title": "GET"
    },
    "resource:update": {
      "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2"
    }
  },
  "id": "3kzxbg5sa2",
  "path": "/"
}

The result contains only links to further actions that can be performed on the specified API resource. To view a method on this resource with a given HTTP verb, you can follow the resource:methods link returned from the response. Alternatively, you can retrieve all the methods of the resource by using the embed=methods query parameter in the request URL. The following example illustrates this.

Example: Get the method map of a resource

Request

The following example request retrieves a given API resource with embedded methods:

GET /restapis/fugvjdxtri/resources/3kzxbg5sa2?embed=methods HTTP/1.1
Content-Type: application/json
Host: apigateway.us-east-1.amazonaws.com
X-Amz-Date: 20170223T022911Z
Authorization: AWS4-HMAC-SHA256 Credential={access_key_ID}/20170223/us-east-1/apigateway/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature={sig4_hash}
Response

The successful response returns the 200 OK status code and a payload similar to the following:

{
  "_links": {
    "curies": [
      {
        "href": "http://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-integration-{rel}.html&quot;,
        "name": "integration",
        "templated": true
      },
      {
        "href": "http://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-integration-response-{rel}.html&quot;,
        "name": "integrationresponse",
        "templated": true
      },
      {
        "href": "http://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-method-{rel}.html&quot;,
        "name": "method",
        "templated": true
      },
      {
        "href": "http://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-method-response-{rel}.html&quot;,
        "name": "methodresponse",
        "templated": true
      },
      {
        "href": "http://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-resource-{rel}.html&quot;,
        "name": "resource",
        "templated": true
      }
    ],
    "self": {
      "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2"
    },
    "method:by-http-method": {
      "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/{http_method}",
      "templated": true
    },
    "method:put": {
      "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/{http_method}",
      "templated": true
    },
    "resource:create-child": {
      "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2"
    },
    "resource:methods": [
      {
        "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET",
        "name": "GET",
        "title": "GET"
      },
      {
        "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS",
        "name": "OPTIONS",
        "title": "OPTIONS"
      }
    ],
    "resource:update": {
      "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2"
    }
  },
  "id": "3kzxbg5sa2",
  "path": "/",
  "_embedded": {
    "resource:methods": [
      {
        "_links": {
          "self": {
            "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET",
            "name": "GET",
            "title": "GET"
          },
          "integration:put": {
            "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration"
          },
          "method:delete": {
            "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET"
          },
          "method:integration": {
            "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration"
          },
          "method:responses": {
            "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200",
            "name": "200",
            "title": "200"
          },
          "method:update": {
            "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET"
          },
          "methodresponse:put": {
            "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/{status_code}",
            "templated": true
          }
        },
        "apiKeyRequired": false,
        "authorizationType": "NONE",
        "httpMethod": "GET",
        "_embedded": {
          "method:integration": {
            "_links": {
              "self": {
                "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration"
              },
              "integration:delete": {
                "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration"
              },
              "integration:responses": {
                "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200",
                "name": "200",
                "title": "200"
              },
              "integration:update": {
                "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration"
              },
              "integrationresponse:put": {
                "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/{status_code}",
                "templated": true
              }
            },
            "cacheKeyParameters": [],
            "cacheNamespace": "3kzxbg5sa2",
            "credentials": "arn:aws:iam::123456789012:role/apigAwsProxyRole",
            "httpMethod": "POST",
            "passthroughBehavior": "WHEN_NO_MATCH",
            "requestParameters": {
              "integration.request.header.Content-Type": "'application/x-amz-json-1.1'"
            },
            "requestTemplates": {
              "application/json": "{\n}"
            },
            "type": "AWS",
            "uri": "arn:aws:apigateway:us-east-1:kinesis:action/ListStreams",
            "_embedded": {
              "integration:responses": {
                "_links": {
                  "self": {
                    "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200",
                    "name": "200",
                    "title": "200"
                  },
                  "integrationresponse:delete": {
                    "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200"
                  },
                  "integrationresponse:update": {
                    "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200"
                  }
                },
                "responseParameters": {
                  "method.response.header.Content-Type": "'application/xml'"
                },
                "responseTemplates": {
                  "application/json": "$util.urlDecode(\"%3CkinesisStreams%3E#foreach($stream in $input.path('$.StreamNames'))%3Cstream%3E%3Cname%3E$stream%3C/name%3E%3C/stream%3E#end%3C/kinesisStreams%3E\")\n"
                },
                "statusCode": "200"
              }
            }
          },
          "method:responses": {
            "_links": {
              "self": {
                "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200",
                "name": "200",
                "title": "200"
              },
              "methodresponse:delete": {
                "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200"
              },
              "methodresponse:update": {
                "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200"
              }
            },
            "responseModels": {
              "application/json": "Empty"
            },
            "responseParameters": {
              "method.response.header.Content-Type": false
            },
            "statusCode": "200"
          }
        }
      },
      {
        "_links": {
          "self": {
            "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS",
            "name": "OPTIONS",
            "title": "OPTIONS"
          },
          "integration:put": {
            "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS/integration"
          },
          "method:delete": {
            "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS"
          },
          "method:integration": {
            "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS/integration"
          },
          "method:responses": {
            "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS/responses/200",
            "name": "200",
            "title": "200"
          },
          "method:update": {
            "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS"
          },
          "methodresponse:put": {
            "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS/responses/{status_code}",
            "templated": true
          }
        },
        "apiKeyRequired": false,
        "authorizationType": "NONE",
        "httpMethod": "OPTIONS",
        "requestParameters": {},
        "_embedded": {
          "method:integration": {
            "_links": {
              "self": {
                "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS/integration"
              },
              "integration:delete": {
                "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS/integration"
              },
              "integration:responses": {
                "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS/integration/responses/200",
                "name": "200",
                "title": "200"
              },
              "integration:update": {
                "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS/integration"
              },
              "integrationresponse:put": {
                "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS/integration/responses/{status_code}",
                "templated": true
              }
            },
            "cacheKeyParameters": [],
            "cacheNamespace": "3kzxbg5sa2",
            "httpMethod": "OPTIONS",
            "passthroughBehavior": "WHEN_NO_MATCH",
            "type": "HTTP",
            "uri": "http://example.com&quot;,
            "_embedded": {
              "integration:responses": {
                "_links": {
                  "self": {
                    "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS/integration/responses/200",
                    "name": "200",
                    "title": "200"
                  },
                  "integrationresponse:delete": {
                    "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS/integration/responses/200"
                  },
                  "integrationresponse:update": {
                    "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS/integration/responses/200"
                  }
                },
                "responseTemplates": {
                  "application/json": null
                },
                "statusCode": "200"
              }
            }
          },
          "method:responses": {
            "_links": {
              "self": {
                "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS/responses/200",
                "name": "200",
                "title": "200"
              },
              "methodresponse:delete": {
                "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS/responses/200"
              },
              "methodresponse:update": {
                "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/OPTIONS/responses/200"
              }
            },
            "responseModels": {
              "application/json": "Empty"
            },
            "statusCode": "200"
          }
        }
      }
    ]
  }
}

See Also

AWS CLI