{"id":27443060,"url":"https://github.com/accelbyte/accelbyte-typescript-sdk","last_synced_at":"2026-04-13T03:22:50.884Z","repository":{"id":61299349,"uuid":"546787252","full_name":"AccelByte/accelbyte-typescript-sdk","owner":"AccelByte","description":"AGS TypeScript SDK is a platform agnostic JavaScript library enabling the building of web applications using AGS API","archived":false,"fork":false,"pushed_at":"2025-03-28T06:48:04.000Z","size":10406,"stargazers_count":5,"open_issues_count":1,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-15T01:18:32.038Z","etag":null,"topics":["javascript","nodejs","sdk","typescript"],"latest_commit_sha":null,"homepage":"https://accelbyte.github.io/accelbyte-typescript-sdk/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AccelByte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-06T16:38:42.000Z","updated_at":"2025-03-28T06:47:40.000Z","dependencies_parsed_at":"2023-10-05T13:45:34.070Z","dependency_job_id":"2b685782-3397-448a-ae72-dde2cbff9469","html_url":"https://github.com/AccelByte/accelbyte-typescript-sdk","commit_stats":null,"previous_names":["accelbyte/accelbyte-typescript-sdk","accelbyte/accelbyte-web-sdk"],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelByte%2Faccelbyte-typescript-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelByte%2Faccelbyte-typescript-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelByte%2Faccelbyte-typescript-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelByte%2Faccelbyte-typescript-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AccelByte","download_url":"https://codeload.github.com/AccelByte/accelbyte-typescript-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248986316,"owners_count":21194025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","nodejs","sdk","typescript"],"created_at":"2025-04-15T01:18:47.517Z","updated_at":"2026-01-05T07:26:32.455Z","avatar_url":"https://github.com/AccelByte.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AccelByte Gaming Services (AGS) TypeScript SDK\n\n\u003e **Note**: The AccelByte Gaming Service (AGS) Typescript SDK is still under development. Some Extend SDK features may not be available yet.\n\nThe AGS TypeScript SDK is a versatile library for building web applications using AccelByte API services. It is platform-agnostic, making it suitable for both browser and server environments. Developed with TypeScript, the SDK emphasizes strict type safety, providing robust runtime type-checking to help you confidently work with AccelByte Gaming Service (AGS) type definitions.\n\nThis guide will walk you through getting started with the AGS TypeScript SDK, including installation and usage instructions.\n\n## Installing AGS TypeScript SDK\n\nWe recommend installing the TypeScript SDK via npm using your preferred package manager. Open your terminal and run this command:\n\n```bash\nnpm install @accelbyte/sdk @accelbyte/sdk-iam @accelbyte/sdk-basic # Add more SDK packages as needed\n```\n\n\u003e **Important:** You must specifically install `@accelbyte/sdk` in your project as it has been moved to `peerDependencies` in other `@accelbyte/sdk-*` packages. This ensures that the core SDK is shared across all related modules.\n\n_Optional_: If you plan to use our generated React Query hooks, you'll also need to install `@tanstack/react-query`.\n\n```bash\nnpm install @tanstack/react-query\n```\n\nRefer to the [AccelByte APIs](#accelbyte-apis) section to see the full list of services and SDK offered by AccelByte.\n\n## Using AGS Typescript SDK\n\nTo begin using the AGS TypeScript SDK, you'll need to instantiate it with some basic configuration, including an IAM Client ID (`clientId`) and other core settings. Depending on your application, you may want to store environment variables in a `.env` file and load them using your development tools (e.g., via `process.env.ENV_KEY`).\n\n```js\nimport { AccelByte } from '@accelbyte/sdk';\n\nconst sdk = await AccelByte.SDK({\n  coreConfig: {\n    baseURL: \"\u003cYour publisher base URL, e.g. \u003chttps://prod.gamingservices.accelbyte.io\u003e\u003e\",\n    clientId: \"\u003cYour publisher Client ID, e.g. 32_char_guid\u003e\",\n    redirectURI: \"\u003cYour publisher Redirect URL, e.g. \u003chttps://prod.gamingservices.accelbyte.io\u003e\u003e\",\n    namespace: \"\u003cYour publisher namespace, e.g. 'accelbyte'\u003e\"\n  },\n  axiosConfig: {\n    interceptors: [\n      {\n        type: 'response',\n        name: 'disconnected',\n        onError: e =\u003e {\n          const error = e as AxiosError;\n          const { config, response } = error;\n          if (!response) {\n            console.warn(`sdk:ERR_INTERNET_DISCONNECTED ${config?.baseURL}${config?.url}. ${error.message}\\n`);\n          }\n          return Promise.reject(error);\n        }\n      }\n    ],\n    request: {\n      withCredentials: true // If true, cookies will be sent automatically with requests.\n    }\n  }\n});\n```\n\n### Configuration breakdown\n\n\u003e **Note:** When setting up IAM Clients, ensure that you include an additional Redirect URI with the format `{studio-namespace}.prod.gamingservices.accelbyte.io` (e.g., `accelbyte.prod.gamingservices.accelbyte.io`).\n\n- **coreConfig**:\n\n  - `baseURL`: The base URL for your AGS deployment. This is the starting point for all API requests.\n  - `clientId`: The client ID. This is required for authentication with the IAM service. For more information about creating IAM clients, refer to the [AGS Documentation Portal](https://docs.accelbyte.io/gaming-services/services/access/authorization/manage-access-control-for-applications/#create-an-iam-client).\n  - `redirectURI`: The URL to which users will be redirected after logging in.\n  - `namespace`: The namespace for your AGS deployment, which helps in scoping API requests.\n\n- **axiosConfig** (optional):\n  - `interceptors`: Custom Axios interceptors to manage request and response behaviors. For example, you can add an interceptor to handle network errors.\n  - `request`: Configuration for Axios request, such as setting `withCredentials` to `true` to include cookies automatically. For more information, refer to the [Axios documentation](https://axios-http.com/docs/req_config). Using cookies can help prevent unauthorized access, protect against Cross-Site Request Forgery (CSRF) attacks, and ensure that resources are only accessed by legitimate referrers.\n\n## Interacting with AGS\n\nThis is a sample code snippet demonstrating how to use the SDK to interact with AGS:\n\n```js\nimport { IamUserAuthorizationClient } from '@accelbyte/sdk-iam'\nimport { UserProfileApi } from '@accelbyte/sdk-basic'\n// Log in to IAM using an authorization code\nconst token = await new IamUserAuthorizationClient(sdk).loginWithAuthorizationCode({ code, codeVerifier })\n// Retrieve the current user profile\nconst userProfile = await UsersAdminApi(sdk).getUsersMe_v3()\n```\n\n## Integrating React Query\n\n\u003e **Note:** This is a browser-only integration.\n\nIf you're using `@tanstack/react-query` to manage server state, the AGS SDK offers seamless integration through generated queries and mutations. This allows you to efficiently fetch, update, and manage data while leveraging React Query's powerful features like caching, automatic retries, and query invalidation.\n\n### Query example\n\nTo retrieve data using a generated query, you can use one of the SDK's hooks. The query key used in invalidation can be found within the generated queries.\n\n```js\nimport { useUsersAdminApi_GetUsersMe_v3 } from '@accelbyte/sdk-iam'\n\nconst usersQuery = useUsersAdminApi_GetUsersMe_v3(\n  sdk,\n  { coreConfig: { namespace }, axiosConfig: {} },\n  {\n    retry: 2 // Retry the request twice before failing\n  }\n)\n\nconsole.log(usersQuery.data)\n```\n\nEach generated query comes with unique query keys that you can use for query invalidation when it's necessary to refresh the data. You can view these keys by hovering over the generated query, as shown below:\n\n![generated react query key on hover](./docs/react-query-key-on-hover.png)\n\n### Mutation Example\n\nTo perform data mutations (e.g., creating, updating, or deleting resources), use one of the generated mutation hooks:\n\n```js\nimport { useUsersAdminApi_UpdateUser_v3 } from '@accelbyte/sdk-iam';\nimport { useQueryClient } from '@tanstack/react-query';\n\nconst queryClient = useQueryClient();\n\nconst updateUserMutation = useUsersAdminApi_UpdateUserMutation_v3(\n  sdk,\n  {\n    onSuccess: (data) =\u003e {\n      console.log('User data updated:', data);\n      // Invalidate the query to refetch the updated data\n      queryClient.invalidateQueries({queryKey: [Key_UsersAdmin.User_v3]);\n    },\n    onError: (error) =\u003e console.error('Error updating user data:', error),\n  }\n);\n\nupdateUserMutation.mutate({ namespace, data: {/* updated user data */} });\n```\n\nIn the example above, after a successful mutation, the corresponding query is invalidated using `queryClient.invalidateQueries({queryKey: [Key_UsersAdmin.User_v3] })`. This triggers a refetch to ensure the UI reflects the latest data.\n\nThese hooks provide a robust way to interact with AGS, making it easier to handle data fetching and state management within your React applications.\n\n## Custom Network Calls\n\nThe SDK exposes public endpoints for common operations, but if you need to make a custom network call, you can do so using the SDK's network capabilities:\n\n```js\nasync function customNetworkCall() {\n  try {\n    const url = '/iam/v3/public/users/me'\n    const network = Network.create(sdk.assembly().axiosConfig.request)\n    return await network.get(url)\n  } catch (err) {\n    console.error(err)\n  }\n}\n```\n\nThis flexibility allows you to extend the SDK for specific use cases beyond the provided API methods.\n\n## AGS SDK API\n\n### AGS SDK Constructor\n\nWhen creating an instance of the AGS SDK using `AccelByte.SDK(config)`, you need to provide a configuration object that adheres to the `SdkConstructorParam` interface.\n\n```js\nexport interface SdkConstructorParam {\n  coreConfig: MakeOptional\u003cCoreConfig, 'useSchemaValidation'\u003e\n  axiosConfig?: AxiosConfig\n  webSocketConfig?: WebSocketConfig\n}\n```\n\nThis configuration includes three main sections: `coreConfig`, `axiosConfig`, and `webSocketConfig`. Here's a detailed breakdown of each section:\n\n#### coreConfig\n\nThis is a required object that contains the core configuration for the SDK. It includes essential settings like `clientId`, `redirectURI`, `baseURL`, and `namespace`.\n\n```js\nexport interface CoreConfig {\n  clientId: string;\n  redirectURI: string;\n  baseURL: string;\n  namespace: string;\n  useSchemaValidation?: boolean;\n}\n```\n\nThe following table describes each parameter's function, type, and default value.\n\n| Parameter                 | Type    | Description                                                                                                                                                                                                                                               | Default Value |\n| ------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |\n| `clientId` (required)     | string  | The client ID associated with your SDK. You can obtain this from the AGS Admin Portal under OAuth Clients **Game Setup** \u003e **Games and Apps** \u003e **IAM Clients**.                                                                                          |               |\n| `redirectURI ` (required) | string  | The URI to redirect to after a successful login. This value is crucial for generating a valid login URL to IAM and should match the redirect URI configured in the Admin Portal.                                                                          |               |\n| `baseURL` (required)      | string  | The URI to redirect to after a successful login. This value is crucial for generating a valid login URL to IAM and should match the redirect URI configured in the Admin Portal.                                                                          |               |\n| `namespace` (required)    | string  | The namespace associated with your AGS deployment.                                                                                                                                                                                                        |               |\n| `useSchemaValidation`     | boolean | Determines whether the SDK enforces the Zod schema validation at runtime. Setting this to `false` will bypass validation, which might be useful to prevent throwing errors if there are schema mismatches between the Zod model and the backend response. | true          |\n\n#### axiosConfig (optional)\n\nThis object allows you to customize the Axios instance used by the SDK, such as adding interceptors or modifying request configurations.\n\n```js\nexport interface AxiosConfig {\n  interceptors?: Interceptor[];\n  request?: AxiosRequestConfig;\n}\n```\n\n- `request` (`AxiosRequestConfig`, optional): A configuration object that allows you to set default properties for Axios request, such as headers, timeout settings, or credentials handling. For more information, refer to the [Axios documentation](https://axios-http.com/docs/req_config).\n\n- `interceptors` (`Interceptor[]`, optional): An array of interceptor objects that can modify requests or responses. These interceptors provide hooks for adding custom behavior before a request is sent or after a response is received.\n\n  ```js\n  export type Interceptor =\n  | {\n      type: 'request';\n      name: string;\n      onRequest?: (config: InternalAxiosRequestConfig) =\u003e InternalAxiosRequestConfig | Promise\u003cInternalAxiosRequestConfig\u003e;\n      onError?: (error: unknown) =\u003e unknown;\n    }\n  | {\n      type: 'response';\n      name: string;\n      onSuccess?: (response: AxiosResponse\u003cunknown\u003e) =\u003e AxiosResponse\u003cunknown\u003e;\n      onError?: (error: unknown) =\u003e unknown;\n    }\n  ```\n\nThe following table describes each parameter's function, type, and default value.\n\n| Parameter         | Type                                                                                                        | Description                                                                                                                                                                  | Default Value |\n| ----------------- | ----------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |\n| `type` (required) | `'request' \\| 'response'`                                                                                   | Specifies whether the interceptor should handle requests or responses.                                                                                                       |               |\n| `name` (required) | string                                                                                                      | A unique name for the interceptor. This helps in identifying the interceptor, especially if you have multiple interceptors.                                                  |               |\n| `onRequest`       | `(config: InternalAxiosRequestConfig) =\u003e InternalAxiosRequestConfig \\| Promise\u003cInternalAxiosRequestConfig\u003e` | A function that processes the request configuration before the request is sent. This can be used to modify the request (e.g., adding headers) or to log the request details. |               |\n| `onError`         | `(error: unknown) =\u003e unknown`                                                                               | A function that handles errors during the request or response process. This is useful for logging errors or retrying requests under certain conditions.                      |               |\n| `onSuccess`       | `(response: AxiosResponse\u003cunknown\u003e) =\u003e AxiosResponse\u003cunknown\u003e`                                              | A function that processes the response before it’s passed back to the calling code. This can be used to transform the response data or log successful requests.              |               |\n\n#### webSocketConfig (optional)\n\nThis configuration allows customization of the WebSocket reconnection behavior when an abnormal disconnection occurs. By default, the WebSocket connection will attempt to reconnect if it closes unexpectedly.\n\n```ts\nexport interface WebSocketConfig {\n  allowReconnect?: boolean\n  maxReconnectAttempts?: number\n}\n```\n\nThe following table describes each parameter's function, type, and default value.\n\n| Parameter              | Type      | Description                                                                                             | Default Value |\n| ---------------------- | --------- | ------------------------------------------------------------------------------------------------------- | ------------- |\n| `allowReconnect`       | `boolean` | Enables automatic reconnection attempts when the WebSocket disconnects unexpectedly.                    | `true`        |\n| `maxReconnectAttempts` | `number`  | Sets the maximum number of reconnection attempts. Use `0` for unlimited retries. Only accepts integers. | `0`           |\n\n### API Class\n\nThe API classes in the AGS TypeScript SDK, such as `*Api` for public endpoints and `*AdminApi` for admin endpoints, are constructed to interact with AGS. These classes offer methods to perform API operations, handling query parameters, request bodies, and returning the corresponding responses.\n\nThe API classes are instantiated using the following constructor:\n\n```js\nconstructor(sdk: AccelByteSDK, args?: SdkSetConfigParam)\n```\n\nThe following table describes each parameter's function, type, and default value.\n\n| Parameter        | Type                | Description                                                                                                                                             | Default Value |\n| ---------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |\n| `sdk` (required) | `AccelByteSDK`      | An instance of the AGS SDK                                                                                                                              |               |\n| `args`           | `SdkSetConfigParam` | An optional parameter that allows you to override or extend the configuration of the SDK. This includes the core configuration and Axios configuration. |               |\n\n## WebSocket Client\n\nThe AGS TypeScript SDK includes support for connecting to the Lobby WebSocket Service, allowing real-time communication and interaction. In addition to connecting, disconnecting, and listening for events, the WebSocket client allows configuration for automatic reconnection on unexpected closures. Here’s an example of how to configure and use the WebSocket client:\n\n```ts\nimport { AccelByte } from '@accelbyte/sdk'\nimport { Lobby } from '@accelbyte/sdk-lobby'\n\nconst sdk = AccelByte.SDK({\n  coreConfig: {\n    baseURL: process.env.AB_BASE_URL || '',\n    clientId: process.env.AB_CLIENT_ID || '',\n    redirectURI: process.env.AB_REDIRECT_URI || '',\n    namespace: process.env.AB_NAMESPACE || ''\n  },\n  webSocketConfig: {\n    // Enable reconnection on abrupt disconnects. Defaults to true.\n    allowReconnect: true,\n    // Maximum number of reconnect attempts. Set to 0 for unlimited attempts.\n    maxReconnectAttempts: 3\n  }\n})\n\n// Ensure login is complete before connecting\nconst lobbyWs = Lobby.WebSocket(sdk)\n\n// Connect to WebSocket\nlobbyWs.connect()\nlobbyWs.onOpen(() =\u003e console.log('Connected to WebSocket.'))\n// Listen for all incoming messages through a single handler\nlobbyWs.onMessage(message =\u003e {\n  console.log(message)\n})\nlobbyWs.onClose(ev =\u003e {\n  console.log('Disconnected from WebSocket.', ev)\n  if (sdk.webSocketConfig.allowReconnect) {\n    console.log('Attempting reconnection, max attempts:', sdk.webSocketConfig.maxReconnectAttempts)\n  }\n})\n\n// Disconnect from WebSocket\nawait lobbyWs.disconnect()\n```\n\n### WebSocket Methods and Properties\n\nThe `WebSocket` class offers several methods and event listeners for managing WebSocket connections and handling messages. The table below provides details on each available method and property.\n\n| Method/Property     | Type                                                                | Description                                                                                                                                       |\n| ------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `connect`           | `() =\u003e void`                                                        | Initiates a connection to the WebSocket server.                                                                                                   |\n| `disconnect`        | `() =\u003e void`                                                        | Closes the WebSocket connection, ending communication.                                                                                            |\n| `onOpen`            | `(cb: () =\u003e void) =\u003e void`                                          | Event listener triggered when the WebSocket connection is successfully opened.                                                                    |\n| `onMessage`         | `(cb: (message?: object \\| string, raw?: boolean) =\u003e void) =\u003e void` | Event listener for incoming messages. Messages are parsed into typed objects, unless `raw` is set to true.                                        |\n| `onError`           | `(cb: (err?: Error) =\u003e void) =\u003e void`                               | Event listener for errors in the WebSocket connection, such as message send failures.                                                             |\n| `onClose`           | `(cb: (ev?: CloseEvent) =\u003e void) =\u003e void`                           | Event listener for connection closure events, which may occur due to errors or manual disconnection.                                              |\n| `send`              | `(message?: object) =\u003e void`                                        | Sends a message to the WebSocket server.                                                                                                          |\n| `send${methodName}` | `(message?: object) =\u003e void`                                        | Type-specific `send` methods for predefined messages (e.g., `sendPartyInfo(data)`, `sendPartyCreate(data)`, etc.).                                |\n| `instance`          | `WebSocket`                                                         | Provides direct access to the [WebSocket instance](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket) for lower-level control. |\n\n## AGS APIs\n\nTypeScript SDK supports the following AGS APIs:\n\n| AGS API          | Documentation                                                                                          | Package                                       | Global variable (UMD)        | URL                                                                                 |\n| ---------------- | ------------------------------------------------------------------------------------------------------ | --------------------------------------------- | ---------------------------- | ----------------------------------------------------------------------------------- |\n| **Core**         | -                                                                                                      | `@accelbyte/sdk`                              | `AccelByteSDK`               | [unpkg](https://unpkg.com/@accelbyte/sdk/dist/global/index.global.js)               |\n| **Access**       | [IAM](https://docs.accelbyte.io/api-explorer/#IAM)                                                     | `@accelbyte/sdk-iam`                          | `AccelByteSDK_IAM`           | [unpkg](https://unpkg.com/@accelbyte/sdk-iam/dist/global/index.global.js)           |\n|                  | [GDPR](https://docs.accelbyte.io/api-explorer/#GDPR)                                                   | `@accelbyte/sdk-gdpr`                         | `AccelByteSDK_GDPR`          | [unpkg](https://unpkg.com/@accelbyte/sdk-gdpr/dist/global/index.global.js)          |\n|                  | [Event Log](https://docs.accelbyte.io/api-explorer/#Event%20Log)                                       | `@accelbyte/sdk-event`                        | `AccelByteSDK_Event`         | [unpkg](https://unpkg.com/@accelbyte/sdk-event/dist/global/index.global.js)         |\n|                  | [Legal](https://docs.accelbyte.io/api-explorer/#Legal)                                                 | `@accelbyte/sdk-legal`                        | `AccelByteSDK_Legal`         | [unpkg](https://unpkg.com/@accelbyte/sdk-legal/dist/global/index.global.js)         |\n| **Analytics**    | [Game Telemetry](https://docs.accelbyte.io/api-explorer/#Telemetry)                                    | `@accelbyte/sdk-gametelemetry`                | `AccelByteSDK_GameTelemetry` | [unpkg](https://unpkg.com/@accelbyte/sdk-gametelemetry/dist/global/index.global.js) |\n| **Basic**        | [Basic](https://docs.accelbyte.io/api-explorer/#Basic)                                                 | `@accelbyte/sdk-basic`                        | `AccelByteSDK_Basic`         | [unpkg](https://unpkg.com/@accelbyte/sdk-basic/dist/global/index.global.js)         |\n| **Engagement**   | [Achievement](https://docs.accelbyte.io/api-explorer/#Achievement)                                     | `@accelbyte/sdk-achievement`                  | `AccelByteSDK_Achievement`   | [unpkg](https://unpkg.com/@accelbyte/sdk-achievement/dist/global/index.global.js)   |\n|                  | [Challenge](https://docs.accelbyte.io/api-explorer/#Challenge)                                         | `@accelbyte/sdk-challenge`                    | `AccelByteSDK_Challenge`     | [unpkg](https://unpkg.com/@accelbyte/sdk-challenge/dist/global/index.global.js)     |\n|                  | [Leaderboard](https://docs.accelbyte.io/api-explorer/#Leaderboard)                                     | `@accelbyte/sdk-leaderboard`                  | `AccelByteSDK_Leaderboard`   | [unpkg](https://unpkg.com/@accelbyte/sdk-leaderboard/dist/global/index.global.js)   |\n|                  | [User-generated Content (UGC)](https://docs.accelbyte.io/api-explorer/#User%20Generated%20Content)     | `@accelbyte/sdk-ugc`                          | `AccelByteSDK_UGC`           | [unpkg](https://unpkg.com/@accelbyte/sdk-ugc/dist/global/index.global.js)           |\n|                  | [SeasonPass](https://docs.accelbyte.io/api-explorer/#SeasonPass)                                       | `@accelbyte/sdk-seasonpass`                   | `AccelByteSDK_SeasonPass`    | [unpkg](https://unpkg.com/@accelbyte/sdk-seasonpass/dist/global/index.global.js)    |\n|                  | [Reporting](https://docs.accelbyte.io/api-explorer/#Reporting)                                         | `@accelbyte/sdk-reporting`                    | `AccelByteSDK_Reporting`     | [unpkg](https://unpkg.com/@accelbyte/sdk-reporting/dist/global/index.global.js)     |\n| **Monetization** | [Platform Store](hhttps://docs.accelbyte.io/api-explorer/?api=Platform%20Store#Platform%20Store)       | `@accelbyte/sdk-platform`                     | `AccelByteSDK_Platform`      | [unpkg](https://unpkg.com/@accelbyte/sdk-platform/dist/global/index.global.js)      |\n| **Play**         | [Session](https://docs.accelbyte.io/api-explorer/#Session)                                             | `@accelbyte/sdk-session`                      | `AccelByteSDK_Session`       | [unpkg](https://unpkg.com/@accelbyte/sdk-session/dist/global/index.global.js)       |\n|                  | [Matchmaking](https://docs.accelbyte.io/api-explorer/#Matchmaking)                                     | `@accelbyte/sdk-matchmaking`                  | `AccelByteSDK_Matchmaking`   | [unpkg](https://unpkg.com/@accelbyte/sdk-matchmaking/dist/global/index.global.js)   |\n| **Social**       | [Chat](https://docs.accelbyte.io/api-explorer/#Chat)                                                   | `@accelbyte/sdk-chat`                         | `AccelByteSDK_Chat`          | [unpkg](https://unpkg.com/@accelbyte/sdk-chat/dist/global/index.global.js)          |\n|                  | [Lobby](https://docs.accelbyte.io/api-explorer/#Lobby%20-%20Friends,%20Presence%20and%20Notifications) | `@accelbyte/sdk-lobby` with websocket support | `AccelByteSDK_Lobby`         | [unpkg](https://unpkg.com/@accelbyte/sdk-lobby/dist/global/index.global.js)         |\n|                  | [Groups](https://docs.accelbyte.io/api-explorer/#Groups)                                               | `@accelbyte/sdk-groups`                       | `AccelByteSDK_Groups`        | [unpkg](https://unpkg.com/@accelbyte/sdk-groups/dist/global/index.global.js)        |\n| **Storage**      | [CloudSave](https://docs.accelbyte.io/api-explorer/#CloudSave)                                         | `@accelbyte/sdk-cloudsave`                    | `AccelByteSDK_CloudSave`     | [unpkg](https://unpkg.com/@accelbyte/sdk-cloudsave/dist/global/index.global.js)     |\n|                  | [Inventory](https://docs.accelbyte.io/api-explorer/#Inventory)                                         | `@accelbyte/sdk-inventory`                    | `AccelByteSDK_Inventory`     | [unpkg](https://unpkg.com/@accelbyte/sdk-inventory/dist/global/index.global.js)     |\n|                  | [Statistics](https://docs.accelbyte.io/api-explorer/#Statistics)                                       | `@accelbyte/sdk-social`                       | `AccelByteSDK_Social`        | [unpkg](https://unpkg.com/@accelbyte/sdk-social/dist/global/index.global.js)        |\n| **Add Ons**      | [AMS](https://docs.accelbyte.io/api-explorer/#AMS)                                                     | `@accelbyte/sdk-ams`                          | `AccelByteSDK_AMS`           | [unpkg](https://unpkg.com/@accelbyte/sdk-ams/dist/global/index.global.js)           |\n\nCheck out the [AGS Documentation Portal](https://docs.accelbyte.io/gaming-services/services/) to learn more about the functions of these AGS services and how to integrate them into your game.\n\n## Migrating from V3 guidelines\n\n### SDK initialization\n\nSDK now needs to be initialized with two fields: `coreConfig` and `axiosConfig`. This distinction clarifies which configurations apply to each component.\n\n```js\n// Before\nconst sdk = Accelbyte.SDK({\n  options: {\n    baseURL: 'http://localhost:3030/api',\n    clientId: '77f88506b6174c3ea4d925f5b4096ce8',\n    namespace: 'accelbyte',\n    redirectURI: 'http://localhost:3030'\n  },\n  onEvents: {\n    onGetUserSession: (accessToken, refreshToken) =\u003e {\n      console.log('SDK Event: onGetUserSession', { accessToken, refreshToken })\n    },\n    onSessionExpired: () =\u003e {\n      console.log('SDK Event: onSessionExpired')\n    },\n    onError: error =\u003e {\n      console.error('SDK Event: onError', error.response)\n    }\n  }\n})\n\n// After\nconst sdk = AccelByte.SDK({\n  coreConfig: {\n    baseURL: 'http://localhost:3030/api',\n    clientId: '77f88506b6174c3ea4d925f5b4096ce8',\n    namespace: 'accelbyte',\n    redirectURI: 'http://localhost:3030'\n  },\n  axiosConfig: {\n    interceptors: [],\n    requests: {}\n  }\n})\n```\n\n### Return response\n\nAPI function calls are now returning `{ data, headers, status }` instead of just the data.\n\n```js\n- const data = await UsersAdminApi(sdk).getUsersMe_v3();\n+ const { data, headers, status } = await UsersAdminApi(sdk).getUsersMe_v3();\n```\n\n### Events and Interceptors\n\nThe AGS SDK no longer has the ability to provide event listeners, e.g. `onSessionRenewed`. This capability is replaced by interceptors. Axios interceptors are now attached to the `axiosInstance` in the SDK instead of the global axios object. For example:\n\n```js\n// Before\nconst sdk = Accelbyte.SDK({\n  options,\n  onEvents: {\n    onGetUserSession: (accessToken, refreshToken) =\u003e {\n      console.log('SDK Event: onGetUserSession', { accessToken, refreshToken })\n    },\n    onSessionExpired: () =\u003e {\n      console.log('SDK Event: onSessionExpired')\n    },\n    onError: error =\u003e {\n      console.error('SDK Event: onError', error.response)\n    }\n  }\n})\n\n// After\nconst sdk = AccelByte.SDK({\n  coreConfig: {\n    baseURL: 'http://localhost:3030/api',\n    clientId: '77f88506b6174c3ea4d925f5b4096ce8',\n    namespace: 'accelbyte',\n    redirectURI: 'http://localhost:3030'\n  },\n  axiosConfig: {\n    interceptors: [\n      createAuthInterceptor({\n        clientId,\n        onSessionExpired,\n        onGetUserSession,\n        getRefreshToken\n      }),\n      createCustomPathInterceptor(),\n      {\n        type: 'response',\n        name: 'cancelled',\n        onError: e =\u003e {\n          const error = e as AxiosError\n          if (axios.isCancel(error)) {\n            // Expected case, exit\n            return Promise.reject(error)\n          }\n          return Promise.reject(error)\n        }\n      },\n      // Add more interceptors\n    ],\n    requests: {}\n  }\n})\n```\n\n#### Interceptors\n\nWe now offer custom interceptors to replace certain events or options. Here's a list of interceptors available for event and option replacement:\n\n- **onSessionExpired** and **onGetUserSession** (**createAuthInterceptor**)\n\n  ```js\n  createAuthInterceptor({\n    /**\n     * The client ID used by the SDK, obtained from the Admin Portal under OAuth Clients.\n     */\n    clientId: string\n    /**\n     * An optional array of URLs that should be ignored when handling session expiration.\n     * Default to `['/iam/v3/oauth/token', '/iam/v4/oauth/token', '/iam/v3/oauth/revoke']`\n     */\n    expectedErrorUrls?: string[]\n    /**\n     * A callback function that retrieves the current refresh token.\n     */\n    getRefreshToken: () =\u003e string | undefined\n    /**\n     * The URL endpoint for obtaining a new token. Defaults to `'/iam/v3/oauth/token'`.\n     */\n    tokenUrl?: GrantTokenUrlString\n    /**\n     * A callback function triggered when the session has expired.\n     */\n    onSessionExpired: () =\u003e void\n    /**\n     * A callback function triggered when successfully get new session.\n     */\n    onGetUserSession?: (accessToken: string, refreshToken: string) =\u003e void\n  })\n  ```\n\n- **onUserEligibilityChange**\n\n  \u003e **Note**: Since there's no dependency on the Internal SDK and it's specific to the application level, we have not created a custom wrapper for it.\n\n  ```js\n  {\n      type: 'response',\n      name: 'user-eligibilitiy-change',\n      onError: e =\u003e {\n        const error = e as AxiosError\u003cany\u003e\n        if (error.response) {\n          const { response } = error\n          if (response?.status === 403 \u0026\u0026 (response?.config as any).url.includes(process.env.BASE_URL) \u0026\u0026 response?.config.withCredentials) {\n            if (response.data.errorCode === ERROR_ELIGIBILITY_CODE) {\n              // Do something when there's an error with ERROR_ELIGIBILITY_CODE\n            }\n          }\n        }\n        return Promise.reject(error)\n      }\n    }\n  ```\n\n- **onTooManyRequest**\n\n  \u003e **Note**: Since there's no dependency on the Internal SDK and it's specific to the application level, we have not created a custom wrapper for it.\n\n  ```js\n  {\n      type: 'response',\n      name: 'too-many-request',\n      onError: e =\u003e {\n        const error = e as AxiosError\u003cany\u003e\n        if (error.response) {\n          const { response } = error\n          if (response?.status === 429 /* TooManyRequests */) {\n            // onTooManyRequest(error)\n          }\n        }\n        return Promise.reject(error)\n      }\n    }\n  ```\n\n- **useInternalNetwork** (**createCustomPathInterceptor**)\n\n  ```js\n  createCustomPathInterceptor({\n    /**\n     * A list of objects specifying which service base paths should be replaced.\n     * For example, providing `{'/iam': '/iam-test'}` will redirect all `'/iam'` requests to `'/iam-test'`.\n     */\n    basePath: Partial\u003cRecord\u003cBasePath, string\u003e\u003e\n    /**\n     * Indicates whether to use the internal AccelByte network. This should only be used in a server environment.\n     * When set to true, requests will be made to `http://{service-name}/{path}` instead of the `baseURL`.\n     */\n    isInternalNetwork?: boolean\n  })\n  ```\n\n### API Class Arguments\n\nThe `ApiArgs` (the second `*Api` argument) has been replaced by partial `coreConfig` and `axiosConfig` to make it consistent with the options passed in the initializer.\n\n```js\n// Before\nconst data = await UsersAdminApi(sdk, { namespace, config: {} }).getUsersMe_v3()\n// After\nconst { data } = await UsersAdminApi(sdk, { coreConfig: { namespace }, axiosConfig }).getUsersMe_v3()\n```\n\n### Admin Class Endpoints\n\nAdmin endpoints that have the \"Admin\" tag in Swagger will only generate one \"Admin\" keyword. The `AdminPlayerRecordAdmin` has been replaced by `PlayerRecordAdmin`.\n\n```js\n;-AdminPlayerRecordAdminApi(sdk).getRecords_ByUserId(userId) + PlayerRecordAdminApi(sdk).getRecords_ByUserId(userId)\n```\n\n### (Extend Functionality) Token Repository\n\nSet the `accessToken` and `refreshToken` and update the Axios request headers to use Bearer authentication.\n\n```js\nsetToken(token: TokenConfig) {\n  this.token = {\n    ...this.token,\n    ...token\n  }\n}\nremoveToken() {\n  this.token = {}\n}\ngetToken() {\n  return this.token\n}\n```\n\n### refreshTokens method\n\nThe `refreshTokens` method is now replaced by `setToken({ accessToken, refreshToken })` with the same behavior.\n\n```\n- sdk.refreshTokens(accessToken, refreshToken);\n+ sdk.refreshTokens({ accessToken, refreshToken });\n```\n\n## TypeScript SDK Playground\n\nYou can live test the TypeScript SDK on the [AccelByte TypeScript SDK Playground](https://accelbyte.github.io/accelbyte-typescript-sdk).\n\n## Frequently Asked Questions (FAQ)\n\n### Can I install all the AGS SDK packages at once?\n\nYes, you can install all the AGS SDK packages in one command using the following `npm` command:\n\n```bash\nnpm install @accelbyte/sdk @accelbyte/sdk-ams @accelbyte/sdk-achievement @accelbyte/sdk-basic @accelbyte/sdk-buildinfo @accelbyte/sdk-challenge @accelbyte/sdk-chat @accelbyte/sdk-cloudsave @accelbyte/sdk-differ @accelbyte/sdk-event @accelbyte/sdk-gametelemetry @accelbyte/sdk-gdpr @accelbyte/sdk-groups @accelbyte/sdk-iam @accelbyte/sdk-inventory @accelbyte/sdk-leaderboard @accelbyte/sdk-legal @accelbyte/sdk-lobby  @accelbyte/sdk-matchmaking @accelbyte/sdk-reporting @accelbyte/sdk-seasonpass @accelbyte/sdk-session @accelbyte/sdk-social @accelbyte/sdk-ugc @accelbyte/sdk-platform\n```\n\n## Contributions\n\nThank you for your interest in contributing to the AGS TypeScript SDK. We value your input and appreciate your input to enhancing the AGS TypeScript SDK project. However, please note that direct contributions via GitHub are not currently accepted.\n\nInstead, we encourage you to submit your ideas and suggestions as feature requests through the [AccelByte Customer Support Portal](https://accelbyte.atlassian.net/servicedesk/customer/portal/6) or via your Account Manager. This process helps us manage contributions effectively and ensures that each idea is carefully reviewed and considered by our team.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faccelbyte%2Faccelbyte-typescript-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faccelbyte%2Faccelbyte-typescript-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faccelbyte%2Faccelbyte-typescript-sdk/lists"}