Changes to Badge APIs


#1

Hey Developers,

We are making some changes to how badges work. What this means for you is that whenever you create a badge, you will now need to start using these new Lua APIs instead of the ones you are accustomed to; otherwise they may not function correctly. After July 16th, all new badges that get created will not be assets and must use these new methods.

The existing APIs will continue to work for all existing badges to avoid breaking games.

Checking badge ownership

To check if a player owns a badge, use BadgeService:UserHasBadgeAsync().

The old method BadgeService:UserHasBadge() was initially meant to be specific to badges, and we realize it is commonly used to check asset ownership. In order to avoid breaking games, we had to create a new method.

Getting badge information

Use BadgeService:GetBadgeInfoAsync() as a replacement for MarketplaceService:GetProductInfo()
This new method exposes the following fields:

  • Name
  • Description
  • Icon image Id
  • Whether or not the badge is enabled

MarketplaceService:GetProductInfo() is intended for items that have products (sellable items,) and a badge cannot be sold so we felt it made more sense to create a new method on BadgeService.

Let us know if you have any questions or concerns!


June Recap: Here's What You Missed in the Developer Community
#2

The new methods will work with badges created on the old ID system right?

Presumably not since if the new IDs reach that ID then they’ll be overwritten by the existing one :confused:


#3

All badges will work for both newly created methods. The only thing to be aware of is that badges created after July 16th will not work with the existing two methods mentioned. (GetProductInfo, and UserHasBadge)
So yes, the new methods will work on badges that were created as assets.


#4

Does the the new method cache?


#5

The documentation for the method clearly states that it does not cache.


#6

So if a badge was about to be created with the same ID as an asset which is a badge, it would skip that ID and go onto the next one? That’s pretty cool.


#7

Will we ever be able to use GetProductInfo on games to see how many visits, sales & price (if paid access), and the name of the game?


#8

Not quite, badges being created right now up until July 16th are still being created as assets, so there’s no need to skip or reserve an ID because they’re still on the same system.
On July 16th this will change and IDs will start colliding and badges will no longer be created as assets, this is why we must provide these new methods to get and check this information.


#9

But surely if the new methods work with the previous badge assets then newly created badges on the new badge system will have to avoid the IDs of assets which are badges?


#10

The new badge IDs will probably start from the last created badge ID at the time they move everything over.


#11

As @ProbableAI mentioned badge IDs will start picking up where asset IDs left off at the time. This means any badge created before badges stop being assets won’t collide with new badge IDs.


#12

Are any front end improvements for badges in the pipeline? It would be cool to see which badges you’ve obtained from the games page.

You could do a “trophy case” like Steam does and show it off on your profile… might make them a little more worth obtaining.


#13

We don’t currently have any plans to expand upon our badges system. See our roadmap for information on what features we will be working on in the near future.


#14

Update: We missed the July 16th deadline, but as of today we no longer create badges as assets.


#15

excellent :sunglasses: