Links
Comment on page

REST API

The REST API is used to interact with the Immersal Cloud Service.
You can use it to submit images for Spatial Map construction, modify and load Maps, and even use the on-server Visual Positioning.
Most REST API requests take JSON as input and also return the result as JSON
Most requests need a valid developer token for authentication. You can get it by logging in to the Developer Portal
We provide a sample implementation for Unity in C#, see the REST.cs and RESTJobsAsync.cs classes in the Immersal SDK Core .unitypackage
We also provide basic Python examples in this documentation.
It should also be quite straightforward to make the API calls in JSON from e.g. JavaScript & WebXR applications, and on other platforms.

API Methods

post
https://api.immersal.com
/align
Align Maps
post
https://api.immersal.com
/b2gb64
B2G Upload (base64)
post
https://api.immersal.com
/b2g
B2G Upload (binary)
post
https://api.immersal.com
/captureb64
Capture Image
post
https://api.immersal.com
/capture
Capture Image (Binary)
post
https://api.immersal.com
/clear
Clear Workspace
post
https://api.immersal.com
/clearmaptoken
Clear Map Access Token
post
https://api.immersal.com
/construct
Map Construct
post
https://api.immersal.com
/copy
Copy Map
get
https://api.immersal.com
/coverage
Check coverage
post
https://api.immersal.com
/delete
Delete Map
get
https://api.immersal.com
/dense
Download Dense Point Cloud
get
https://api.immersal.com
/download
Download Immersal Unity SDK
post
https://api.immersal.com
/ecef
Map ECEF (GPS)
post
https://api.immersal.com
/eula
Set EULA To Accepted
post
https://api.immersal.com
/fuse
Stitch Maps
post
https://api.immersal.com
/geolist
List Jobs (GPS)
post
https://api.immersal.com
/geolocalizeb64
Localize Image (GPS)
post
https://api.immersal.com
/geolocalize
Localize Image (GPS, Binary)
post
https://api.immersal.com
/geopose
Localize Image (Binary): Receive Longitude, Latitude, Altitude
post
https://api.immersal.com
/getposes
Get Poses
post
https://api.immersal.com
/list
List Jobs
post
https://api.immersal.com
/loadmap
Load Map (May be deprecated)
post
https://api.immersal.com
/localizeb64
Localize Image
post
https://api.immersal.com
/localize
Localize Image (Binary)
post
https://api.immersal.com
/login
Login
get
https://api.immersal.com
/map
Load Map
post
https://api.immersal.com
/mapb64
Load Map
post
https://api.immersal.com
/reset
Reset Map Coordinates
post
https://api.immersal.com
/metadataget
Get Map Metadata
post
https://api.immersal.com
/metadataset
Set Map Metadata
post
https://api.immersal.com
/password
Change Password
post
https://api.immersal.com
/privacy
Set Map Privacy
post
https://api.immersal.com
/register
Register New User
post
https://api.immersal.com
/restore
Restore Images
post
https://api.immersal.com
/setmaptoken
Set Map Access Token
get
https://api.immersal.com
/sparse
Download Sparse Point Cloud
post
https://api.immersal.com
/status
Account Status
get
https://api.immersal.com
/tex
Download Textured Mesh
post
https://api.immersal.com
/token
Change Developer Token
post
https://api.immersal.com
/upload
Uploads Chunked Files
post
https://api.immersal.com
/version
Get Version

C# Sample Code

The code below is an example of using the REST API to log in a user and retrieving their token. Except for the SDKLoginRequest class, all other Request classes inherit the requisite token from SDKRequestBase.
See the Immersal.Samples.Mapping.MapperJobs and Immersal.Samples.Mapping.Mapper classes and Samples/Scenes/MappingApp for more examples.
SDKLoginRequest loginRequest = new SDKLoginRequest();
loginRequest.login = "[email protected]";
loginRequest.password = "password";
string jsonString = JsonUtility.ToJson(loginRequest);
using (UnityWebRequest request = UnityWebRequest.Put(string.Format(Endpoint.URL_FORMAT, m_Sdk.localizationServer, Endpoint.LOGIN), jsonString))
{
request.method = UnityWebRequest.kHttpVerbPOST;
request.useHttpContinue = false;
request.SetRequestHeader("Content-Type", "application/json");
request.SetRequestHeader("Accept", "application/json");
yield return request.SendWebRequest();
SDKLoginResult loginResult = JsonUtility.FromJson<SDKLoginResult>(request.downloadHandler.text);
if (loginResult.error == "none")
{
Debug.Log(loginResult.token);
}
}

Entities

Construct Job

Represents a server job that is calculating the map
[Serializable]
public class SDKJob
{
public int id;
public int size;
public int bank;
public string work;
public string status; // "done" | "sparse" | "processing" | "failed" | "pending"
public string server;
public string name;
public double latitude;
public double longitude;
public double altitude;
public string created;
public string modified;
}

Map Id

Encapsulates a map's ID, might be extended in the future. Currently only used in SDKLocalizeRequest. In JavaScript and other platforms, this could be represented as a typical JSON object, e.g. {"id": 6779}.
[Serializable]
public class SDKMapId
{
public int id;
}

Requests and Responses

Login

Log in request / response
[Serializable]
public class SDKLoginRequest
{
public string login;
public string password;
}
[Serializable]
public class SDKLoginResult
{
public string error; // "none" | "auth"
public string token; // developer token
public int banks; // number of image banks, limited to 1 currently
}

Clear the Image Bank

Clear request / response
[Serializable]
public class SDKClearRequest : SDKRequestBase
{
public int bank; // id of image bank to clear
public bool anchor; // if true, clears also anchor points (i.e. empty cloud)
}
[Serializable]
public class SDKClearResult
{
public string error;
}

Construct a Map

Construct request / response
[Serializable]
public class SDKConstructRequest : SDKRequestBase
{
public int bank; // id of image bank
public string name; // name for the map
}
[Serializable]
public class SDKConstructResult
{
public int id; // id of the construction job / map
public int size; // number of images used to create the map
public string error;
}

Status

Status request / response
[Serializable]
public class SDKStatusRequest : SDKRequestBase
{
public int bank;
}
[Serializable]
public class SDKStatusResult
{
public int imageCount;
public int bankMax;
public int imageMax;
public bool eulaAccepted;
public string error;
}

List of All Jobs

Jobs request / response
[Serializable]
public class SDKJobsRequest : SDKRequestBase
{
public int bank;
}
[Serializable]
public class SDKJobsResult
{
public int count;
public SDKJob[] jobs;
public string error;
}

List of All Jobs (GPS)

The same as SDKJobsRequest, but only fetches the maps within the user's GPS location and range. If token is not given, all public maps will be fetched.
public class SDKGeoJobsRequest : SDKJobsRequest
{
public double latitude;
public double longitude;
public double radius;
}

Save Captured Image to the Map

Image request / response
[Serializable]
public class SDKImageRequest : SDKRequestBase
{
public int bank;
public int run;
public int index;
public bool anchor;
public double px; // camera x position
public double py; // camera y position
public double pz; // camera z position
public double r00; // rotation matrix row 0, col 0
public double r01; // rotation matrix row 0, col 1
public double r02; // rotation matrix row 0, col 2
public double r10; // rotation matrix row 1, col 0
public double r11; // rotation matrix row 1, col 1
public double r12; // rotation matrix row 1, col 2
public double r20; // rotation matrix row 2, col 0
public double r21; // rotation matrix row 2, col 1
public double r22; // rotation matrix row 2, col 2
public double fx; // camera intrinsics focal length x
public double fy; // camera intrinsics focal length y
public double ox; // camera intrinsics principal point x
public double oy; // camera intrinsics principal point y
public double latitude; // WGS84 latitude
public double longitude; // WGS84 longitude
public double altitude; // GPS elevation
public string b64; // Base64-encoded PNG image, 8-bit grayscale or 24-bit RGB
}
[Serializable]
public class SDKImageResult
{
public string path;
}

Localize Image

Localize request / response
The result (when localization has been successful) is a projection matrix in the AR Cloud space. It can be used to extract the position and rotation of the AR device, which then again can be combined with the device's local SLAM tracking.
[Serializable]
public class SDKLocalizeRequest : SDKRequestBase
{
public double fx; // camera intrinsics focal length x
public double fy; // camera intrinsics focal length y
public double ox; // camera intrinsics principal point x
public double oy; // camera intrinsics principal point y
public string b64; // Base64-encoded PNG image, 8-bit grayscale or 24-bit RGB
public SDKMapId[] mapIds; // list of maps to localize against
}
[Serializable]
public class SDKLocalizeResult : SDKResultBase
{
public bool success;
public int map; // ID of the map if localization was successful
public float px; // x position within the map
public float py; // y position within the map
public float pz; // z position within the map
public float r00; // rotation matrix row 0, col 0
public float r01; // rotation matrix row 0, col 1
public float r02; // rotation matrix row 0, col 2
public float r10; // rotation matrix row 1, col 0
public float r11; // rotation matrix row 1, col 1
public float r12; // rotation matrix row 1, col 2
public float r20; // rotation matrix row 2, col 0
public float r21; // rotation matrix row 2, col 1
public float r22; // rotation matrix row 2, col 2
}

Localize Image (GPS)

Geo-localize request. The response is the same as with SDKLocalizeRequest.
This request localizes against maps within a given radius near the device's GPS coordinates. The mapIds array can be left empty in this case.
[Serializable]
public class SDKGeoLocalizeRequest : SDKLocalizeRequest
{
public double latitude;
public double longitude;
public double radius;
}

Map coordinates in ECEF system (GPS)

ECEF request / response
[Serializable]
public class SDKEcefRequest : SDKRequestBase
{
public int id; // map ID
}
[Serializable]
public class SDKEcefResult : SDKResultBase
{
public double[] ecef; // ECEF coordinates
}

Delete Map

Delete map request / response
[Serializable]
public class SDKDeleteMapRequest : SDKRequestBase
{
public int id; // map ID
}
[Serializable]
public class SDKDeleteMapResult : SDKResultBase
{
}

Restore Images

Restore map images request / response
After restoring the map's images, it is possible to add more images to the map and recalculate it.
[Serializable]
public class SDKRestoreMapImagesRequest : SDKRequestBase
{
public int id; // map ID
}
[Serializable]
public class SDKRestoreMapImagesResult : SDKResultBase
{
}

Load Constructed Map

Map request / response
[Serializable]
public class SDKMapRequest : SDKRequestBase
{
public int id; // map ID
}
[Serializable]
public class SDKMapResult
{
public string md5_al; // MD5 hash for the loaded map
public string b64; // Base64 encoded .bytes map file
}

Errors

The REST API uses the following error codes (TBD):
Error Code
Meaning
400
Bad Request -- Your request is invalid.