AWS SDK for JavaScript GameLift Client for Node.js, Browser and React Native.
Amazon GameLift provides solutions for hosting session-based multiplayer game servers in the
cloud, including tools for deploying, operating, and scaling game servers. Built on
Amazon Web Services global computing infrastructure, GameLift helps you deliver high-performance,
high-reliability, low-cost game servers while dynamically scaling your resource usage to
meet player demand.
About Amazon GameLift solutions
Get more information on these Amazon GameLift solutions in the Amazon GameLift Developer Guide.
-
Amazon GameLift managed hosting -- Amazon GameLift offers a fully managed service to set up
and maintain computing machines for hosting, manage game session and player
session life cycle, and handle security, storage, and performance tracking. You
can use automatic scaling tools to balance player demand and hosting costs,
configure your game session management to minimize player latency, and add
FlexMatch for matchmaking.
-
Managed hosting with Amazon GameLift Realtime -- With Amazon GameLift Amazon GameLift Realtime, you can quickly configure
and set up ready-to-go game servers for your game. Amazon GameLift Realtime provides a game server
framework with core Amazon GameLift infrastructure already built in. Then use the full
range of Amazon GameLift managed hosting features, including FlexMatch, for your
game.
-
Amazon GameLift FleetIQ -- Use Amazon GameLift FleetIQ as a standalone service while hosting your games using EC2
instances and Auto Scaling groups. Amazon GameLift FleetIQ provides optimizations for game
hosting, including boosting the viability of low-cost Spot Instances gaming. For
a complete solution, pair the Amazon GameLift FleetIQ and FlexMatch standalone services.
-
Amazon GameLift FlexMatch -- Add matchmaking to your game hosting solution. FlexMatch is a
customizable matchmaking service for multiplayer games. Use FlexMatch as
integrated with Amazon GameLift managed hosting or incorporate FlexMatch as a standalone
service into your own hosting solution.
About this API Reference
This reference guide describes the low-level service API for Amazon GameLift. With each topic
in this guide, you can find links to language-specific SDK guides and the Amazon Web Services CLI
reference. Useful links:
To install this package, simply type add or install @aws-sdk/client-gamelift
using your favorite package manager:
npm install @aws-sdk/client-gamelift
yarn add @aws-sdk/client-gamelift
pnpm add @aws-sdk/client-gamelift
The AWS SDK is modulized by clients and commands.
To send a request, you only need to import the GameLiftClient
and
the commands you need, for example ListAliasesCommand
:
// ES5 example
const { GameLiftClient, ListAliasesCommand } = require("@aws-sdk/client-gamelift");
// ES6+ example
import { GameLiftClient, ListAliasesCommand } from "@aws-sdk/client-gamelift";
To send a request, you:
- Initiate client with configuration (e.g. credentials, region).
- Initiate command with input parameters.
- Call
send
operation on client with command object as input.
- If you are using a custom http handler, you may call
destroy()
to close open connections.
// a client can be shared by different commands.
const client = new GameLiftClient({ region: "REGION" });
const params = {
/** input parameters */
};
const command = new ListAliasesCommand(params);
We recommend using await
operator to wait for the promise returned by send operation as follows:
// async/await.
try {
const data = await client.send(command);
// process data.
} catch (error) {
// error handling.
} finally {
// finally.
}
Async-await is clean, concise, intuitive, easy to debug and has better error handling
as compared to using Promise chains or callbacks.
You can also use Promise chaining
to execute send operation.
client.send(command).then(
(data) => {
// process data.
},
(error) => {
// error handling.
}
);
Promises can also be called using .catch()
and .finally()
as follows:
client
.send(command)
.then((data) => {
// process data.
})
.catch((error) => {
// error handling.
})
.finally(() => {
// finally.
});
We do not recommend using callbacks because of callback hell,
but they are supported by the send operation.
// callbacks.
client.send(command, (err, data) => {
// process err and data.
});
The client can also send requests using v2 compatible style.
However, it results in a bigger bundle size and may be dropped in next major version. More details in the blog post
on modular packages in AWS SDK for JavaScript
import * as AWS from "@aws-sdk/client-gamelift";
const client = new AWS.GameLift({ region: "REGION" });
// async/await.
try {
const data = await client.listAliases(params);
// process data.
} catch (error) {
// error handling.
}
// Promises.
client
.listAliases(params)
.then((data) => {
// process data.
})
.catch((error) => {
// error handling.
});
// callbacks.
client.listAliases(params, (err, data) => {
// process err and data.
});
When the service returns an exception, the error will include the exception information,
as well as response metadata (e.g. request id).
try {
const data = await client.send(command);
// process data.
} catch (error) {
const { requestId, cfId, extendedRequestId } = error.$metadata;
console.log({ requestId, cfId, extendedRequestId });
/**
* The keys within exceptions are also parsed.
* You can access them by specifying exception names:
* if (error.name === 'SomeServiceException') {
* const value = error.specialKeyInException;
* }
*/
}
Please use these community resources for getting help.
We use the GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.
To test your universal JavaScript code in Node.js, browser and react-native environments,
visit our code samples repo.
This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-gamelift
package is updated.
To contribute to client you can check our generate clients scripts.
This SDK is distributed under the
Apache License, Version 2.0,
see LICENSE for more information.
Client Commands (Operations List)
AcceptMatch
Command API Reference / Input / Output
ClaimGameServer
Command API Reference / Input / Output
CreateAlias
Command API Reference / Input / Output
CreateBuild
Command API Reference / Input / Output
CreateContainerFleet
Command API Reference / Input / Output
CreateContainerGroupDefinition
Command API Reference / Input / Output
CreateFleet
Command API Reference / Input / Output
CreateFleetLocations
Command API Reference / Input / Output
CreateGameServerGroup
Command API Reference / Input / Output
CreateGameSession
Command API Reference / Input / Output
CreateGameSessionQueue
Command API Reference / Input / Output
CreateLocation
Command API Reference / Input / Output
CreateMatchmakingConfiguration
Command API Reference / Input / Output
CreateMatchmakingRuleSet
Command API Reference / Input / Output
CreatePlayerSession
Command API Reference / Input / Output
CreatePlayerSessions
Command API Reference / Input / Output
CreateScript
Command API Reference / Input / Output
CreateVpcPeeringAuthorization
Command API Reference / Input / Output
CreateVpcPeeringConnection
Command API Reference / Input / Output
DeleteAlias
Command API Reference / Input / Output
DeleteBuild
Command API Reference / Input / Output
DeleteContainerFleet
Command API Reference / Input / Output
DeleteContainerGroupDefinition
Command API Reference / Input / Output
DeleteFleet
Command API Reference / Input / Output
DeleteFleetLocations
Command API Reference / Input / Output
DeleteGameServerGroup
Command API Reference / Input / Output
DeleteGameSessionQueue
Command API Reference / Input / Output
DeleteLocation
Command API Reference / Input / Output
DeleteMatchmakingConfiguration
Command API Reference / Input / Output
DeleteMatchmakingRuleSet
Command API Reference / Input / Output
DeleteScalingPolicy
Command API Reference / Input / Output
DeleteScript
Command API Reference / Input / Output
DeleteVpcPeeringAuthorization
Command API Reference / Input / Output
DeleteVpcPeeringConnection
Command API Reference / Input / Output
DeregisterCompute
Command API Reference / Input / Output
DeregisterGameServer
Command API Reference / Input / Output
DescribeAlias
Command API Reference / Input / Output
DescribeBuild
Command API Reference / Input / Output
DescribeCompute
Command API Reference / Input / Output
DescribeContainerFleet
Command API Reference / Input / Output
DescribeContainerGroupDefinition
Command API Reference / Input / Output
DescribeEC2InstanceLimits
Command API Reference / Input / Output
DescribeFleetAttributes
Command API Reference / Input / Output
DescribeFleetCapacity
Command API Reference / Input / Output
DescribeFleetDeployment
Command API Reference / Input / Output
DescribeFleetEvents
Command API Reference / Input / Output
DescribeFleetLocationAttributes
Command API Reference / Input / Output
DescribeFleetLocationCapacity
Command API Reference / Input / Output
DescribeFleetLocationUtilization
Command API Reference / Input / Output
DescribeFleetPortSettings
Command API Reference / Input / Output
DescribeFleetUtilization
Command API Reference / Input / Output
DescribeGameServer
Command API Reference / Input / Output
DescribeGameServerGroup
Command API Reference / Input / Output
DescribeGameServerInstances
Command API Reference / Input / Output
DescribeGameSessionDetails
Command API Reference / Input / Output
DescribeGameSessionPlacement
Command API Reference / Input / Output
DescribeGameSessionQueues
Command API Reference / Input / Output
DescribeGameSessions
Command API Reference / Input / Output
DescribeInstances
Command API Reference / Input / Output
DescribeMatchmaking
Command API Reference / Input / Output
DescribeMatchmakingConfigurations
Command API Reference / Input / Output
DescribeMatchmakingRuleSets
Command API Reference / Input / Output
DescribePlayerSessions
Command API Reference / Input / Output
DescribeRuntimeConfiguration
Command API Reference / Input / Output
DescribeScalingPolicies
Command API Reference / Input / Output
DescribeScript
Command API Reference / Input / Output
DescribeVpcPeeringAuthorizations
Command API Reference / Input / Output
DescribeVpcPeeringConnections
Command API Reference / Input / Output
GetComputeAccess
Command API Reference / Input / Output
GetComputeAuthToken
Command API Reference / Input / Output
GetGameSessionLogUrl
Command API Reference / Input / Output
GetInstanceAccess
Command API Reference / Input / Output
ListAliases
Command API Reference / Input / Output
ListBuilds
Command API Reference / Input / Output
ListCompute
Command API Reference / Input / Output
ListContainerFleets
Command API Reference / Input / Output
ListContainerGroupDefinitions
Command API Reference / Input / Output
ListContainerGroupDefinitionVersions
Command API Reference / Input / Output
ListFleetDeployments
Command API Reference / Input / Output
ListFleets
Command API Reference / Input / Output
ListGameServerGroups
Command API Reference / Input / Output
ListGameServers
Command API Reference / Input / Output
ListLocations
Command API Reference / Input / Output
ListScripts
Command API Reference / Input / Output
ListTagsForResource
Command API Reference / Input / Output
PutScalingPolicy
Command API Reference / Input / Output
RegisterCompute
Command API Reference / Input / Output
RegisterGameServer
Command API Reference / Input / Output
RequestUploadCredentials
Command API Reference / Input / Output
ResolveAlias
Command API Reference / Input / Output
ResumeGameServerGroup
Command API Reference / Input / Output
SearchGameSessions
Command API Reference / Input / Output
StartFleetActions
Command API Reference / Input / Output
StartGameSessionPlacement
Command API Reference / Input / Output
StartMatchBackfill
Command API Reference / Input / Output
StartMatchmaking
Command API Reference / Input / Output
StopFleetActions
Command API Reference / Input / Output
StopGameSessionPlacement
Command API Reference / Input / Output
StopMatchmaking
Command API Reference / Input / Output
SuspendGameServerGroup
Command API Reference / Input / Output
TagResource
Command API Reference / Input / Output
TerminateGameSession
Command API Reference / Input / Output
UntagResource
Command API Reference / Input / Output
UpdateAlias
Command API Reference / Input / Output
UpdateBuild
Command API Reference / Input / Output
UpdateContainerFleet
Command API Reference / Input / Output
UpdateContainerGroupDefinition
Command API Reference / Input / Output
UpdateFleetAttributes
Command API Reference / Input / Output
UpdateFleetCapacity
Command API Reference / Input / Output
UpdateFleetPortSettings
Command API Reference / Input / Output
UpdateGameServer
Command API Reference / Input / Output
UpdateGameServerGroup
Command API Reference / Input / Output
UpdateGameSession
Command API Reference / Input / Output
UpdateGameSessionQueue
Command API Reference / Input / Output
UpdateMatchmakingConfiguration
Command API Reference / Input / Output
UpdateRuntimeConfiguration
Command API Reference / Input / Output
UpdateScript
Command API Reference / Input / Output
ValidateMatchmakingRuleSet
Command API Reference / Input / Output