question

brendan avatar image
brendan asked

Query user data from a web site

Brendan Vanous
started a topic on Mon, 20 April 2015 at 4:29 PM

Question from a developer:

I'm storing player data using the UpdateUserData API call, and I'd like to be able to display that info on a website. What's the best way to do this?

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

·
brendan avatar image
brendan answered

Best Answer
Brendan Vanous said on Mon, 20 April 2015 at 4:33 PM

You can use the Server API call GetUserData (as well as GetUserReadOnlyData, GetUserInternalData, and all the Publisher versions of those calls) to get the data for a player from your own server. Care should be taken to never expose your Secret Key to users in your site's code, of course.

The real question is, how to get the PlayFab ID for the user in question. There are a few ways you can do this:

If you're using RegisterPlayFabUser, LoginWithPlayFab, LoginWithEmailAddress, or even just AddUsernamePassword in your game, then users who have passwords in our system can be logged in using that method, using the Client API calls from your server, in order to get a session token and call to PlayFab on their behalf. Using this method, you should make sure to only do this on secure pages, and to never log the credentials, so that the user's account cannot be compromised.

Alternately, you could set up a linkage between PlayFab and your site using a method similar to that used by many console applications and online services (such as Netflix). This involves generating and showing a code on one device, and having the user enter it on the other. The easiest way to do this would be by making a call directly to your site with that code, but you could (if you're concerned about that endpoint failing under load) write that code to a Shared Group Data object using the code as the ID, with a Key/Value pair containing the user's PlayFab ID. Then, when the player enters that code on your site, the site can query for the Shared Group Data object with the information about the user, store that locally, and delete the Shared Group Data object.

Also, bear in mind that while this is great for grabbing the info for a single user (my account, checking a friend, etc.), this should not be used to aggregate data across many users, as that could result in an excessive number of API calls against our service, which may result in the calls being throttled. If you have a need for an aggregated report or are looking at ways to use data which may otherwise require many calls, the best thing to do is to reach out to us at devrel@playfab.com to talk through the specifics, so that we can help to design a solution which will work well, and still be valid within our Terms of Service.

Brendan


1 Comment
Brendan Vanous said on Mon, 20 April 2015 at 4:33 PM

You can use the Server API call GetUserData (as well as GetUserReadOnlyData, GetUserInternalData, and all the Publisher versions of those calls) to get the data for a player from your own server. Care should be taken to never expose your Secret Key to users in your site's code, of course.

The real question is, how to get the PlayFab ID for the user in question. There are a few ways you can do this:

If you're using RegisterPlayFabUser, LoginWithPlayFab, LoginWithEmailAddress, or even just AddUsernamePassword in your game, then users who have passwords in our system can be logged in using that method, using the Client API calls from your server, in order to get a session token and call to PlayFab on their behalf. Using this method, you should make sure to only do this on secure pages, and to never log the credentials, so that the user's account cannot be compromised.

Alternately, you could set up a linkage between PlayFab and your site using a method similar to that used by many console applications and online services (such as Netflix). This involves generating and showing a code on one device, and having the user enter it on the other. The easiest way to do this would be by making a call directly to your site with that code, but you could (if you're concerned about that endpoint failing under load) write that code to a Shared Group Data object using the code as the ID, with a Key/Value pair containing the user's PlayFab ID. Then, when the player enters that code on your site, the site can query for the Shared Group Data object with the information about the user, store that locally, and delete the Shared Group Data object.

Also, bear in mind that while this is great for grabbing the info for a single user (my account, checking a friend, etc.), this should not be used to aggregate data across many users, as that could result in an excessive number of API calls against our service, which may result in the calls being throttled. If you have a need for an aggregated report or are looking at ways to use data which may otherwise require many calls, the best thing to do is to reach out to us at devrel@playfab.com to talk through the specifics, so that we can help to design a solution which will work well, and still be valid within our Terms of Service.

Brendan

10 |1200

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

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.