question

mustafazalsoufi avatar image
mustafazalsoufi asked

Accessing Playfab API

Hello, So Basically I want to access the player's data through PlayFab's API using JavaScript

I know my secret key and I know the title ID. and I think I know the URL that I should use "https://cab1e.playfabapi.com/Client/GetUserData/", but I'm not sure how can I combine them together to get a proper URL which is accessible with my secret key.

any help would be appretiate it.

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

·
Citrus Yan avatar image
Citrus Yan answered

Hi @mustafazalsoufi,

The URL you provided is a Client API Endpoint which requires a client session ticket for authentication, available from any Client Login function such as LoginWithCustomID. The ticket is passed in the header when you are trying to make an Http request to that endpoint. The GetUserData API that takes a secret key for authentication is the Admin API: https://cab1e.playfabapi.com/Admin/GetUserData, which is almost the same as the Client API except that it requires a secret key in the header for authentication. Therefore, the URL needs no more combination, you’ll need to pass the secret key in the header in order to make a successful request.

By the way, PlayFab JavaScript SDK provides everything you need to access the PlayFab API. This includes models, methods, an HTTP wrapper for sending and receiving web requests, and JSON serialization. In your case, if you want to make an Admin API call such as Admin/GetUserData, this code will simply set the secret key in the PlayFab settings and include it in the header when making subsequent calls. And, it's also helpful to use PlayFab Postman collection to debug and test APIs.

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.