Did you find this helpful?
Getting Started with PlayFab - Chapter 1
Welcome! This introductory tutorial will quickly get you up and running with PlayFab. By following this tutorial, you will go through the following steps:
Chapter 1 - Get started with players and tournaments
If you have already created an account with PlayFab, then this tutorial is also available in a special interactive version directly inside the Game Manager. If you plan on following along with these steps, then you may find that version more useful.
We also have another set of Getting Started guides, which help you make your first PlayFab API call in each of our SDK languages or environments.
Let's get started!
Get started with players and tournaments
In this chapter you will:
- Getting Started & First API Call
- Update your Login Mechanism
- Using remote configuration data
- View a player profile using our management tool
- Create a basic leaderboard, and add the player to it
- View your game's analytics data in real-time
1. Getting Started & First API Call
We have SDKs for all major game engines and languages.
Choose an environment from the list below, and follow the link to the appropriate getting started guide. This will guide you through installing your environment, creating a new test project, and making your first API call.
Pick your SDK:
- Flash (ActionScript3)
- Defold (Lua)
- Corona (Lua)
- Linux - C++
2. Update your Login mechanism
The first step adding PlayFab to any game is always logging in the player. Logging in the player returns a security token that is needed for all other API calls.
The Guides in step 1 utilize a test titleId, but from now on, you should be using your own. Create a title in Game Manager, and update your environment with your own titleId.
Obtaining your titleId
Once logged in, click "Settings". You should see the titleId for your game:
The SDK guide you followed above should have included instructions on how to enter your Title ID.
PlayFab makes it easy to authenticate players. On a smartphone you can login with the iOS or Android device ID for easy authentication with zero friction for the player. We also support authentication with Windows, Google, Kongregate, Facebook, Steam, and Twitch accounts, as well as username/password, email/password, or an ID you generate.
For this tutorial, we'll demonstrate authentication using the last method - LoginWithCustomID, which uses an arbitrary string generated by your title, or your own game servers. It's worth noting, however, that the recommended path for most titles is to use authentication mechanisms that align to the devices and platforms on which your title is shipping. So, for example, on Android or iOS, use the device-specific login API calls to get players into the game quickly, and then incentivize them to add a cross-device authentication mechanism later as part of the game experience (as shown in this post).
After a login call, you can call other functions in the client API. Some, like UpdatePlayerStatistics and AddUserVirtualCurrency are disabled by default until you allow them on the API Features page in Game Manager (and you can specifically enable or disable any Client API calls using Permission Policies).
PRO TIP: If you look at the PlayStream Debugger on the Dashboard tab of the game manager, you will see several events connected to logging you in.
You can click the "information" circle to view the raw JSON of that event.
3. Using remote configuration data
Storing configuration information about your game on PlayFab is a smart idea, because you can then change that data at any time. This is much more useful than hard-coding that information in your game, and having to update your client to change anything.
Configuration data for your game is stored in what we call Title Data.
Examples of configuration data might include much XP a player earns from each match, a maximum movement speed, or a feedback URL. You can store JSON in the title data if your game requires more complex data.
- Go to Content > Title Data
- Add a few keys and values, doesn't matter what they are
- Click Save Title Data
That's all you have to do in the Game Manager.
- In your game, call GetTitleData
- You should see the keys and values you just added
Title Data is a great way to tweak your game balance while it's in development, or to run special events post-launch.
4. View your player profile in the Game Manager
You should now have a new player created, identified with the Custom ID you configured earlier.
- Go to the Players tab
- You should see the player you just created
- If not, paste the Custom ID from above into the query box and click Search.
- Click on that player
From the Overview tab you can see the player's email address, when they were created (provisioned), change their statistics, look at login events, manage characters, check on their inventory, and much more. On the player's PlayStream tab you can watch their events come in live.
Custom ID vs User ID
The player's Custom ID is not the same as their User ID. User ID is automatically generated by PlayFab and used to track the player if they login using different methods.
Some games do choose to expose the User ID to the player, however, to help with customer support requests.
5. Create a basic leaderboard
Let's create a statistic for this player so you can try out our leaderboard feature, and later, some player segmentation capabilities.
WARNING: unlike Title Data, you cannot delete or rename a statistic once it's created. If you don't want to have an "xp" statistic forever, give it a different name.
- Go to the player's Statistics tab
- Add a key labeled "xp" and set the value to 0
- Click Save Player Statistics
In your game, call GetPlayerStatistics
Statistics are a great place to store experience points, number of wins and losses, headshots, or anything you want tallied. Every statistic automatically creates its own Leaderboard, so you can track who's doing the best (and worst) in your game.
Click "Leaderboards" on the Players tab to see the current progress.
6. PlayStream events
Click the PlayStream tab for this player (next to Overview). You should see a login event and the statistic change event. Keep this window open while you do other things and you'll be able to see more events pop up.
Now that you have a player, some title data, and a statistic, let's create a currency and start your game's economy.