# GETTING STARTED

current API version is 0.9 beta

# Basic concepts: Hierarchy

UMI APIs are based on parent children relationship between users and organizations. A basic relationship is as simple as passing a parentId to a request. To query a list of experiences of any user or start a session for a user you can pass the userId from your own platform (called externalUserId that is indeed different from UMI's userId) but you will have to pass your UMI's adminId to give context to the request. externalUserIds are not unique on our platform, they become unique under your adminId.

# Basic concepts: Authority

With this request you will get all public informations about the user.

// basic: you will retrieve only public informations about the user.
//be it his created games/experiences or his data.
const requestData = { userId: "e26a2d4a-634d-4c2e-bf73-878c876c2bf7" };

If you want, for example, get his non-public experiences you will have to provide a pair of userId-publicKey equal or greater than the level of authority of this user

// By using the user's publicKey we can get the same informations
//as we were logged as the user (you will not be able to get drafts)
let requestData = { userId: "e26a2d4a-634d-4c2e-bf73-878c876c2bf7", publicKey: "dsbtiUJaaEddsVsQYKa6zdsAUYnissjs=" };
// You can also send the date of
//the parent account (in this case the user's organizzation) and its publicKey
let requestData = { userId: "e26a2d4a-634d-4c2e-bcrif73-878c876c2bf7", publicKey: "ajshhd6++=oKSKlLMMna=", parentId: "92db75a4-jj28-476b-4452-221f40b45f73" };
// You can simplify things by including adminId and its publicKey
// in the request
let requestData = { userId: "e26a2d4a-634d-4c2e-bcrif73-878c876c2bf7", publicKey: "AAAAB3NzaC1yc2EAAAADAQABAAACAQDROqW94oqVzYwW8Sa5cmIsYGxjW3g", adminId: "42406c23-1826-4113-a895-0b9cec0d85e5" };

You can also pass a parentId without a userId to get all the items related to a certain organization, like getting all the experiences created by users under a company

let requestData = { publicKey: "ajshhd6++=oKSKlLMMna=", parentId: "92db75a4-jj28-476b-4452-221f40b45f73" };
//If you don't want to keep track of the publicKeys you can pass your adminId and your publicKey.
let requestData = { publicKey: "AAAAB3NzaC1yc2EAAAADAQABAAACAQDROqW94oqVzYwW8Sa5cmIsYGxjW3g", adminId: "42406c23-1826-4113-a895-0b9cec0d85e5", parentId: "92db75a4-jj28-476b-4452-221f40b45f73" };

If you prefer to use your own user ids you can replace the ids with your ids by prefixing the field with external (keeping the camel casing). ex. userId will be externalUserId and parentId externalParentId. As those ids are not unique you will have always to pass your adminId.

# Base url

This is UMI base url: it will be used to retrieve informations as well to get actual client url for your game.

const baseurl = "https://api.playumi.com";

# Basic usage

This is the url you will need to hit in order to get all the experiences created by a certain user.

const byUser =  "e26a2d4a-634d-4c2e-bf73-878c876c2bf7";
fetch(baseurl +  "experiences/?userId="  +byUser);
//The response will be similar to this one
{
    "success"  :  true,
    "items"  :  [{"id":  "85248535-0067-4bee-b494-94b78b60c9e1",  "projectName"  :  "Test"}]
}

Important: You will only receive public experiences through this configuration

# Option list

// api key
const apiKey = YOUR_PUBLIC_API_KEY // or a company under your partnership's API_KEY
fetch(baseurl + "experiences/?publicKey=" + apiKey);
const parentId = ANY_USER_ID / COMPANY ID //it will retrieve also children's user experiences.
fetch(baseurl + "experiences/?publicKey=" + apiKey + "&parentId=" + parentId)