Getting Started

Overview

The Apsima REST Api can be used to access resources on the Apsima server from either a mobile device or another server.

Note: Most of these API are already encapsulated into the iOS and Android SDKs. It is strongly recommended to use those SDKs from those platforms as they provide a lot of more features.

Back To Top

Communication Protocol

The Api leverages the HTTPS protocol and conforms to REST constraints and conventions.

In order to use the Api an HTTP request can be sent to the server to a specific url as follows:

Request:
POST https://rest.apsima.com/api/users/authentications
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6OGZla3FqcmpyYWFhMXlxeXEyYWQ=
Accept: application/vnd.apsima.api-1.0+json
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
Content-Type: application/json
Host: 000.000.000.000
Content-Length: 111
{
    "username":"JohnDoe99",
    "password":"opensesame",
    "duration_type":1,
    "device_id":"43662ebb-3e8e-4b2a-8037-d14cd1088936"
}
Response:
HTTP/1.1 200 OK
Content-Length: 215
Content-Type: application/json
{
    "auth_id":"70486781-903f-48a3-ba78-f7eaa2d52458",
    "user_id":"559b7652-ede3-41d2-8631-6c3ffa763411","duration_type":1,
    "authenticated_time":"2014-03-01T02:21:16.459178Z",
    "expire_time":"2014-03-08T02:21:16.459178Z"
}

Back To Top

Request Message Format

The Api requires HTTP requests that consist of the following:

  1. URL
  2. HTTP Method
  3. HTTP Headers
  4. Request Body (only required for POST and PUT)

Back To Top

URL

A url is an address to a particular resource or a collection of resources.

In the Apsima Api, the urls are built up logically of a collection of resources and their sub collections of related resources.

Here is an example url:

https://rest.apsima.com/api/users/123/notifications/987

The first part of the resource rest.apsima.com/api is normally always the same and identifies the root path of the resources that can be reached via the api.

The next part of the resource users/123/notifications/987 identifies the resource as a set of related collections. In the previous example the url indicates that there is a collection of users, each of which can have a collection of notifications. The particular url used in the example, locates notification with id 987 which belongs to the user with id 123.

In such an example, the collection of all users could be accessible via:

https://rest.apsima.com/api/users

The resource for a particular user could be accessible via:

https://rest.apsima.com/api/users/123

The collection of all notifications for a user could be accessible via:

https://rest.apsima.com/api/users/123/notifications

And the resource for a particular notification of a particular user could be accessible via:

https://rest.apsima.com/api/users/123/notifications/987

Note that although these paths could be possible, the api does not always support all paths, and may support only specific HTTP methods (read HTTP methods in the next section) on any specific url.

Back To Top

URL Query Parameters

A Url may optionally contain query parameters which allow a resource to be located by some property other than its id.

Here is an example of a url with query parameters

https://rest.apsima.com/api/users?username=JohnDoe99

In the above example, the query parameter username is used to locate the user with the user name “JohnDoe99” in the users collection. A request with query parameters returns a list of resources that matches the query.

Back To Top

HTTP Method

Each url supports one or more of the GET, PUT, POST, or DELETE HTTP methods.

POST

The POST method will create a new resource and will not require a resource Id.

Example: A POST request to the following url would create a new user resource.

rest.apsima.com/api/users
GET

The GET method can merely be used to retrieve a resource and will never change a resource and is guaranteed not to have any side-effects.

Example: A GET request to the following url would retrieve the user resource 123.

rest.apsima.com/api/users/123
PUT

The PUT method will update a resource and will usually require a resource Id to do so.

Example: A PUT request to the following url would update the user resource 123..

rest.apsima.com/api/users/123
DELETE

The DELETE method will remove a resource. Resources removed with DELETE will normally no longer be accessible via other methods.

Example: A DELETE request to the following url would remove the user resource 123. from the system.

rest.apsima.com/api/users/123

Note that the GET, PUT, and DELETE methods are idempotent, meaning that sending the exact same request multiple times is the same as sending the request the first time.

Back To Top

Headers

The following headers are required:

Accept

This header defines which format the entire http message will have and which api version is used. This header is always required.

Example:

Accept: application/vnd.apsima.api-1.0+json

An accept header similar to the example above should be used, and only the version number can vary.

Content-Type

This header defines the format of the HTTP request body.   This header is required for POST and PUT requests.  For most urls, the content type will be application/json.  The content type application/octet-stream is only used for uploading raw bytes to the server as is the case for uploading images.

Examples:

Content-Type: application/json
Content-Type: application/octet-stream

Content-Length

This header defines the length of the content in the HTTP request body.  This header is only required for POST and PUT requests.  The length depends on which Content-Type is used.  For the application/json type it defines the total number of characters in the json string.  For the application/octet-stream type it defines the number of bytes.

Domain-Key

This header identifies which application domain you are using.  This allows the server to locate application specific data associated with the given value.

Example:

Domain-Key: 1ba3a26d-3f89-46ed-9ac4-5b8345212b2b

This value can be found in the Dashboard under the Api section of the Application tab.

application_domain_key

Authorization

This header is used to authorize the access to any api resource.

Example:

Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6OGZla3FqcmpyYWFhMXlxeXEyYWQ=

This header has the following format:

Authorization: Basic[SPACE][Base64 encoded representation of ApiKey:ApiSecret]

Base 64 Encoded Representation of Api Key and Secret:

In order to get a base 64 encoded version of the Api Key and Secret do the following:

    1. Locate the Api Key and Api Secret in the Dashboard

application_api_key

Which secret is used (Server Secret, or Client Secret) depends on whether the Api is being used to communicate from another server to the Apsima server or a mobile client to the Apsima server.

Server Secret:

Use this secret to communicate from a server to the Apsima server.

Client Secret:

This secret should be used when communicating from a mobile or web client to the Apsima server.

  1. Type out a string of the ApiKey and then a colon and then the ApiSecret as follows:
ApiKey:ApiSecret  (example: aa5yq17zxf7y-yq520zx: 8fekqjrjraaa1yqyq2ad)
  1. Then encode the string using base64 encoding.  (Refer to Appendix A for details on how to convert a string to base64 encoding).

User-Authorization

For various user-specific resources this additional header is required for additional security only if using the Api Client Secret.  If the Api Server Secret is used, this header is ignored.

An Example of a url which requires this header is:

https://rest.apsima.com/api/users/ 559b7652-ede3-41d2-8631-6c3ffa763411

Example:

User-Auth: ZmZhNzYzNDExOjJiNTdlZTNkLWNlYzEtNDM2My04NjAwLTJjMzcxNGQ5YjBlMA==

This header has the following format:

User-Auth: [Base64 encoded representation of UserId:AuthId]

The UserId is the resource id of the user.  In the example above it would be:

559b7652-ede3-41d2-8631-6c3ffa763411

The AuthId is the authorization token received in the auth_id property of the response to an authentication request.  (Please refer to the LoginUser section on how to create a new authentication token)

In order to create a base64 representation:

    1. Form the string as follows:
559b7652-ede3-41d2-8631-6c3ffa76341<b>:</b>91db2614-1214-4d06-b7be-5d5db0b69150
    1. Convert the string to base64 (Refer to Appendix A for details on how to convert a string to base64 encoding).
ZmZhNzYzNDExOjJiNTdlZTNkLWNlYzEtNDM2My04NjAwLTJjMzcxNGQ5YjBlMA==
    1. Then form the header as follows:
User-Auth: ZmZhNzYzNDExOjJiNTdlZTNkLWNlYzEtNDM2My04NjAwLTJjMzcxNGQ5YjBlMA==

Device-Type

This header identifies what device you are using.  This allows the server to locate device specific data associated with the given value.

Example:

Device-Type: AndroidPhone

Currently, the supported Device-Type values are Web, iPhone, iPad, AndroidPhone, AndroidTablet, and WindowsPhone.

Back To Top

Request Body

The GET and DELETE methods will not require a request body to be sent, however for POST and PUT methods a request body is always expected. The format of the request body is usually in json (JavaScript Object Notation) format.
The following is an example of a request that includes a request body:

POST https://rest.apsima.com/api/users/authentications
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6OGZla3FqcmpyYWFhMXlxeXEyYWQ=
Accept: application/vnd.apsima.api-1.0+json
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
Content-Type: application/json
Host: 000.000.000.000
Content-Length: 111
{
    "username":"JohnDoe99",
    "password":"opensesame",
    "duration_type":1,
    "device_id":"43662ebb-3e8e-4b2a-8037-d14cd1088936"
}

Back To Top

JSON Format & Conventions

The api uses JSON format as its main format for application data communicated to the api as well as data received from the api.
A json object is denoted by curly braces “{}”, and contains a set of key and value pairs “key”:value, which define property names and values. The property names used in the api follow snake_case conventions which means that only lower case letters are used and underscores are used to divide words.

Back To Top

Data Types

Text Format

All text values are represented as strings surrounded by double quotation marks “”.

"username":"JohnDoe99",
Resource Identifiers

All resource identifiers use GUID (globally unique identifiers) format.

43662ebb-3e8e-4b2a-8037-d14cd1088936

In request and response bodies, these values must be represented in text format (i.e. surrounded by double quotation marks)

"device_id":"43662ebb-3e8e-4b2a-8037-d14cd1088936"
Number Format

Number values are represented as simple numeric values without quotations

"duration_type":1
Date Format

Dates are in ISO 8601 Date format.

"expire_time":"2014-03-08T02:21:16.459178Z"

Back To Top

Responses

A response will usually consist of a status code, and optionally content which is defined by a content-type which signals which format the content will have and the content data. Note that a response will not always contain content. Most DELETE requests, for example, will just contain a status code, and no additional content.
The following is an example of a response:

HTTP/1.1 200 OK
Content-Length: 215
Content-Type: application/json
{
    "id":"cdd82fa8-4a07-47db-9bbe-000fbdfaad2f",
    "type":1,
    "user_id":"66D566C1-DF24-49DD-ADE9-21B3E211EF13",
    "notification_key":"2bd6e20efb3943a1ac21a07402f4f78e",
    "is_active":true
}

Back To Top

Response Content

The response content is usually in JSON format.

Back To Top

Response Status Codes

200 – Success

This response means that the request was successful.

201 – Created

This response occurs when a request was made to a url using POST, and indicates that a new resource was successfully created.

401 – Unauthorized

This response occurs when either the Api Key and Api Secret could not be validated or in the case a user authentication token is required and the one provided could not be validated.

404 – Not Found

This response occurs when the resource defined in the url could not be found.

409 – Bad Request

This response occurs if the syntax of the data provided was incorrect.

422 – Unprocessable Entity

This response occurs if the syntax of the data was correct but the data semantics of the data was incorrect.

50x – Internal Server Error

This response occurs when an error occurred on the server while trying to process the request.

Back To Top

API

API Documentation

This Api documentation is provided for clients to be able to make these calls themselves. If they are using Apsima Mobile SDK (iOS and Android), most of these calls have been implemented inside the SDK.

Back To Top

CreateDevice

POST

The POST method can be used to request the server to generate a new device uid. App needs to call createDevice if it has not saved device uid locally. If device uid already exist, then call updateDevice.

Json key:
  • notification_key is an identifier used in push notification. In Android, it is GCM Registration Id. In iOS, it is deviceToken. Use “undefined”, if it is not yet available.
  • type defines device type (0 = Web, 1 = iPhone, 2 = iPad, 3 = AndroidPhone, 4 = AndroidTablet, 5 = WindowsPhone).
  • is_active is a flag whether device is active (true) or inactive (false).

 

Request:
POST https://rest.apsima.com/api/devices HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Content-Type: application/json
Content-Length: 58
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
 
{
    "notification_key":"undefined",
    "type":3,
    "is_active":true
}
Response:
HTTP/1.1 201 Created
Cache-Control: private
Content-Length: 154
Content-Type: application/xml; charset=utf-8
Location: https://rest.apsima.com/api/devices/34a0713e-2d1d-4336-9241-c7467e58614a
Server: Microsoft-IIS/7.5
Set-Cookie: ASP.NET_SessionId=saqkn45ntdzfeupjqrkw0uhv; path=/; HttpOnly
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 22:14:37 GMT
 
{
    "id":"34a0713e-2d1d-4336-9241-c7467e58614a",
    "type":3,
    "user_id":"00000000-0000-0000-0000-000000000000",
    "notification_key":"undefined",
    "is_active":true
}

Back To Top

UpdateDevice

PUT

The PUT method can be used to update server with the current device uid or when notification_key is modified. See CreateDevice for parameters.

Request:
PUT https https://rest.apsima.com/api/devices/4eb71d30-4309-4f64-8525-90b03b173f47 HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Content-Type: application/json
Content-Length: 260
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OjJhNzA4YzlhLTA3ZTktNGI0YS04Yzk0LTRkY2I4YWVlZjQ5Nw==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
 
{
    "user_id":"32aee5b7-6027-411a-a438-526b3e766fe5",
    "notification_key":"APA91bHgOFMX6mwT47j756JG8AQ21O0nYI9x2ZJJokNmMNkAh3FdXgpE03Xfp25BaeoiZWcbipvxicWFMstfR3XC1BzqtJRl6VuGTUn6kBIZ0Ss3nRLawoFhYwi2ZlHkGEs76NYVa5cusjyy4TiSUXWVtSUZ60_zuQ",
    "type":3,
    "is_active":true
}
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 307
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 18:09:17 GMT
 
{
    "id":"4eb71d30-4309-4f64-8525-90b03b173f47",
    "type":3,
    "user_id":"00000000-0000-0000-0000-000000000000",
    "notification_key":"APA91bHgOFMX6mwT47j756JG8AQ21O0nYI9x2ZJJokNmMNkAh3FdXgpE03Xfp25BaeoiZWcbipvxicWFMstfR3XC1BzqtJRl6VuGTUn6kBIZ0Ss3nRLawoFhYwi2ZlHkGEs76NYVa5cusjyy4TiSUXWVtSUZ60_zuQ",
    "is_active":true
}

Back To Top

LoginUser

POST

The POST method can be used to create a new authentication token. Save the userId and authId locally, and we also need to create an authentication token using base64 encoded representation of userId:authId. This token will be used in User Authorization header.

Json key:
  • Device_id is a unique identifier assigned by server for this device.
  • Duration_type defines if authentication is long lived or short lived. (1= LongLived, 2= ShortLived)

 

Request:
POST https://rest.apsima.com/api/users/authentications HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Content-Type: application/json
Content-Length: 120
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MjAyM2EwNWEtMjQ4MC00Nzk0LWFlYzktNTRlNzVhM2FjZDUwOjdmNzFhNjM1LTQzZDEtNDMxNC05Y2RlLWQ2Y2NlNjcxNTQ5YQ==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
 
{
    "device_id":"4eb71d30-4309-4f64-8525-90b03b173f47",
    "username":"johnsmith101",
    "password":"opensesame",
    "duration_type":1
}
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 217
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 02:53:28 GMT
 
{
    "auth_id":"1437c511-5c34-47c9-aba0-bcfbd83700cc",
    "user_id":"32aee5b7-6027-411a-a438-526b3e766fe5",
    "duration_type":1,
    "authenticated_time":"2014-03-05T02:53:28.2797712Z",
    "expire_time":"2014-03-12T02:53:28.2797712Z"
}

Back To Top

LogoutUser

DELETE

The DELETE method can be used to invalidate an existing authentication token.

Request:
DELETE https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5/authentications/7cf60b3e-0e30-485a-a81e-f5f9c8463795 HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OjdjZjYwYjNlLTBlMzAtNDg1YS1hODFlLWY1ZjljODQ2Mzc5NQ==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
Response:
HTTP/1.1 200 OK
Cache-Control: private
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 18:06:59 GMT
Content-Length: 0

Back To Top

ExtendLogin

PUT

The PUT method can be used to extend expiration time of current authentication token.

Request:
PUT https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5/authentications/2a708c9a-07e9-4b4a-8c94-4dcb8aeef497/extension HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Content-Type: application/json
Content-Length: 2
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OjJhNzA4YzlhLTA3ZTktNGI0YS04Yzk0LTRkY2I4YWVlZjQ5Nw==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
 
{}
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 217
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 18:10:01 GMT
 
{
    "auth_id":"2a708c9a-07e9-4b4a-8c94-4dcb8aeef497",
    "user_id":"32aee5b7-6027-411a-a438-526b3e766fe5",
    "duration_type":1,
    "authenticated_time":"2014-03-05T18:10:02.4559194Z",
    "expire_time":"2014-03-12T18:10:02.4559194Z"
}

Back To Top

CreateUser

POST

The POST method can be used to create a new user. This is called when a new user is signing up.

Json key:
  • Type defines the type of user. Default value is 0 (zero).
Request:
POST https://rest.apsima.com/api/users 
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Content-Type: application/json
Content-Length: 127
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MjAyM2EwNWEtMjQ4MC00Nzk0LWFlYzktNTRlNzVhM2FjZDUwOjdmNzFhNjM1LTQzZDEtNDMxNC05Y2RlLWQ2Y2NlNjcxNTQ5YQ==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
{
    "email":"johnsmith101@email.com",
    "first_name":"john",
    "last_name":"smith",
    "password":"opensesame",
    "username":"johnsmith101",
    "type":0
}
Response:
HTTP/1.1 201 Created
Cache-Control: private
Content-Length: 156
Content-Type: application/xml; charset=utf-8
Location: https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 02:51:31 GMT
 
{
    "id":"32aee5b7-6027-411a-a438-526b3e766fe5",
    "username":"johnsmith101",
    "first_name":"john",
    "last_name":"smith",
    "email":"johnsmith101@email.com",
    "type":0
}

Back To Top

GetUser

GET

The GET method can be used to create a new authentication token.

Request:
GET https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5 HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1Ojg4ZTQ0YTg5LTFjMTctNGUwZC05MGQ3LTIyYjFhMjA3YzMwYg==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 156
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 03:04:58 GMT
 
{
    "id":"32aee5b7-6027-411a-a438-526b3e766fe5",
    "username":"johnsmith101",
    "first_name":"john",
    "last_name":"smith",
    "email":"johnsmith101@email.com",
    "type":0
}

Back To Top

UpdateUser

PUT

The PUT method can be used to update user’s information. See CreateUser for parameter.

Request:
PUT https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5 HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Content-Type: application/json
Content-Length: 153
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1Ojg4ZTQ0YTg5LTFjMTctNGUwZC05MGQ3LTIyYjFhMjA3YzMwYg==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
 
{
    "email":"johnsmith102@email.com",
    "first_name":"john",
    "id":"32aee5b7-6027-411a-a438-526b3e766fe5",
    "last_name":"smith",
    "username":"johnsmith102",
    "type":0
}
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 156
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 03:34:37 GMT
 
{
    "id":"32aee5b7-6027-411a-a438-526b3e766fe5",
    "username":"johnsmith102",
    "first_name":"john",
    "last_name":"smith",
    "email":"johnsmith102@email.com",
    "type":0
}

Back To Top

GetUserProfileImage

GET

The GET method can be used to obtain user’s profile image.

Request:
GET https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5/profile_image HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OjJhNzA4YzlhLTA3ZTktNGI0YS04Yzk0LTRkY2I4YWVlZjQ5Nw==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 31362
Content-Type: image/jpeg
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 18:10:06 GMT

Back To Top

UpdateUserProfileImage

PUT

The PUT method can be used to update user’s profile image.

Request:
PUT https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5/profile_image HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Content-Type: application/octet-stream
Transfer-Encoding: chunked
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OjJhNzA4YzlhLTA3ZTktNGI0YS04Yzk0LTRkY2I4YWVlZjQ5Nw==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
Response:
HTTP/1.1 200 OK
Cache-Control: private
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 18:16:04 GMT
Content-Length: 0

Back To Top

ChangeUserPassword

PUT

The PUT method can be used to change user’s password.

Request:
PUT https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5/password HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Content-Type: application/json
Content-Length: 62
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1Ojg4ZTQ0YTg5LTFjMTctNGUwZC05MGQ3LTIyYjFhMjA3YzMwYg==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
 
{
    "current_password":"opensesame",
    "new_password":"opensesame1"
}
Response:
HTTP/1.1 200 OK
Cache-Control: private
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 03:36:32 GMT
Content-Length: 0

Back To Top

SendPasswordForgetEmail

POST

The POST method can be used to request server to send temporary password via email.

Request:
POST https://rest.apsima.com/api/users/password_forget HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Content-Type: application/json
Content-Length: 27
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=saqkn45ntdzfeupjqrkw0uhv
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
 
{
    "username":"johnsmith102"
}
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 103
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 23:18:32 GMT

Back To Top

GetProperties

GET

The GET method can be used to obtain a list of custom properties for users.

Json key:
  • Type defines custom property data type (1=Built-In, 2= Enum, 3= Text, 4= Int, 5= Float, 6= Date).
  • Default_value is the expected default value for a specific property.
  • Type_value is a numeric identifier for a specific custom property choice.

 

Request:
GET https://rest.apsima.com/api/properties HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OjE0MzdjNTExLTVjMzQtNDdjOS1hYmEwLWJjZmJkODM3MDBjYw==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 7108
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 02:54:00 GMT
 
[{
    "id":"99c1c133-31d9-45d4-bc90-0ad01ab37a84",
    "name":"Ethnicity",
    "description":"What is your Ethnicity?",
    "type":2,
    "default_value":"",
    "choices":
[{
    "id":"3f3422a9-cae7-46f1-ab68-da24f7773670",
    "description":"African American",
    "type_value":1
},{
    "id":"08c38ea1-5770-45b8-873b-d5aae9b24998",
    "description":"Asian",
    "type_value":2
}]
},{
    "id":"dc2d2930-ce20-4112-80ef-1091f311c090",
    "name":"Text Pro",
    "description":"It is text pro",
    "type":3,
    "default_value":"test",
    "choices":[]
}]

Back To Top

GetOfferByUserOfferUid

GET

The GET method can be used to obtain a specific Notification.

Request:
GET https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5/notifications/7732e303-f42a-4586-9d4c-a1b4bd3e3c4e HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OjJhNzA4YzlhLTA3ZTktNGI0YS04Yzk0LTRkY2I4YWVlZjQ5Nw==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone

Response:

HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 381
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 18:50:58 GMT
 
{
    "id":"7732e303-f42a-4586-9d4c-a1b4bd3e3c4e",
    "template_id":"1b368c26-e227-4f01-b14f-72585cfd5c15",
    "owner_id":"3f48393c-3dd1-41f6-8190-84dc991fb91c",
    "time_started":"2014-03-05T18:50:00Z",
    "time_expired":"2014-03-12T17:50:00Z",
    "title":"Come in and get scanned",
    "description":"for a free Lobster dinner",
    "is_read":false,
    "is_deleted":false,
    "time_modified":"2014-03-05T18:50:50.037Z"
}

Back To Top

GetUserOfferThumbnail

GET

The GET method can be used to obtain the thumbnail of Notification.

Request:
GET https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5/notifications/7732e303-f42a-4586-9d4c-a1b4bd3e3c4e/thumbnail HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OjJhNzA4YzlhLTA3ZTktNGI0YS04Yzk0LTRkY2I4YWVlZjQ5Nw==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 18656
Content-Type: image/jpeg
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 18:50:58 GMT

Back To Top

GetUserOfferContent

GET

The GET method can be used to obtain the content of a specific Notification.

Request:
GET https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5/notifications/7732e303-f42a-4586-9d4c-a1b4bd3e3c4e/content HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OjJhNzA4YzlhLTA3ZTktNGI0YS04Yzk0LTRkY2I4YWVlZjQ5Nw==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 1077
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 19:20:24 GMT
 
{
"content":
"<!DOCTYPE html> 
 <html>          
     <head>         
         <meta charset=\"utf-8\" />         
         <meta name=\"viewport\" content=\"initial-scale=1\" />         
         <title>Come in and get scanned for a free Lobster dinner</title>         
         <link rel=\"stylesheet\" href=\"https://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css\" />         
         <link rel=\"stylesheet\" href=\"https://portal.player360inc.com/Ad/Themes/Woody/Woody.min.css\" />     
     </head>          
     <body>         
         <div data-role=\"page\" id=\"welcome\" data-theme=\"a\">             
             <div style=\"box-shadow: 0px 3px 4px 4px  #E2E2E2;\">                 
                 <img src=\"https://portal.player360inc.com/Ad/Images/ads-image-sample-3b.png\" width=\"100%\">             
             </div>             
             <div data-role=\"content\">                 
                 <div style=\"color: #F30; font-size: 1em;\">
                     Come in and get scanned for a <strong>free Lobster dinner</strong>.
                 </div>                 
                 <p>Nunc tellus justo, sagittis ac convallis quis, tincidunt a leo. Fusce tempus viverra luctus.</p>             
             </div>         
         </div>     
     </body>  
 </html>"
}

Back To Top

ReadOffer

POST

The POST method can be used to notify server that Notification has been opened.

Json key:
  • is_read is true when this offer is opened from Android/iOS System Notification. If user opens this notification from the App’s UI, it should be set to false.

 

Request:
POST https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5/notifications/7732e303-f42a-4586-9d4c-a1b4bd3e3c4e/read HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Content-Type: application/json
Content-Length: 17
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OjJhNzA4YzlhLTA3ZTktNGI0YS04Yzk0LTRkY2I4YWVlZjQ5Nw==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
 
{
"is_read":false
}
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 380
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 19:20:26 GMT
 
{
    "id":"7732e303-f42a-4586-9d4c-a1b4bd3e3c4e",
    "template_id":"1b368c26-e227-4f01-b14f-72585cfd5c15",
    "owner_id":"3f48393c-3dd1-41f6-8190-84dc991fb91c",
    "time_started":"2014-03-05T18:50:00Z",
    "time_expired":"2014-03-12T17:50:00Z",
    "title":"Come in and get scanned",
    "description":"for a free Lobster dinner",
    "is_read":true,
    "is_deleted":false,
    "time_modified":"2014-03-05T19:20:26.467Z"
}

Back To Top

GetOfferUpdates

GET

The GET method can be used to get the updates of all Notifications if there is any change since last GetOfferUpdates.

Request:
GET https https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5/notifications/updates?types=1&max_count=999&from=2014-03-05T18%3A09%3A24Z&first_load=false HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OjJhNzA4YzlhLTA3ZTktNGI0YS04Yzk0LTRkY2I4YWVlZjQ5Nw==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 382
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 19:20:32 GMT
 
[{
    "id":"7732e303-f42a-4586-9d4c-a1b4bd3e3c4e",
    "template_id":"1b368c26-e227-4f01-b14f-72585cfd5c15",
    "owner_id":"3f48393c-3dd1-41f6-8190-84dc991fb91c",
    "time_started":"2014-03-05T18:50:00Z",
    "time_expired":"2014-03-12T17:50:00Z",
    "title":"Come in and get scanned",
    "description":"for a free Lobster dinner",
    "is_read":true,
    "is_deleted":false,
    "time_modified":"2014-03-05T19:20:26.467Z"
}]

Back To Top

DeleteOffer

DELETE

The DELETE method can be used to notify server that offer has been deleted by user.

Request:
DELETE https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5/notifications/7732e303-f42a-4586-9d4c-a1b4bd3e3c4e HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OjJhNzA4YzlhLTA3ZTktNGI0YS04Yzk0LTRkY2I4YWVlZjQ5Nw==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
Response:
HTTP/1.1 204 No Content
Cache-Control: private
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 19:33:21 GMT

Back To Top

GetUserSettingUpdates

GET

The GET method can be used to obtain user’s setting.

Json key:
  • type defines which UserSetting that has been set. (1= PaymentProcessedEmailEnabled, 2= PaymentProcessedPushEnabled, 3= KspNotificationPushEnabled)
  • value defines UserSetting is enabled (1) or disabled (2). (1= true, 0= false)

 

Request:
GET https https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5/settings/updates?from=1970-01-01T00%3A00%3A00Z&first_load=true HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OjBiNWZmYWQ0LWE5ODctNDA1Yi05ZWU5LWQyNDlkZjFjOGM0Zg==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 73
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 19:44:37 GMT
 
[{
    "type":1,
    "value":"1"
},
{
    "type":2,
    "value":"1"
},
{
    "type":3,
    "value":"1"
}]

Back To Top

UpdateUserSetting

PUT

The PUT method can be used to notify server that user has modified user’s setting. See GetUserSettingUpdates for parameters.

Request:
PUT https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5/settings HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Content-Type: application/json
Content-Length: 22
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OjBiNWZmYWQ0LWE5ODctNDA1Yi05ZWU5LWQyNDlkZjFjOGM0Zg==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
 
{
    "value":"0",
    "type":3
}
Response:
HTTP/1.1 200 OK
Cache-Control: private
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 20:10:19 GMT
Content-Length: 0

Back To Top

GetBeaconGroupUpdates

GET

The GET method can be used to get all beacon groups that need to be monitored since the last update.

Json key:
  • app_hardware_id defines the identifier used as proximityUid.
  • Group_hardware_id defines the identifier used as majorId.

 

Request:
GET https://rest.apsima.com/api/beacon_groups/updates?owner_id=3f48393c-3dd1-41f6-8190-84dc991fb91c&from=1970-01-01T00%3A00%3A00Z&first_load=true HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OjBiNWZmYWQ0LWE5ODctNDA1Yi05ZWU5LWQyNDlkZjFjOGM0Zg==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 1346
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Wed, 05 Mar 2014 19:44:36 GMT
 
[{
    "id":"c78e4ddc-b59d-40bf-817c-06e106337beb",
    "name":"Women Shoes",
    "app_hardware_id":"E2C56DB5-DFFB-48D2-B060-D0F5A71096E0",
    "group_hardware_id":20,
    "is_deleted":false
}, 
{
    "id":"e071c0a9-e768-436d-bfdd-396bf84aec35",
    "name":"Handbags",
    "app_hardware_id":"E2C56DB5-DFFB-48D2-B060-D0F5A71096E0",
    "group_hardware_id":1,
    "is_deleted":false
}]

Back To Top

GetOfferRelatedBeaconGroupUpdates

GET

The GET method can be used to obtain a list of Beacon Groups that is related to Notifications for this user. See GetBeaconGroupUpdates for parameters.

Request:
GET https https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5/beacon_groups/notifications/updates?owner_id=3f48393c-3dd1-41f6-8190-84dc991fb91c&from=1970-01-01T00%3A00%3A00Z HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=saqkn45ntdzfeupjqrkw0uhv
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OmExMDA5NDc1LTMwNWQtNGNlMy05YjY0LWUzZDVmNTQ5YzMwOA==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 332
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Thu, 06 Mar 2014 02:46:04 GMT
 
[{
    "id":"e071c0a9-e768-436d-bfdd-396bf84aec35",
    "name":"Toy Department",
    "app_hardware_id":"E2C56DB5-DFFB-48D2-B060-D0F5A71096E0",
    "group_hardware_id":1,
    "is_deleted":false
},
{
    "id":"e4df0e63-d584-4d07-94c3-55e5bb00fadc",
    "name":"Office",
    "app_hardware_id":"E2C56DB5-DFFB-48D2-B060-D0F5A71096E0",
    "group_hardware_id":4,
    "is_deleted":false
}]

Back To Top

ReportBeaconGroupTriggered

POST

The POST method can be used to report that the device is within proximity of a BeaconGroup.

Json key:
  • Trigger_time defines the time that the event is recorded.
  • Trigger_direction defines the direction of the event. (1=Enter, 2=Exit)

 

Request:
POST https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5/beacon_groups/e4df0e63-d584-4d07-94c3-55e5bb00fadc/triggered HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Content-Type: application/json
Content-Length: 61
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=saqkn45ntdzfeupjqrkw0uhv
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OmExMDA5NDc1LTMwNWQtNGNlMy05YjY0LWUzZDVmNTQ5YzMwOA==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
 
{
    "trigger_time":"2014-03-06T02:24:11Z",
    "trigger_direction":1
}
Response:
HTTP/1.1 200 OK
Cache-Control: private
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Thu, 06 Mar 2014 02:24:31 GMT
Content-Length: 0

Back To Top

GetBeacons

GET

The GET method can be used to obtain information about a specific Beacon.

Json key:
  • Extra holds extra information about Beacon.

 

Request:
GET https://rest.apsima.com/api/beacons?hardware_id=7&amp;group_id=e4df0e63-d584-4d07-94c3-55e5bb00fadc HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=saqkn45ntdzfeupjqrkw0uhv
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OmExMDA5NDc1LTMwNWQtNGNlMy05YjY0LWUzZDVmNTQ5YzMwOA==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 427
Content-Type: application/json
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, DELETE
Access-Control-Allow-Headers: Content-Type, UserUid, Domain-Key, Authorization, Accept
Date: Thu, 06 Mar 2014 02:34:44 GMT
 
[{
    "id":"13d8ce73-845e-429e-8c44-79ab6263c502",
    "name":"P1003",
    "group_id":"e4df0e63-d584-4d07-94c3-55e5bb00fadc",
    "hardware_id":7,
    "latitude":32.900542,
    "longitude":-117.208181,
    "is_deleted":false,
    "extra":"{"Address":"3 Main Street", "ConvenienceFee":"0.35", "MaxSecond":"7200", "MinSecond":"900", "Rate":"0.5", "Increment":"1800", "FreeHourBegin":"23:00", "FreeHourEnd":"5:00"}",
    "is_active":true
}]

Back To Top

GetGeofenceLocationUpdates

GET

The GET method can be used to get all geofence locations that need to be monitored since the last update.

Json key:
  • Location_type defines the type of location. (1= Radial, 2= Polygon, 3= Place)
  • Trigger_type defines the direction of event whether user enters or exits a region. (1 = Enter, 2= Exit)
  • Center defines the center coordinate of the region.
  • Radius defines the radius of the region from a center coordinate.
Request:
GET https https://rest.apsima.com/api/users/32aee5b7-6027-411a-a438-526b3e766fe5/geofences/updates?from=1970-01-01T00%3A00%3A00Z&first_load=true HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1OjBiNWZmYWQ0LWE5ODctNDA1Yi05ZWU5LWQyNDlkZjFjOGM0Zg==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone

Back To Top

ReportTimeInApp

POST

The POST method can be used to report how long (in seconds) the app has been opened.

Request:
POST https://rest.apsima.com/api/metrics/devices/4eb71d30-4309-4f64-8525-90b03b173f47/timeinapp HTTP/1.1
Authorization: Basic YWE1eXExN3p4Zjd5LXlxNTIweng6YzlkMGIzeGc1OGM4eGcyYzlmYWE=
Accept: application/vnd.apsima.api-1.0+json
Content-Type: application/json
Content-Length: 18
Host: 000.000.000.000
Connection: Keep-Alive
User-Agent: android-async-http/1.4.4 (http://loopj.com/android-async-http)
Cookie: ASP.NET_SessionId=rvcc23kad3hgv3qrdq1prw00
Cookie2: $Version=1
Accept-Encoding: gzip
Domain-Key: 1BA3A26D-3F89-46ED-9AC4-5B8345212B2B
User-Auth: MzJhZWU1YjctNjAyNy00MTFhLWE0MzgtNTI2YjNlNzY2ZmU1Ojg4ZTQ0YTg5LTFjMTctNGUwZC05MGQ3LTIyYjFhMjA3YzMwYg==
Accept: application/vnd.apsima.api-1.0+json
Device-Type: AndroidPhone
 
{
    "total_time":763
}
Response: