Hathora Cloud API: Welcome to the Hathora Cloud API documentation! Learn how to use the Hathora Cloud APIs to build and scale your game servers globally.
- SDK Installation
- SDK Example Usage
- Available Resources and Operations
- Global Parameters
- Error Handling
- Server Selection
- Authentication
JDK 11 or later is required.
The samples below show how a published SDK artifact is used:
Gradle:
implementation 'dev.hathora:cloud-sdk:2.11.2'
Maven:
<dependency>
<groupId>dev.hathora</groupId>
<artifactId>cloud-sdk</artifactId>
<version>2.11.2</version>
</dependency>
After cloning the git repository to your file system you can build the SDK artifact from source to the build
directory by running ./gradlew build
on *nix systems or gradlew.bat
on Windows systems.
If you wish to build from source and publish the SDK artifact to your local Maven repository (on your filesystem) then use the following command (after cloning the git repo locally):
On *nix:
./gradlew publishToMavenLocal -Pskip.signing
On Windows:
gradlew.bat publishToMavenLocal -Pskip.signing
package hello.world;
import dev.hathora.cloud_sdk.HathoraCloud;
import dev.hathora.cloud_sdk.models.errors.ApiError;
import dev.hathora.cloud_sdk.models.operations.CreateAppResponse;
import dev.hathora.cloud_sdk.models.shared.AppConfig;
import dev.hathora.cloud_sdk.models.shared.AuthConfiguration;
import dev.hathora.cloud_sdk.models.shared.Security;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ApiError, Exception {
HathoraCloud sdk = HathoraCloud.builder()
.security(Security.builder()
.hathoraDevToken("<YOUR_BEARER_TOKEN_HERE>")
.build())
.appId("app-af469a92-5b45-4565-b3c4-b79878de67d2")
.build();
CreateAppResponse res = sdk.appsV2().createApp()
.appConfig(AppConfig.builder()
.appName("minecraft")
.authConfiguration(AuthConfiguration.builder()
.build())
.build())
.orgId("org-6f706e83-0ec1-437a-9a46-7d4281eb2f39")
.call();
if (res.application().isPresent()) {
// handle response
}
}
}
Available methods
createAppV1Deprecated- CreateAppV1Deprecated⚠️ DeprecateddeleteAppV1Deprecated- DeleteAppV1Deprecated⚠️ DeprecatedgetAppInfoV1Deprecated- GetAppInfoV1Deprecated⚠️ DeprecatedgetAppsV1Deprecated- GetAppsV1Deprecated⚠️ DeprecatedupdateAppV1Deprecated- UpdateAppV1Deprecated⚠️ Deprecated
- loginAnonymous - LoginAnonymous
- loginGoogle - LoginGoogle
- loginNickname - LoginNickname
- getBalance - GetBalance
- getInvoices - GetInvoices
- getPaymentMethod - GetPaymentMethod
- getUpcomingInvoiceItems - GetUpcomingInvoiceItems
- getUpcomingInvoiceTotal - GetUpcomingInvoiceTotal
- initStripeCustomerPortalUrl - InitStripeCustomerPortalUrl
createBuildDeprecated- CreateBuildDeprecated⚠️ DeprecateddeleteBuildDeprecated- DeleteBuildDeprecated⚠️ DeprecatedgetBuildInfoDeprecated- GetBuildInfoDeprecated⚠️ DeprecatedgetBuildsDeprecated- GetBuildsDeprecated⚠️ DeprecatedrunBuildDeprecated- RunBuildDeprecated⚠️ Deprecated
createBuildV2Deprecated- CreateBuildV2Deprecated⚠️ DeprecatedcreateBuildWithUploadUrlV2Deprecated- CreateBuildWithUploadUrlV2Deprecated⚠️ DeprecatedcreateWithMultipartUploadsV2Deprecated- CreateWithMultipartUploadsV2Deprecated⚠️ DeprecateddeleteBuildV2Deprecated- DeleteBuildV2Deprecated⚠️ DeprecatedgetBuildInfoV2Deprecated- GetBuildInfoV2Deprecated⚠️ DeprecatedgetBuildsV2Deprecated- GetBuildsV2Deprecated⚠️ DeprecatedrunBuildV2Deprecated- RunBuildV2Deprecated⚠️ Deprecated
- createBuild - CreateBuild
- deleteBuild - DeleteBuild
- getBuild - GetBuild
- getBuilds - GetBuilds
- runBuild - RunBuild
createDeploymentV1Deprecated- CreateDeploymentV1Deprecated⚠️ DeprecatedgetDeploymentInfoV1Deprecated- GetDeploymentInfoV1Deprecated⚠️ DeprecatedgetDeploymentsV1Deprecated- GetDeploymentsV1Deprecated⚠️ DeprecatedgetLatestDeploymentV1Deprecated- GetLatestDeploymentV1Deprecated⚠️ Deprecated
createDeploymentV2Deprecated- CreateDeploymentV2Deprecated⚠️ DeprecatedgetDeploymentInfoV2Deprecated- GetDeploymentInfoV2Deprecated⚠️ DeprecatedgetDeploymentsV2Deprecated- GetDeploymentsV2Deprecated⚠️ DeprecatedgetLatestDeploymentV2Deprecated- GetLatestDeploymentV2Deprecated⚠️ Deprecated
- createDeployment - CreateDeployment
- getDeployment - GetDeployment
- getDeployments - GetDeployments
- getLatestDeployment - GetLatestDeployment
getPingServiceEndpointsDeprecated- GetPingServiceEndpointsDeprecated⚠️ Deprecated
- getPingServiceEndpoints - GetPingServiceEndpoints
- getFleetMetrics - GetFleetMetrics
- getFleetRegion - GetFleetRegion
- getFleets - GetFleets
- updateFleetRegion - UpdateFleetRegion
createPrivateLobbyDeprecated- CreatePrivateLobbyDeprecated⚠️ DeprecatedcreatePublicLobbyDeprecated- CreatePublicLobbyDeprecated⚠️ DeprecatedlistActivePublicLobbiesDeprecatedV1- ListActivePublicLobbiesDeprecatedV1⚠️ Deprecated
createLobbyDeprecated- CreateLobbyDeprecated⚠️ DeprecatedcreateLocalLobby- CreateLocalLobby⚠️ DeprecatedcreatePrivateLobby- CreatePrivateLobby⚠️ DeprecatedcreatePublicLobby- CreatePublicLobby⚠️ DeprecatedgetLobbyInfo- GetLobbyInfo⚠️ DeprecatedlistActivePublicLobbiesDeprecatedV2- ListActivePublicLobbiesDeprecatedV2⚠️ DeprecatedsetLobbyState- SetLobbyState⚠️ Deprecated
- createLobby - CreateLobby
- getLobbyInfoByRoomId - GetLobbyInfoByRoomId
- getLobbyInfoByShortCode - GetLobbyInfoByShortCode
- listActivePublicLobbies - ListActivePublicLobbies
- downloadLogForProcess - DownloadLogForProcess
- getLogsForProcess - GetLogsForProcess
- sendVerificationEmail - SendVerificationEmail
getMetricsDeprecated- GetMetricsDeprecated⚠️ Deprecated
- acceptInvite - AcceptInvite
- getOrgMembers - GetOrgMembers
- getOrgPendingInvites - GetOrgPendingInvites
- getOrgs - GetOrgs
- getUsageLimits - GetUsageLimits
- getUserPendingInvites - GetUserPendingInvites
- inviteUser - InviteUser
- rejectInvite - RejectInvite
- rescindInvite - RescindInvite
getProcessInfoDeprecated- GetProcessInfoDeprecated⚠️ DeprecatedgetRunningProcesses- GetRunningProcesses⚠️ DeprecatedgetStoppedProcesses- GetStoppedProcesses⚠️ Deprecated
createProcessV2Deprecated- CreateProcessV2Deprecated⚠️ DeprecatedgetLatestProcessesV2Deprecated- GetLatestProcessesV2Deprecated⚠️ DeprecatedgetProcessInfoV2Deprecated- GetProcessInfoV2Deprecated⚠️ DeprecatedgetProcessesCountExperimentalV2Deprecated- GetProcessesCountExperimentalV2Deprecated⚠️ DeprecatedstopProcessV2Deprecated- StopProcessV2Deprecated⚠️ Deprecated
- createProcess - CreateProcess
- getLatestProcesses - GetLatestProcesses
- getProcess - GetProcess
- getProcessMetrics - GetProcessMetrics
- getProcessesCountExperimental - GetProcessesCountExperimental
- stopProcess - StopProcess
createRoomDeprecated- CreateRoomDeprecated⚠️ DeprecateddestroyRoomDeprecated- DestroyRoomDeprecated⚠️ DeprecatedgetActiveRoomsForProcessDeprecated- GetActiveRoomsForProcessDeprecated⚠️ DeprecatedgetConnectionInfoDeprecated- GetConnectionInfoDeprecated⚠️ DeprecatedgetInactiveRoomsForProcessDeprecated- GetInactiveRoomsForProcessDeprecated⚠️ DeprecatedgetRoomInfoDeprecated- GetRoomInfoDeprecated⚠️ DeprecatedsuspendRoomDeprecated- SuspendRoomDeprecated⚠️ Deprecated
- createRoom - CreateRoom
- destroyRoom - DestroyRoom
- getActiveRoomsForProcess - GetActiveRoomsForProcess
- getConnectionInfo - GetConnectionInfo
- getInactiveRoomsForProcess - GetInactiveRoomsForProcess
- getRoomInfo - GetRoomInfo
suspendRoomV2Deprecated- SuspendRoomV2Deprecated⚠️ Deprecated- updateRoomConfig - UpdateRoomConfig
- createOrgToken - CreateOrgToken
- getOrgTokens - GetOrgTokens
- revokeOrgToken - RevokeOrgToken
A parameter is configured globally. This parameter may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed.
For example, you can set appId
to "app-af469a92-5b45-4565-b3c4-b79878de67d2"
at SDK initialization and then you do not have to pass the same value on calls to operations like deleteApp
. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.
The following global parameter is available.
Name | Type | Description |
---|---|---|
appId | java.lang.String | The appId parameter. |
package hello.world;
import dev.hathora.cloud_sdk.HathoraCloud;
import dev.hathora.cloud_sdk.models.errors.ApiError;
import dev.hathora.cloud_sdk.models.operations.DeleteAppResponse;
import dev.hathora.cloud_sdk.models.shared.Security;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ApiError, Exception {
HathoraCloud sdk = HathoraCloud.builder()
.security(Security.builder()
.hathoraDevToken("<YOUR_BEARER_TOKEN_HERE>")
.build())
.appId("app-af469a92-5b45-4565-b3c4-b79878de67d2")
.build();
DeleteAppResponse res = sdk.appsV2().deleteApp()
.appId("app-af469a92-5b45-4565-b3c4-b79878de67d2")
.call();
// handle response
}
}
Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.
By default, an API error will throw a models/errors/SDKError
exception. When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the createApp
method throws the following exceptions:
Error Type | Status Code | Content Type |
---|---|---|
models/errors/ApiError | 401, 404, 422, 429, 500 | application/json |
models/errors/SDKError | 4XX, 5XX | */* |
package hello.world;
import dev.hathora.cloud_sdk.HathoraCloud;
import dev.hathora.cloud_sdk.models.errors.ApiError;
import dev.hathora.cloud_sdk.models.operations.CreateAppResponse;
import dev.hathora.cloud_sdk.models.shared.AppConfig;
import dev.hathora.cloud_sdk.models.shared.AuthConfiguration;
import dev.hathora.cloud_sdk.models.shared.Security;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ApiError, Exception {
HathoraCloud sdk = HathoraCloud.builder()
.security(Security.builder()
.hathoraDevToken("<YOUR_BEARER_TOKEN_HERE>")
.build())
.appId("app-af469a92-5b45-4565-b3c4-b79878de67d2")
.build();
CreateAppResponse res = sdk.appsV2().createApp()
.appConfig(AppConfig.builder()
.appName("minecraft")
.authConfiguration(AuthConfiguration.builder()
.build())
.build())
.orgId("org-6f706e83-0ec1-437a-9a46-7d4281eb2f39")
.call();
if (res.application().isPresent()) {
// handle response
}
}
}
You can override the default server globally using the .serverIndex(int serverIdx)
builder method when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
# | Server |
---|---|
0 | https://api.hathora.dev |
1 | https:/// |
package hello.world;
import dev.hathora.cloud_sdk.HathoraCloud;
import dev.hathora.cloud_sdk.models.errors.ApiError;
import dev.hathora.cloud_sdk.models.operations.CreateAppResponse;
import dev.hathora.cloud_sdk.models.shared.AppConfig;
import dev.hathora.cloud_sdk.models.shared.AuthConfiguration;
import dev.hathora.cloud_sdk.models.shared.Security;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ApiError, Exception {
HathoraCloud sdk = HathoraCloud.builder()
.serverIndex(1)
.security(Security.builder()
.hathoraDevToken("<YOUR_BEARER_TOKEN_HERE>")
.build())
.appId("app-af469a92-5b45-4565-b3c4-b79878de67d2")
.build();
CreateAppResponse res = sdk.appsV2().createApp()
.appConfig(AppConfig.builder()
.appName("minecraft")
.authConfiguration(AuthConfiguration.builder()
.build())
.build())
.orgId("org-6f706e83-0ec1-437a-9a46-7d4281eb2f39")
.call();
if (res.application().isPresent()) {
// handle response
}
}
}
The default server can also be overridden globally using the .serverURL(String serverUrl)
builder method when initializing the SDK client instance. For example:
package hello.world;
import dev.hathora.cloud_sdk.HathoraCloud;
import dev.hathora.cloud_sdk.models.errors.ApiError;
import dev.hathora.cloud_sdk.models.operations.CreateAppResponse;
import dev.hathora.cloud_sdk.models.shared.AppConfig;
import dev.hathora.cloud_sdk.models.shared.AuthConfiguration;
import dev.hathora.cloud_sdk.models.shared.Security;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ApiError, Exception {
HathoraCloud sdk = HathoraCloud.builder()
.serverURL("https://api.hathora.dev")
.security(Security.builder()
.hathoraDevToken("<YOUR_BEARER_TOKEN_HERE>")
.build())
.appId("app-af469a92-5b45-4565-b3c4-b79878de67d2")
.build();
CreateAppResponse res = sdk.appsV2().createApp()
.appConfig(AppConfig.builder()
.appName("minecraft")
.authConfiguration(AuthConfiguration.builder()
.build())
.build())
.orgId("org-6f706e83-0ec1-437a-9a46-7d4281eb2f39")
.call();
if (res.application().isPresent()) {
// handle response
}
}
}
This SDK supports the following security scheme globally:
Name | Type | Scheme |
---|---|---|
hathoraDevToken |
http | HTTP Bearer |
You can set the security parameters through the security
builder method when initializing the SDK client instance. For example:
package hello.world;
import dev.hathora.cloud_sdk.HathoraCloud;
import dev.hathora.cloud_sdk.models.errors.ApiError;
import dev.hathora.cloud_sdk.models.operations.CreateAppResponse;
import dev.hathora.cloud_sdk.models.shared.AppConfig;
import dev.hathora.cloud_sdk.models.shared.AuthConfiguration;
import dev.hathora.cloud_sdk.models.shared.Security;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ApiError, Exception {
HathoraCloud sdk = HathoraCloud.builder()
.security(Security.builder()
.hathoraDevToken("<YOUR_BEARER_TOKEN_HERE>")
.build())
.appId("app-af469a92-5b45-4565-b3c4-b79878de67d2")
.build();
CreateAppResponse res = sdk.appsV2().createApp()
.appConfig(AppConfig.builder()
.appName("minecraft")
.authConfiguration(AuthConfiguration.builder()
.build())
.build())
.orgId("org-6f706e83-0ec1-437a-9a46-7d4281eb2f39")
.call();
if (res.application().isPresent()) {
// handle response
}
}
}
Some operations in this SDK require the security scheme to be specified at the request level. For example:
package hello.world;
import dev.hathora.cloud_sdk.HathoraCloud;
import dev.hathora.cloud_sdk.models.errors.ApiError;
import dev.hathora.cloud_sdk.models.operations.CreateLobbyRequest;
import dev.hathora.cloud_sdk.models.operations.CreateLobbyResponse;
import dev.hathora.cloud_sdk.models.operations.CreateLobbySecurity;
import dev.hathora.cloud_sdk.models.shared.CreateLobbyV3Params;
import dev.hathora.cloud_sdk.models.shared.LobbyVisibility;
import dev.hathora.cloud_sdk.models.shared.Region;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ApiError, Exception {
HathoraCloud sdk = HathoraCloud.builder()
.appId("app-af469a92-5b45-4565-b3c4-b79878de67d2")
.build();
CreateLobbyRequest req = CreateLobbyRequest.builder()
.createLobbyV3Params(CreateLobbyV3Params.builder()
.region(Region.SEATTLE)
.visibility(LobbyVisibility.PRIVATE)
.roomConfig("{\"name\":\"my-room\"}")
.build())
.roomId("2swovpy1fnunu")
.shortCode("LFG4")
.build();
CreateLobbyResponse res = sdk.lobbiesV3().createLobby()
.request(req)
.security(CreateLobbySecurity.builder()
.playerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build())
.call();
if (res.lobbyV3().isPresent()) {
// handle response
}
}
}
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release !