 Hi, my name is Gabriel Corbera, a software engineer on the Microsoft Health and Band Team. In this video, I am going to talk about the Microsoft Health Cloud APIs and I will demonstrate how this can be used to build apps, to get access to users health and fitness data storing the Cloud. We will start with an introduction about the platform, then we'll jump into looking at the API and at the end, we will dissect the JavaScript sample to better understand how the API works. All right, let's get started by defining what is Microsoft Health. Microsoft Health is a service on the Cloud that is used to store and track health and fitness data from different sources. It is a powerful insights machine. It uses sensor data collected by the band and your phone to generate insights that help improve people's lives by providing insightful information as to the quality of their sleep and workouts and in general, about their day. Microsoft Health is multi-platform. It empowers users in any platform. Today, Microsoft Health allows users to see their information from any device as we have apps available in Android, iOS and Windows. And there is also a web dashboard which allows people to see more details on a bigger screen. It is also an open platform. It works with other fitness and health partners to enhance the user data. You might be thinking now, that sounds pretty cool, but can I, as a third-party developer, get access to that information to create new experiences? The answer is yes. Microsoft Health provides an API for third-party developers. This API is a standard resting point that gives you access to different kinds of data about your users. It uses JSON format to transfer data in a simple way. It is also a secure OAuth API that allows users to use their Microsoft account to provide third-party developers access to their information. It is a course-enabled API that allows you to build single-page web apps using client technology without having to build an extra layer on your server. Today, the API has four endpoints. The profile endpoint gives you access to users' height, weight, and name. The device's endpoint allows you to know how many devices are associated with the account and it is useful to find out if your user is using a Microsoft band or a phone to create data in their accounts. The summary's endpoint returns aggregated information about different metrics, such as born calories, hardware data, active hours, and step-staking, also distance travel. It returns this data aggregated by a given period. It doesn't differentiate if the user was running or slipping, for that we need the last endpoint. The activity's endpoint will let you dig deep into specific activities. You can find all the details about the sleep sessions, golf rounds, runs, bike sessions, and workouts. It may infer a moment that you are building an app to track how your user is improving when running. You will use this API to find out how fast they are running, what was their heart rate, and you will even get access to details such as elevation and actual GPS coordinates. Now that we have described the API, let's see them in action. First, we need to create an application in the Microsoft Account Developer Center. Here is the website, and you can see I already created an app for this demo. It is called demo. Let's take a look inside. In the many settings this website provides, we can see the client ID, return URL, and client secret. Here they are. We will need them for our app. Now, let's switch to Visual Studio. Here in Visual Studio, I have a demo website that is using the JavaScript sample available for download in the Microsoft Health Developer Portal. Using this sample, I can easily construct a JavaScript web application that accesses my data from the cloud using course. First, we will need to enter all the details about my app. Here we have this constructor called Microsoft Health that will initialize the app. You can see the client ID, it's here, the redirect URI, and also you can find the scopes that we're gonna request the user for permission. This will be used to get access to the information. Once you have the object, we have to call login. Login is gonna take us to login.live.com. It's gonna request permissions from the user, and then we're gonna be able to access the data. This sample will access the four endpoints. Let's take a look at them. Here is get profile. Here is get devices. Here is get summaries. As you can see, it gets a little bit more complicated. It has a period, it has a start time and an end time. Then we will see the get activities. All right, let's take a look at the JavaScript code. Here you can see that we are actually calling the XML HTTP request object to call the API with an HTTP request. It's really simple. Once we get the authorization token from login.live.com, we're gonna stick it into the authorization header here, which is gonna give us access to the API. All right, let's start using this app. As you can see, once it loads, it take us to login.live.com, and it will require us access to the data. In order to get the permission, the user has to go through these permissions, and then it will be able to say yes. Once they say yes, we'll get the access token, and then we'll be able to call the API. As you can see, the app has all my information now. It knows I have five devices, and it knows that I have locked seven activities in the last seven days. There's also other information. But I'm interested in run activities and slip activities. So I'm gonna modify this code so it takes more information and shows it here. All right, so I have prepared this line of code here that I'm gonna uncomment and we're gonna analyze now. So instead of just counting the number of activities, I'm gonna actually look at the slip activities, and I'm gonna use the length to know how many slip sessions I recorded in the seven days. Then we're gonna look at the run activities, and I'm gonna do the same. So let's run this. As you can see now, it is telling me that I locked five slip activities and I went for a run in the last seven days. This is pretty useful. All right, now that we saw this thing, and it is really simple, we're gonna see the API Explorer. If we go back to the Microsoft head developer portal, we can see that we have an API reference. In the API reference, you can see more details about the four endpoints, including the model of the data. So if you open this, you'll see that we can go and take a look at the properties for the activity response, how the bike activities are composed, and other information. This will give you access to all the useful fitness and health information of your users. You can find more information on the web regarding these APIs. In the Microsoft head developer portal, you can find more detailed information on the APIs, the exact contracts, and details on how to use it. To create your applications, you will need to register in the Microsoft Account Developer Center. And finally, there are many ways you can contact us. These are other resources that you can use to learn more about Microsoft Health and other very cool Microsoft products. Thank you for watching this video, and I look forward to see what kind of experiences this API will enable. Until next time.