Use GetBasePathMapping with an AWS SDK or command line tool - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use GetBasePathMapping with an AWS SDK or command line tool

The following code examples show how to use GetBasePathMapping.

CLI
AWS CLI

To get the base path mapping for a custom domain name

Command:

aws apigateway get-base-path-mapping --domain-name subdomain.domain.tld --base-path v1

Output:

{ "basePath": "v1", "restApiId": "1234w4321e", "stage": "api" }
PHP
SDK for PHP
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

require 'vendor/autoload.php'; use Aws\ApiGateway\ApiGatewayClient; use Aws\Exception\AwsException; /* //////////////////////////////////////////////////////////////////////////// * Purpose: Gets the base path mapping for a custom domain name in * Amazon API Gateway. * * Prerequisites: A custom domain name in API Gateway. For more information, * see "Custom Domain Names" in the Amazon API Gateway Developer Guide. * * Inputs: * - $apiGatewayClient: An initialized AWS SDK for PHP API client for * API Gateway. * - $basePath: The base path name that callers must provide as part of the * URL after the domain name. * - $domainName: The custom domain name for the base path mapping. * * Returns: The base path mapping, if available; otherwise, the error message. * ///////////////////////////////////////////////////////////////////////// */ function getBasePathMapping($apiGatewayClient, $basePath, $domainName) { try { $result = $apiGatewayClient->getBasePathMapping([ 'basePath' => $basePath, 'domainName' => $domainName, ]); return 'The base path mapping\'s effective URI is: ' . $result['@metadata']['effectiveUri']; } catch (AwsException $e) { return 'Error: ' . $e['message']; } } function getsTheBasePathMapping() { $apiGatewayClient = new ApiGatewayClient([ 'profile' => 'default', 'region' => 'us-east-1', 'version' => '2015-07-09' ]); echo getBasePathMapping($apiGatewayClient, '(none)', 'example.com'); } // Uncomment the following line to run this code in an AWS account. // getsTheBasePathMapping();