Getting Started
Our SDK is a modern, open-source, dependency-free JavaScript SDK for PlayFab that supports Promises, ES Modules, tree-shaking, and custom request middleware.
Installation
Section titled “Installation”Install the SDK using npm:
npm install @community-fabs/playfab-sdkInitialize the SDK
Section titled “Initialize the SDK”Create a PlayFab client by providing your title ID and developer secret key.
import { initializePlayFab } from '@community-fabs/playfab-sdk/core';
const playfab = initializePlayFab({ titleId: 'YOUR_TITLE_ID', developerSecretKey: 'YOUR_DEV_SECRET_KEY',});Create an API Client
Section titled “Create an API Client”Import the API suite you want to use and create a client instance.
import getClientApi from '@community-fabs/playfab-sdk/client';
const clientApi = getClientApi(playfab);Make Your First Request
Section titled “Make Your First Request”All SDK methods return Promises and can be used with async/await.
await clientApi.loginWithCustomID({ CustomId: 'test-custom-id',});Complete Example
Section titled “Complete Example”import { initializePlayFab } from '@community-fabs/playfab-sdk/core';import getClientApi from '@community-fabs/playfab-sdk/client';
const playfab = initializePlayFab({ titleId: 'YOUR_TITLE_ID', developerSecretKey: 'YOUR_DEV_SECRET_KEY',});
const clientApi = getClientApi(playfab);
const result = await clientApi.loginWithCustomID({ CustomId: 'test-custom-id',});
console.log(result);Next Steps
Section titled “Next Steps”- Learn how to configure custom middleware for logging, retries, and request customization.
- Explore the available PlayFab API suites.