Makes a recommendation prediction. If using API Key based authentication, the API Key must be registered using the PredictionApiKeyRegistry
service. Learn more.
HTTP request
POST https://recommendationengine.googleapis.com/v1beta1/{name=projects/*/locations/*/catalogs/*/eventStores/*/placements/*}:predict
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
name |
Required. Full resource name of the format: We currently support three placements with the following IDs by default:
The full list of available placements can be seen at https://console.cloud.google.com/recommendation/datafeeds/default_catalog/dashboard |
Request body
The request body contains data with the following structure:
JSON representation | |
---|---|
{
"userEvent": {
object ( |
Fields | |
---|---|
userEvent |
Required. Context about the user, what they are looking at and what action they took to trigger the predict request. Note that this user event detail won't be ingested to userEvent logs. Thus, a separate userEvent write request is required for event logging. |
pageSize |
Optional. Maximum number of results to return per page. Set this property to the number of prediction results required. If zero, the service will choose a reasonable default. |
pageToken |
Optional. The previous PredictResponse.next_page_token. |
filter |
Optional. Filter for restricting prediction results. Accepts values for tags and the
Examples:
If your filter blocks all prediction results, nothing will be returned. If you want generic (unfiltered) popular items to be returned instead, set |
dryRun |
Optional. Use dryRun mode for this prediction query. If set to true, a fake model will be used that returns arbitrary catalog items. Note that the dryRun mode should only be used for testing the API, or if the model is not ready. |
params |
Optional. Additional domain specific parameters for the predictions. Allowed values:
|
labels |
Optional. The labels for the predict request.
See https://goo.gl/xmQnxf for more information on and examples of labels. |
Response body
If successful, the response body contains data with the following structure:
Response message for predict method.
JSON representation | |
---|---|
{
"results": [
{
object ( |
Fields | |
---|---|
results[] |
A list of recommended items. The order represents the ranking (from the most relevant item to the least). |
recommendationToken |
A unique recommendation token. This should be included in the user event logs resulting from this recommendation, which enables accurate attribution of recommendation model performance. |
itemsMissingInCatalog[] |
IDs of items in the request that were missing from the catalog. |
dryRun |
True if the dryRun property was set in the request. |
metadata |
Additional domain specific prediction response metadata. |
nextPageToken |
If empty, the list is complete. If nonempty, the token to pass to the next request's PredictRequest.page_token. |
Authorization Scopes
Requires the following OAuth scope:
https://www.googleapis.com/auth/cloud-platform
For more information, see the Authentication Overview.
PredictionResult
PredictionResult represents the recommendation prediction results.
JSON representation | |
---|---|
{ "id": string, "itemMetadata": { string: value, ... } } |
Fields | |
---|---|
id |
ID of the recommended catalog item |
itemMetadata |
Additional item metadata / annotations. Possible values:
|