User-Generated Content (UGC) quickstart
The purpose of this guide is to explain how to quickly get started with UGC, using direct service-to-service calls. We show you step by step how to connect to the draft UGC content items, publish those items, and then search and find them.Get an Entity Token
UGC is designed to work with PlayFab entities, so the first step is to get an entity token using LoginWithCustomID. This example shows a service call.Create Blob URLs
The UGC system uses Azure Blob Storage to store all content (files and images) associated with your title’s UGC. To upload the content, we first need to call the CreateUploadUrls API, passing in the file names and sizes (in bytes) to create the new blobs. For example, if you wanted to upload a text file and PNG image, you would pass in the following to the request body:Id and Url for each piece of content:
Create a draft UGC item
You create “draft” UGC items by calling the CreateDraftItem API with the"Type":"ugc" parameter. Creators can review and access draft items before publishing them. To create a draft item, you need:
- The
EntityTokenfrom the previous call in the X-EntityToken header. - The
Entity.Idfrom the previous call in the item’sCreatorEntityKey.Id. - The
TitleIdfor the title in the item’s sourceId.
Id. Save the Id so you can use it later.
Get draft item IDs for a player
To get draft item IDs for a particular player, the GetEntityDraftItems API can be used. Title entities can call this API with player ID in theEntity parameter, and the API returns a list of Draft Items for that particular player. Only Title Entities can pass in an Entity parameter. Player entities can call the API without an Entity parameter and the API returns a list of draft items created by the calling player.
Publish a UGC item
Once an item is in draft, you can then push it to a published state using PublishDraftItem. Once a UGC item is published, it’s searchable and available publicly. You need to use the itemId returned from the CreateDraftItem response.
Get the published status of a UGC item
Using the itemId, you can get the status of a publish for an item in your UGC catalog using the GetItemPublishStatus API.
Result values are as follows:
UnknownPendingSucceededFailedCanceled
Do a search
After the publish call succeeds, all players can access the item in the Public Catalog. TheSearchItems API executes a search against published catalog (including UGC items) using the provided parameters and returns a set of paginated results. The Filter, OrderBy, and Select fields use OData as the query standard.
