question

Marlon avatar image
Marlon asked

Would This Code be Abusing PlayFabs API Calls

Im wording if this code would end up creating a large amount of API Calls, it is on the Update() function.

void Update () {

if (PlayFabItemsController.VirtualCurrency ["JL"] == 20) {

    //Do Something

}

Would this produce an API call only when Virtual Currency JL equals 21? or would it be constantly be sending API calls every second checking if JL equals to 21. I don't want to abuse PlayFab's servers in anyway.

10 |1200

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

brendan avatar image
brendan answered

I would have to see the rest of your code to determine specifically what it's doing (the PlayFabItemsController isn't from our SDKs), but this appears to be checking a locally defined value, rather than making any calls to our service. What is your design goal? Is this a regenerating currency? If so, we provide the time to the next increment of the currency in the returned data (when you get the current balance), so you could just use that to calculate the time at which the currency will reach your target value.

10 |1200

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

Marlon avatar image
Marlon answered

I tried doing my own test by calling that code and checking my "TODAY API CALLS" Odometer, but it still says we have made 0 API calls. So I am guessing it takes a little while to show me.

10 |1200

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

Marlon avatar image
Marlon answered

Basically, the code is checking if the users virtual currency reaches a certain number every second. I assume that it does make api calls to your servers but I just want to make sure.

10 |1200

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

brendan avatar image
brendan answered

Ah, I see - you're referencing the PlayFabItemsController from the Union MOBA demo.

No, the VirtualCurrency array is updated as a result of any inventory query, so that check does not update anything or make any calls to our service.

Again, though - what is it you're trying to do? If you want to trigger some behavior when a regenerating virtual currency exceeds a certain value, you should take the current value and use the SecondsToRecharge you get back from the inventory query, together with the VC generation rate, to compute when the value you want will be reached.

To answer the question about call frequency though, yes, calling an API every second (or more often - bear in mind that Update loops are often tied to the frame rate, as is the case with Union) would be too frequent, and could result in your title getting throttled by the service.

10 |1200

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

Marlon avatar image
Marlon answered

I see, yes I read that to many Api calls can throttle the service that is why I am double checking here, plus I don't want to harm playfabs servers in anyway. The reason we are doing this is a bit confidential, but anyways we found a better way around this. But this is good information to know anyways. Thanks a lot for your awesome replies like always, we would never be so close to finishing if it wasn't for Playfab and its team such as yourself.

10 |1200

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

brendan avatar image
brendan answered

Thanks! Always glad to hear that we've been able to help accelerate someone's development. And we do appreciate your concern, though the service is designed to minimize the chance of anyone being able to cause harm. My real concern is the potential throttling, as you pointed out.

If you do have questions that can only be made clear with info that's confidential, feel free to open a ticket - while we do our primary support via the forums, we're aware that from time to time people will have questions which require privacy. You can open a ticket via the Help button below, or by emailing us at support@playfab.com.

10 |1200

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

Marlon avatar image
Marlon answered

Oh that is good to know! I will remember that next time we have any confidential issue! Thanks brendanv!

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.