REST

The REST APIs, at their root, are a set of HTTP-based APIs for accessing IMVU. This is hidden behind a clean, strongly-typed API. Aside from the fact that many operations are asynchronous, you don't have to worry about the fact that there are HTTP requests behind the scenes. The REST APIs are accessed through RestModel and RestCollection classes. Every function in the API that returns a RestModel or RestCollection will actually return a Promise, which is necessary because of the asynchronous nature of REST. See the documentation of Promises for more information on how those work.

The IMVU REST architecture can be thought of as a graph, and is often referred to as the REST graph. Each RestModel has a set of relations, which point to other RestModels or RestCollections, and each RestCollection has a list of RestModels. The RestModel and RestCollection classes aren't used directly, however. They're subclassed to things like the UserModel, AppModel or OutfitCollection. Each RestModel or RestCollection has an info field on it that stores the model's data. For a collection, it just has one field, items, which contains a List of Promises to the appropriate subclass of RestModel.

The entry point into the REST graph is the ConnectionModel, which you get by calling Imvu.Connect(). The first time you call Imvu.Connect(), it will prompt the user to login. If the user is already logged in, then it will just return the ConnectionModel. From the ConnectionModel, you can get the UserModel, which represents the current user, the AppModel, which represents the current app, and the PlayerModel, which represents the relationship between the current user and the current app.

For instance, to get the current user's name, you can do this:

Imvu.Connect().Then(
    connectionModel => connectModel.GetUser()
).Then(
    userModel => Debug.Log("User's name " + userModel.info.name)
    err => Debug.LogError(err)
);

The set of RestModels include:

The set of RestCollections include:

  • FriendCollection
  • IapCollection
  • OutfitCollection
  • PlayerIapCollection
  • ProductCollection
  • TransactionCollection