SuggestGrid Node.js Client

SuggestGrid Node.js Client

We will walk through how to get started with SuggestGrid Node.js Client in three steps:

  1. Configuration

  2. Post actions

  3. Get recommendations

In this guide we will demonstrate how to display personalized recommendations on an existing Node.js project.

We have a movie catalog Node.js application, SuggestGridMovies, similar to IMDb. For logged in users we want to display movies that similar people viewed on movie pages. Let's implement this feature in five minutes with SuggestGrid!

We are beginning the development by adding the client as a dependency.

'suggestgrid': '0.1.31'

Once you sign up for SuggestGrid, you'll see your SUGGESTGRID_URL parameter on the dashboard in the format below:

http://{user}:{pass}@{region}.suggestgrid.space/{app-uuid}

You can authenticate your application using SUGGESTGRID_URL environment variable like the example below:

var suggestgrid = require('suggestgrid')
suggestgrid.configure(process.env.SUGGESTGRID_URL)

Every recommendation logic needs to belong to a type. For this demonstration we can create an implicit type named as views. This could be done either from the dashboard or with a snippet like this:

var typeController = suggestgrid.TypeController;

typeController.getType('views', function (error, response) {
    if (error && error.errorCode == 404) {
        typeController.createType('views', {'rating': 'implicit'}, function (error, response) {
            if (!error) {
                console.info('Views type is created')
            }
        })
    }
})

2. Post actions

Once the type exists, let's start posting actions. We should invoke SuggestGrid client's suggestgrid.ActionController.postAction when an user views an item in our application.

We can do this by putting the snippet below on the relevant point:

var actionController = suggestgrid.ActionController

app.get('/movie/:id', function (req, res) {
    var action = new suggestgrid.Action({type: 'views', user_id: user.id, item_id: req.params.id})
    actionController.postAction(action, function (error, response) {
        if (error) {
            console.error(error)
        } else {
            console.log(response)
        }
    })
})

The more actions SuggestGrid gets, more relevant and diverse its responses are.

Finally, let's show "movies similar users viewed" on movie pages.

SuggestGrid needs recommendation models for returning recommendations. Model generation is scheduled in every 24 hours. In addition, instant model generations can be triggered on the dashboard.

Once the first model generated for 'views' type, recommendations could be get using a snippet like the following:

var recommendationController = suggestgrid.RecommendationController;

function recommendItems(userId, callback) {
    recommendationController.recommendItems({type: 'views', user_id: userId}, callback)
}

Type methods are used for creating, getting, and deleting types. Refer to types for an overview.

suggestgrid.TypeController.createType(type, body, callback)

Creates a new type.

// Types have implicit rating type by default
typeContoller.createType('views', {}, function (error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})
typeContoller.createType('views', {'rating': 'implicit'}, function (error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})
typeContoller.createType('ratings', {'rating': 'explicit'}, function (error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})
URI/Query Parameters
Name Type Required Description
Body Parameters

TypeRequestBody (object)

Name Type Required Description
rating string false The rating type of the type. Could be "explicit" or "implicit", where "implicit" is the default.
type string true The name of the type.

suggestgrid.TypeController.getType(type, callback)

Returns the options of a type. The response rating parameter.

typeContoller.getType('views', function (error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})
URI/Query Parameters
Name Type Required Description
type string true The name of the type to get properties.

suggestgrid.TypeController.deleteType(type, callback)

Warning: Deletes the type with all of its actions and its recommendation model.

typeContoller.deleteType('views', function (error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})
URI/Query Parameters
Name Type Required Description
type string true The name of the type to be deleted.

suggestgrid.TypeController.getAllTypes(callback)

Returns all type names in an array named types.

typeContoller.getAllTypes(function (error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})

suggestgrid.TypeController.deleteAllTypes(callback)

Deletes ALL the types and ALL the actions.

typeContoller.deleteAllTypes(function (error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})

Action methods are for creating, getting, and deleting actions. Refer to actions for an overview.

suggestgrid.ActionController.postAction({type, user_id, item_id, rating})

Posts an action to the given type in the body. The body must have user id, item id and type. Rating is required for actions sent to an explicit type.

var action = {type: 'views', user_id: '20', item_id: '10'}
actionController.postAction(action, function (error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})
var action = {type: 'ratings', user_id: '20', item_id: '10', rating: 5}
actionController.postAction(action, function (error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})
Body Parameters

Action (object)

Name Type Required Description
itemId string true The item id of the item the action is performed on.
rating number false The optional rating given by the user, if the type is explicit.
timestamp integer false The optional UNIX epoch timestamp of the action. Defaults to the current timestamp.
type string true The type that the action belongs to.
userId string true The user id of the performer of the action.

suggestgrid.ActionController.postBulkActions(actions, callback)

Posts bulk actions to SuggestGrid. The recommended method for posting multiple actions at once.

There's a limit of lines, hence number of actions you can send in one requests of 10000.

An example for bulk action request is the following:

var actions = []
actions.push({'type': 'views', 'user_id' : '100', 'item_id' : '10'})
actions.push({'type': 'views', 'user_id' : '100', 'item_id' : '11'})
actions.push({'type': 'views', 'user_id' : '100', 'item_id' : '12'})
actions.push({'type': 'views', 'user_id' : '100', 'item_id' : '13'})
actions.push({'type': 'views', 'user_id' : '100', 'item_id' : '14'})
actions.push({'type': 'views', 'user_id' : '100', 'item_id' : '15'})
actions.push({'type': 'views', 'user_id' : '101', 'item_id' : '16'})
actions.push({'type': 'views', 'user_id' : '101', 'item_id' : '17'})
actions.push({'type': 'views', 'user_id' : '101', 'item_id' : '18'})
actions.push({'type': 'views', 'user_id' : '101', 'item_id' : '99'})

actionController.postBulkActions(actions, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})

Explicit actions can be post as

var actions = []
actions.push({'type': 'views', 'user_id' : '100', 'item_id' : '10', rating: 3})
actions.push({'type': 'views', 'user_id' : '100', 'item_id' : '11', rating: 23})
actions.push({'type': 'views', 'user_id' : '100', 'item_id' : '12', rating: 13})
actions.push({'type': 'views', 'user_id' : '100', 'item_id' : '13', rating: 9})
actions.push({'type': 'views', 'user_id' : '100', 'item_id' : '14', rating: 1})
actions.push({'type': 'views', 'user_id' : '100', 'item_id' : '15', rating: 4})
actions.push({'type': 'views', 'user_id' : '101', 'item_id' : '16', rating: 7})
actions.push({'type': 'views', 'user_id' : '101', 'item_id' : '17', rating: 12})
actions.push({'type': 'views', 'user_id' : '101', 'item_id' : '18', rating: 3})
actions.push({'type': 'views', 'user_id' : '101', 'item_id' : '99', rating: 6})

actionController.postBulkActions(actions, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})

suggestgrid.ActionController.getActions(type, userId, itemId, olderThan, from, size, callback)

Get actions. Defaut responses will be paged by 10 actios each. Type, user id, item id, or older than parameters could be provided. The intersection of the provided parameters will be returned.

If no query parameters is provided, all the actions will be returned:

actionController.getActions(null, null, null, null, null, null, function (error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})

You can include any of type, userId, itemId, and olderThan query parameters and SuggestGrid would return the actions satisfying all the query parameters: olderThan value could be a ISO 8601 duration, or a Unix time number.

actionController.getActions(null, '325', '168', null, null, null, function (error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})

You can also include from and size parameters to nativage throught the reponse actions. From defaults to 0 and size defaults to 10. Returned actions are sorted from the most recent one to the least recent ones.

URI/Query Parameters
Name Type Required Description
from integer The number of users to be skipped from the response. Defaults to 0. Must be bigger than or equal to 0. This parameter must be string represetation of an integer like "1".
item_id string Get actions of an item id.
older_than string Get actions older than the given duration, or the given time number. Could be a ISO 8601 duration, or a Unix time number. Specifications are available at https://en.wikipedia.org/wiki/ISO_8601#Durations, or https://en.wikipedia.org/wiki/Unix_time.
size integer The number of the users response. Defaults to 10. Must be between 1 and 10,000 inclusive. This parameter must be string represetation of an integer like "1".
type string Get actions of a type.
user_id string Get actions of a user id.

suggestgrid.ActionController.deleteActions(type, userId, itemId, olderThan)

Warning: Please use get actions with the exact parameters first to inspect the actions to be deleted.

  • Type must be provided.
  • If user id is provided, all actions of the user will be deleted.
  • If item id is provided, all actions on the item will be deleted.
  • If older than is provided, all actions older than the timestamp or the duration will be deleted.
  • If a number of these parameters are provided, the intersection of these parameters will be deleted.
  • In addition to a type, at least one of these parameters must be provided. In order to delete all the actions of a type, delete the type.

Type and at least one more parameter must be provided for all delete actions queries.

Delete a user's actions:

actionController.deleteActions('views', '12', null, null, function (error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})

Delete an item's actions:

actionController.deleteActions('views', null, '12', null, function (error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})

Delete old actions:

olderThan value could be a ISO 8601 duration in the form of PnDTnHnM, or a Unix time number.

Example durations:

  • P365D: Approximately a year.
  • P30D: Approximately a month.
  • P1DT12H: One and a half days.
  • P1D: A day (where a day is 24 hours or 86400 seconds).
  • PT12H: 10 hours (where an hour is 3600 seconds).
  • PT1M: 1 minute.

Delete actions older than a month:

actionController.deleteActions('views', null, null, 'P30D', function (error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})

Delete actions by query:

You can include any of userId, itemId, and olderThan parameters to the delete query and SuggestGrid would delete the intersection of the given queries accordingly.

For example, if all of userId, itemId, and olderThan are provided, SuggestGrid would delete the actions of the given user on the given item older than the given time or duration.

actionController.deleteActions('views', '1', '30', '891628467', function (error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})

It's highly recommended to first get the actions with the same parameters before deleting actions.

URI/Query Parameters
Name Type Required Description
item_id string Delete actions of an item id.
older_than string Delete actions older than the given duration, or the given time number. Could be a ISO 8601 duration, or a Unix time number. Specifications are available at https://en.wikipedia.org/wiki/ISO_8601#Durations, or https://en.wikipedia.org/wiki/Unix_time.
type string true Delete actions of a type. This parameter and at least one other parameter is required.
user_id string Delete actions of a user id.

Metadata methods are for creating, getting, and deleting user, and item metadata. Refer to metadata for an overview.

suggestgrid.MetadataController.postUser(user, callback)

Posts a user metadata. Note that this operation completely overrides previous metadata for the id, if it exists.

var user = {'id': '9394182', 'age': 28, 'name': 'Avis Horton'}

metadataController.postUser(user, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})
Body Parameters

Metadata (object)

Name Type Required Description
id string true The id of the metadata of a user or an item.

suggestgrid.MetadataController.postBulkUsers(users, callback)

Posts user metadata in bulk. Note that this operation completely overrides metadata with the same ids, if they exist.

There's a limit of lines, hence number of actions you can send in one requests. That's default to 10000.

An example for bulk user request is the following:

var users = []
users.push({'id': '9394182', 'age': 28, 'name': 'Avis Horton'})
users.push({'id': '6006895', 'age': 29, 'name': 'Jami Bishop'})
users.push({'id': '6540497', 'age': 21, 'name': 'Bauer Case'})
users.push({'id': '1967970', 'age': 30, 'name': 'Rosetta Cole'})
users.push({'id': '6084106', 'age': 35, 'name': 'Shaw Simon'})

metadataController.postBulkUsers(users, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})

suggestgrid.MetadataController.getUser(userId, callback)

Returns a user metadata if it exists.

metadataController.getUser('10', function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})
URI/Query Parameters
Name Type Required Description
user_id string true The user id to get its metadata.

suggestgrid.MetadataController.getUsers(size, from, callback)

Get items and total count of items. Page and per-page parameters could be set.

metadataController.getUsers(null, null, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})
URI/Query Parameters
Name Type Required Description
from integer The number of users to be skipped from the response. Defaults to 0. Must be bigger than or equal to 0. This parameter must be string represetation of an integer like "1".
size integer The number of the users response. Defaults to 10. Must be between 1 and 10,000 inclusive. This parameter must be string represetation of an integer like "1".

suggestgrid.MetadataController.deleteUser(userId, callback)

Deletes a user metadata with the given user id.

metadataController.deleteUser('10', function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})
URI/Query Parameters
Name Type Required Description
user_id string true The user id to delete its metadata.

suggestgrid.MetadataController.deleteAllUsers(callback)

Warning: Deletes all user metadata from SuggestGrid.

metadataController.deleteAllUsers(function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})

suggestgrid.MetadataController.postItem(item, callback)

Posts an item metadata. Note that this operation completely overrides previous metadata for the id, if it exists.

var item = {'id': '25922342', 'manufacturer': 'Vicon', 'price': 348}

metadataController.postItem(item, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})
Body Parameters

Metadata (object)

Name Type Required Description
id string true The id of the metadata of a user or an item.

suggestgrid.MetadataController.postBulkItems(items, callback)

Posts item metadata in bulk. Note that this operation completely overrides metadata with the same ids, if they exist.

There's a limit of lines, hence number of actions you can send in one requests, of 10000.

An example for bulk user request is the following:

var items = []
items.push({'id': '25922342', 'manufacturer': 'Vicon', 'price': 348})
items.push({'id': '80885987', 'manufacturer': 'Aquamate', 'price': 771})
items.push({'id': '71746854', 'manufacturer': 'Exoplode', 'price': 310})
items.push({'id': '53538832', 'manufacturer': 'Teraprene', 'price': 832})
items.push({'id': '72006635', 'manufacturer': 'Ohmnet', 'price': 340})

metadataController.postBulkItems(items, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})

suggestgrid.MetadataController.getItem(itemId, callback)

Returns an item metadata if it exists.

  metadataController.getItem('10', function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
  })
URI/Query Parameters
Name Type Required Description
item_id string true The item id to get its metadata.

suggestgrid.MetadataController.getItems(size, from, callback)

Gets items and total count of items. Page and per-page parameters could be set.

  metadataController.getItems(null, null, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
  })
URI/Query Parameters
Name Type Required Description
from integer The number of users to be skipped from the response. Defaults to 0. Must be bigger than or equal to 0. This parameter must be string represetation of an integer like "1".
size integer The number of the users response. Defaults to 10. Must be between 1 and 10,000 inclusive. This parameter must be string represetation of an integer like "1".

suggestgrid.MetadataController.deleteItem(itemId, callback)

Deletes an item metadata with the given item id.

metadataController.deleteItem('10', function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})
URI/Query Parameters
Name Type Required Description
item_id string true The item id to delete its metadata.

suggestgrid.MetadataController.deleteAllItems(callback)

Warning: Deletes all item metadata from SuggestGrid.

metadataController.deleteAllItems(function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.info(response)
    }
})

Recommendation methods are for getting recommended items for users, or recommended users for items. Refer to recommendations for an overview.

suggestgrid.RecommendationController.getRecommendedUsers(query, callback)

Returns recommended users for the query.

recommendationController.getRecommendedUsers({'type': 'view', 'item_id': '42'}, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.log(response.users) // [{'id':'451'},{'id':'456'}]
    }
})
recommendationController.getRecommendedUsers({'type': 'view', 'item_ids': ['42', '532', '841']}, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.log(response.users) // [{'id':'121'},{'id':'33'},{'id':'12'},{'id':'32'},{'id':'49'},{'id':'11'},{'id':'23'},{'id':'54'},{'id':'62'},{'id':'29'}]
    }
})
recommendationController.getRecommendedUsers({'type': 'view', 'item_ids': ['42', '532', '841'], 'similar_user_id': '100', 'except': ['100'], 'size': 5}, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.log(response.users) // [{'id':'1'},{'id':'84'},{'id':'9'},{'id':'32'},{'id':'45'}]
    }
})
recommendationController.getRecommendedUsers({'type': 'view', 'item_id': '42', 'size': 5, 'fields': ['name'], 'filter': { 'less_equal': {'age': 60}}}, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.log(response.users) // [{'id':'11','name':'Robert'},{'id':'848','name':'Mike'},{'id':'2','name':'Jennifer'}]
    }
})

You can read filters and fields documentations for further reference.

Body Parameters

GetRecommendedUsersBody (object)

Name Type Required Description
except array false These user ids that will not be included in the response.
fields array false The metadata fields to be included in returned user objects.
filter false
from integer false The number of most recommended items to be skipped from the response. Defaults to 0.
itemId string false The item id of the query.
itemIds array false The item ids of the query. Exactly one of item id or item ids parameters must be provided.
similarUserId string false Similar user that the response should be similar to.
similarUserIds array false Similar users that the response should be similar to. At most one of similar user and similar users parameters can be provided.
size integer false The number of users requested. Defaults to 10. Must be between 1 and 10,000 inclusive.
type string false The type of the query. Recommendations will be calculated based on actions of this type.
types array false The types of the query. Exactly one of type or types parameters must be provided.

suggestgrid.RecommendationController.getRecommendedItems(query, callback)

Returns recommended items for the query.

recommendationController.getRecommendedItems({'type': 'view', 'user_id': '42'}, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.log(response.items) // [{'id':'451'},{'id':'456'}]
    }
})
recommendationController.getRecommendedItems({'type': 'view', 'user_ids': ['42', '532', '841']}, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.log(response.items) // [{'id':'121'},{'id':'33'},{'id':'12'},{'id':'32'},{'id':'49'},{'id':'11'},{'id':'23'},{'id':'54'},{'id':'62'},{'id':'29'}]
    }
})
recommendationController.getRecommendedItems({'type': 'view', 'user_ids': ['42', '532', '841'], 'similar_item_id': '321', 'size': 3}, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.log(response.items) // [{'id':'13'},{'id':'65'},{'id':'102'}]
    }
})
recommendationController.getRecommendedItems({'type': 'view', 'user_id': '42', 'size': 5, 'filter': {'less_equal': {'price': 100}}}, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.log(response.items) // [{'id':'930'},{'id':'848'},{'id':'102'},{'id':'303'},{'id':'593'}]
    }
})
recommendationController.getRecommendedItems({'type': 'view', 'user_id': '42', 'size': 5, fields '': ['category'], 'filter': { 'exact': {'manufacturer': 'Apple'}}}, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.log(response.items) // [{'id':'930','category':'notebook'},{'id':'848','category':'keyboard'},{'id':'102','category':'watch'}]
    }
})

You can read filters and fields documentations for further reference.

Body Parameters

GetRecommendedItemsBody (object)

Name Type Required Description
except array false These item ids that will not be included in the response.
fields array false The metadata fields to be included in returned item objects.
filter false
from integer false The number of most recommended items to be skipped from the response. Defaults to 0.
similarItemId string false Similar item that the response should be similar to.
similarItemIds array false Similar items that the response should be similar to. At most one of similar item and similar items parameters can be provided.
size integer false The number of items requested. Defaults to 10. Must be between 1 and 10,000 inclusive.
type string false The type of the query. Recommendations will be calculated based on actions of this type.
types array false The types of the query. Exactly one of type or types parameters must be provided.
userId string false The user id of the query.
userIds array false The user ids of the query. Exactly one of user id or user ids parameters must be provided.

Similarity methods are for getting similar items, or similar users. Refer to similarities for an overview.

suggestgrid.SimilarityController.getSimilarUsers(query, callback)

Returns similar users for the query.

similarityController.getSimilarUsers({'type': 'views', 'user_id': '1'}, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.log(response.users) // [{'id':'12'},{'id':'451'},{'id':'456'}]
    }
})
similarityController.getSimilarUsers({'type': 'views', 'user_id': '1', 'except': ['12']}, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.log(response.users) // [{'id':'451'},{'id':'456'}]
    }
})
similarityController.getSimilarUsers({'type': 'views', 'user_ids': ['42', '532', '841'], 'size': 3, 'fields': ['name'], 'filter': { 'less_equal': { 'age': 20}}, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.log(response.users) // [{'id':'400', 'name':'Jason'},{'id':'132', 'name':'Scarlett'},{'id':'503', 'name':'Amy'}]
    }
})

You can read filters and fields documentations for further reference.

Body Parameters

GetSimilarUsersBody (object)

Name Type Required Description
except array false These user ids that will not be included in the response.
fields array false The metadata fields to be included in returned user objects.
filter false
from integer false The number of most similar users to be skipped from the response. Defaults to 0.
size integer false The number of users requested. Defaults to 10. Must be between 1 and 10,000 inclusive.
type string false The type of the query. Similarities will be calculated based on actions of this type.
types array false The types of the query. Exactly one of type or types parameters must be provided.
userId string false The user id of the query.
userIds array false The user ids of the query. Exactly one of user id or user ids parameters must be provided.

suggestgrid.SimilarityController.getSimilarItems(query, callback)

Returns similar items for the query.

similarityController.getSimilarItems({'type': 'views', 'item_id': '1'}, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.log(response.items) // [{'id':'12'},{'id':'451'},{'id':'456'}]
    }
})
similarityController.getSimilarItems({'type': 'views', 'item_id': '12', 'except': ['1']}, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.log(response.items) // [{'id':'451'},{'id':'456'}]
    }
})
similarityController.getSimilarItems({'type': 'views', 'item_ids':  ['3','5','8'], 'size': 3, 'fields': ['category'], 'filter': { 'greater': { 'capacity': 60}}, function(error, response) {
    if (error) {
        console.error(error)
    } else {
        console.log(response.items) // [{'id':'451','category':'television'},{'id':'656','category':'blu-ray-dvd-players'}]
    }
})

You can read filters and fields documentations for further reference.

Body Parameters

GetSimilarItemsBody (object)

Name Type Required Description
except array false These item ids that will not be included in the response.
fields array false The metadata fields to be included in returned item objects.
filter false
from integer false The number of most similar items to be skipped from the response. Defaults to 0.
itemId string false The item id of the query. Get similar items to given item id. Either item id or item ids must be provided.
itemIds array false The item ids of the query. Exactly one of item id or item ids parameters must be provided. Get similar items to given item ids. Either item id or item ids must be provided.
size integer false The number of items requested. Defaults to 10. Must be between 1 and 10,000 inclusive.
type string false The type of the query. Similarities will be calculated based on actions of this type.
types array false The types of the query. Exactly one of type or types parameters must be provided.