question

luitelrubin avatar image
luitelrubin asked

Confused on when to use what api from client vs server.

So I started learning playfab recently and I found out that I can use azure functions to execute server side code. I see that I have access to different apis such as economy, server, data, events, etc... But if I were to get something basic like inventory directly from client side, I wouldn't want to go execute some azure functions using cloudscript, and instead use the client api from unity to get it. I know this is possible in economy v1, but is there a documentation on what api can be executed from client side(without providing the auth stuff, since unit is already configured with it) vs server side. Like it seems like I cant use economy api from client side the way I can use client api without passing any auth tokens since unit is already setup with playfab.

In-Game Economy
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Xiao Zha avatar image
Xiao Zha answered

For client-side operations, you can use the PlayFab Client API. For server-side operations, you can use the PlayFab Server API. As for other APIs, such as PlayFab Data REST API | Microsoft Learn, Catalog - REST API (PlayFab Economy) | Microsoft Learn, PlayFab Events REST API | Microsoft Learn etc., most of them can be used both on client side and server side, it depends on which Entity(usually the title_player_account entity and the title entity) calls the API. However, it’s important to note that some APIs require authentication and can only be called from the server-side for security reasons. For example, certain operations such as add/ subtract virtual currency etc. or player data management might require server-side execution to prevent unauthorized access or manipulation.

As for your question about the Economy API, it’s generally recommended to handle economy-related operations on the server-side to ensure the integrity and security of your game’s economy. However, PlayFab does provide the client-side API to get player’s inventory. You can refer to Player Item Management - Get User Inventory - REST API (PlayFab Client) | Microsoft Learn to get inventory V1 and Inventory - Get Inventory Items - REST API (PlayFab Economy) | Microsoft Learn to get inventory V2. In addition, once players login success, they should be able to call these client-side APIs without having to manually pass any authentication tokens. The PlayFab SDK handles the authentication process for them.

For detailed information on how to use these APIs and what each API can do, I recommend checking out the PlayFab REST API reference and the PlayFab documentation on Microsoft Learn. These resources provide comprehensive information on how to use PlayFab’s APIs and services. Please remember that while it’s possible to perform some operations from the client-side, it’s generally a good practice to perform sensitive operations on the server-side whenever possible to ensure the security and integrity of your game.

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

luitelrubin avatar image luitelrubin commented ·

Inventory item's display properties depends on catalog items display properties. I dont understand why we aren't able to get catalog items when logging in the user so we can cache it and use it for future use. Or is there a way that I am misisng? I don't think its a good idea to make a single azure function to get catalog items when its only called once.

0 Likes 0 ·
luitelrubin avatar image luitelrubin luitelrubin commented ·

nvm seems like passing GetUserInventory = true in GetPlayerCombinedInfoRequestParams when logging in doesn't work for v2.

0 Likes 0 ·
Xiao Zha avatar image Xiao Zha luitelrubin commented ·

The DisplayProperties are different for Catalog Items and Inventory Items. You may refer to Can I call DIsplayProperties via InventoryItems?,Why can't I access displayproperties - Playfab Community. Also, In Economy V2, you may use SearchItem API to get catalog Items after player logged in and cache it for future use. In addition, currently, "GetUserInventory = true" only works for Economy V1.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.