App Services is a backend as a service solution that enables you to get your apps up and running quickly. Using App Services, you can set up your own cloud-based data platform in minutes instead of months. And you can do it without any server-side coding. You can take advantage of App Services to quickly build leading-edge mobile apps with social graphs, geolocation, built-in activity streams, and more. Administrative features in App Services also make it easy to add and manage user accounts for your apps.

Store and access any type of application data

You can store any type of application data in the App Services infrastructure and immediately perform query or full-text searches on any field. App Services provides an easy-to-use, REST-based API and a set of SDKs that enable you to quickly store and query data in a variety of languages and platforms, including iOS, Android, JavaScript (HTML5), Ruby, Node.js, and C#. For example, after downloading the JavaScript (HTML5) SDK and doing some initial setup, storing an object is as easy as this:

var options = {
    type:'cats',
    name:'nico'
}
client.createEntity(options, function (err, cat) {
    if (err) {
        error('entity not created');
    } else {
        success('entity created');         
    }
});

Here, the object is a cat named 'nico'. App Services calls these objects entities. Entities are simple objects you may want to use in your app, such as cats, stores, and books. Entities of the same type are grouped in a collection: all the cats entities are in the cats collection. You don't have to first create the collection. Simply creating an entity of a certain type will create a collection for you if it doesn't already exist.

It's just as easy to retrieve an entity. If you're a Ruby user (and have the Ruby SDK installed and do some initialization), here’s how to get the cat named 'nico':

app = Usergrid::Application.new 'https://api.usergrid.com/my-org/sandbox/'
cat = app['cats/nico'].entity

Or do a more widespread query such as find all cats that begins with the letter 'n'. Here's how to do that using Ruby:

result = app['cats'].query "select * where name = 'n*'"
cat = result.collection

You can even upload and retrieve binary objects such as images, video, and audio.

When you create the entity, you can specify one or more properties for that entity, for example, the ca'’s name (as in the previous example), a book's author, or a store's location. In addition, some properties will be created automatically for you, such as a unique uuid identifier and a type property that identifies which collection the entity is in. You can query or do full-text searches on any entity property

Build social networking into your apps

App Services provides features that make it easy to build social networking-type apps. One of these features makes it easy to create relationships between entities. A simple example of this is the Twitter-like use of following, where one user forms a relationship with another by subscribing to any tweets they post. You can create a following relationship that connects two users (in this case, a user named Fred following a user named Barney) as easily as this in JavaScript (HTML5):

var options = {
    method:'POST',
    endpoint:'users/fred/following/users/barney
'    
};
client.request(options, function (err, data) {
    if (err) {
        //error — POST failed
    } else {
        //success — data will contain raw results from API call        
    }
});

You can just as easily create any type of relationship between entities, such as Fred likes his dog named Dino, or Barney works_for his manager named Mr. Slate, or John.Doe owns a task named build_project1.

Another key aspect of social networking apps is the ability to publish data streams, such as those that contain an ongoing list of comments, activities, and tweets, to connected users. Applications often struggle to manage these data streams, which typically include very large amounts of data, and which have to be routed automatically to subscribers or filtered or counted.

App Services makes it easy to manage and route these data streams. It provides an activity entity that is specifically designed for data streams. An activity is an entity type that represents activity stream actions. When a user creates an activity, it creates a relationship between the activity and the user who created it. Because this relationship exists, the activity will appear in the feed of any of the user’s followers.

You can take advantage of this functionality to enable activities such as status updates, check-ins, comments, or other broadcasts to fellow users. You can easily deliver activities to connected users to support messaging and notifications.

Manage user accounts and sign in

App Services makes it easy to add users to your apps. A user is an entity, like other entities, and user entities are grouped into a collection — in this case the users collection. As is the case for other entities, you can easily create, retrieve, and search for user entities. However, user entities come with automatic methods to do things such as securely save the user’s password, and look up people by email address.

Here’s an example of creating a user entity in Ruby:

app = Usergrid::Application.new 'https://api.usergrid.com/my-org/sandbox/'
result = app.create_user username: 'john.doe', name: 'John Doe', email: 'john.doe@gmail.com', password: 'test1234'
john_doe = result.entity

You can also organize users into groups. You decide what criteria to use for including users in a group. For example, it could be job role (such as manager) or relationship (such as schoolmate). You can take advantage of this in your apps to enable social networking on a group basis. For example, a user can post an activity to a group, in which case, a relationship is established between the activity and the group, and because of that, the activity will appear in the group’s feed. In other words, the activity will be published to all the users in the group.

A user can also create an activity for only their followers in a group. This is useful for users who want to create specific groups of friends (such as, acquaintances or colleagues) and publish content to them with more precise privacy settings. This allows you to re-create a privacy model similar to Google+’s Circles or Facebook’s current privacy system.

Beyond its support for adding users to an app, App Services enables your app users to sign in with their Facebook or Twitter accounts (or other OAuth-enabled accounts). You can also create your own proprietary accounts.

Visually administer applications and data

App Services provides a web-based tool called the Admin portal to manage applications and data for your organization. In this context, an application is a workspace in your organization that contains the entities and data for your app.

Using the Admin portal, you can perform administrative operations as varied as creating an application, adding users and groups to an application, and viewing or regenerating the credentials for your organization.

The Admin portal is itself an App Services app and is an example of using App Services with JavaScript. You can download the source code for the Admin Portal for inspection.

Learn more