• darkblurbg

API Documentation

General Information

Note:

This page is meant for developers that want to program an API to connect their service with SlapLab! If you are a SlapLab user, please check our FAQ on more Information on how to actually use the API Interface!

Documentation:

This is the API Documentation for our Slaplab API Interface! To clarify: This is not the Documentation of an API that we provide. It is the Documentation of an API that you can build for your Service to Interface it with the Slaplab Apps Preset Database!

SlapLab does simple GET & POST HTTP calls on Port 80 or 443 if the user is using https://

Parameters will be sent according to the endpoints documentation with either POST or GET.

We expext your API to return valid UTF8 encoded JSON. We tried to make this documentation as easy to understand as possible, that is why we have included not only a formal documentation of the parameters and expected response, we have also included sample requests and responses, so it should be easy for you to figure out what our interface actually expects. We are currently woking on a developer mode in SlapLab, that will allow you to output the requests and reponses from your API, so you can figure out if and where you may have Problems!

Authentification

Documentation:

Authentification will be performed via a Token. You can provide your Users with an access token that they can use in our App to query your Services API!

Users can enter the API Token along with your API Url in our Apps Preset API Settings. This will unlock the UI Buttons for the Preset Database in our App

When Users use these Database Options the App will query your API according the the Endpoints specified below!

The Token will be transfered as an "Authentification" Header in the Bearer Style!

Sample:

Sample Header from SlapLab:
GET /v1/check HTTP/1.1
Host: your.api.url
User-Agent: Unity (SomeVersion)
Authentification: Bearer YOUR_TOKEN
...

Check Endpoint

Documentation:

The Check Endpoint is called when a User enters the API Credentials!

Parameters:

- none -

Response:
  • status/error: A Status or Error Object Containing a Code and a Message
Status/Error Codes:
  • 0: Check succeded and API Response is correct!
  • -1: No Endpoint given (http://url/v1/)!
  • 100: Invalid API Call (Meaning the Endpoint does not exist)
  • 948: Missing API Token!
  • 20: Invalid API Token!

Sample:

Sample Reqeust from SlapLab:
GET http://your.api.url/v1/check
Sample Response from your API on success:
{
	"status":
	{
		"code":0,
		"message":"OK"
	}
}
Sample Response from your API on failure:
{
	"error":
	{
		"code":ERROR_CODE,
		"message":"Invalid API Key"
	}
}

Categories Endpoint

Documentation:

The Categories Endpoint should return a list of Categories. But only if the requested Type has at least one Item in this Category, to avoid empty Categories!

Parameters:
  • type: The Type of Item SlapLab currently reqeusts (Can be: 'Rule','Regulation','Toy','Position','Action')
Total Response:
  • data: An Array of Categories (See below)!
Category Item:
  • id: The ID of the Category. It is used with the "cat" Attribute of Lists to filter Category Items!
  • name: The Name of the Category (This cannot be empty!)
Notes:

This Endpoint is NOT Paginated and will always return all Options. For ease of access the returned List should also be sorted by Name!

Sample:

Sample Reqeust from SlapLab:
GET http://your.api.url/v1/categories?type=Toy
Sample Response from your API:
{
	"data":
	[
		{
			"id": "24",
			"name": "Category1"
		},
		{
			"id": "14",
			"name": "Category2"
		},
		{
			"id": "49",
			"name": "Category3"
		},
		{
			"id": "6",
			"name": "Category6"
		}
	]
}

Import Endpoint

Documentation:

The Import Endpoint is used to upload new Items from our App into your Database. You should implement a basic review process into your Service!

Parameters:
  • type: The Type of Item SlapLab is currently trying to send (Can be: 'Rule','Regulation','Toy','Position','Action')
  • name: The Name of the Item to be inserted
  • image: The actual Image as a File. This Endpoint is requested as POST as "multipart/form-data". (Can be empty! You should do some basic sanity checks for the Image to make your API Secure!)
  • description: The Description of the Item (Can be an empty String)
  • karma: (Optional) The Karma of the Item to be inserted (This is not set if the Item has no Karma)
  • goodkarma: (Optional) The Good Karma of the Item to be inserted (This is not set if the Item has no Good Karma)
  • badkarma: (Optional) The Bad Karma of the Item to be inserted (This is not set if the Item has no BadKarma)
  • actiontype: (Optional) The ActionType of the Item to be inserted (This is not set if the Item has no ActionType. If it it set it can be one of the following Values: 'None','Times','Seconds','Minutes','Hours','Days')
  • actioncount: (Optional) The Actioncount of the Item to be inserted (This is not set if the Item has no ActionCount)
Response:
  • status/error: A Status or Error Object Containing a Code and a Message (See Check Endpoint for Error-Codes)

Sample:

Sample Reqeust from SlapLab:
POST http://your.api.url/v1/import
form.AddField("type", context.type);
form.AddField("name", context.Name);
form.AddField("description", context.Description);
if (this.context is Action)
{
	form.AddField("actioncount", (context as Action).Value);
	form.AddField("actiontype", (context as Action).Type.ToString());
	form.AddField("karma", (context as Action).Karma);
}
if(this.context is Rule)
{
	form.AddField("actioncount", (context as Rule).Value);
	form.AddField("actiontype", (context as Rule).Type.ToString());
	form.AddField("goodkarma", (context as Rule).GoodKarma);
	form.AddField("badkarma", (context as Rule).BadKarma);
}
if(this.context is Regulation)
{
	form.AddField("karma", (context as Regulation).Karma);
}
if (includeImage)
{
	form.AddBinaryData("image",imgdata);
}
Sample Response from your API:
{
	"status":
	{
		"code":0,
		"message":"OK"
	}
}

Search Endpoint

Documentation:

The Search Endpoint should return a list of items that contain a specific search phrase!

Parameters:
  • type: The Type of Item SlapLab currently reqeusts (Can be: 'Rule','Regulation','Toy','Position','Action')
  • q: The search query. Returned Items should contain this search query!
  • cat: (Optional) We supply a "cat" Attribute, if the user filters by a category ID!
  • p: Used for Pagination. p=20, means start at Item 21! You can return as many Items per Page as you like, but do not overdo it!
Total Response:
  • data: An Array of Items (See below)!
  • hasNext: If this Endpoint has more Items yet (Boolean Value)
Single Item:
  • id: The ID of the Item. It is used with the /item Endpoint to actually get the Details of the Item!
  • name: The Name of the Item (This cannot be empty!)
  • description: The Description of the Item (This can be empty but has to be limited to 128 Characters!)
  • image: The URL to the Image of this Item (Cannot be empty)
  • thumbnail: The URL to the Thumbnail of this Item (Cannot be empty and should be smaller than 10kb)

Sample:

Sample Reqeust from SlapLab:
GET http://your.api.url/v1/search?type=Toy&p=5%q=Name
Sample Response from your API:
{
	"data":
	[
		{
			"id": 20,
			"name": "Some Name",
			"description": "Some Desc",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		},
		{
			"id": 103,
			"name": "Some Name#2",
			"description": "Some Desc",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		},
		{
			"id": 56,
			"name": "Some Name#4",
			"description": "",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		}
	],
	"hasNext": false
}

New Endpoint

Documentation:

The New Endpoint should return a list of items that were recently added (This is the Default Endpoint in our App)!

Parameters:
  • type: The Type of Item SlapLab currently reqeusts (Can be: 'Rule','Regulation','Toy','Position','Action')
  • cat: (Optional) We supply a "cat" Attribute, if the user filters by a category ID!
  • p: Used for Pagination. p=20, means start at Item 21! You can return as many Items per Page as you like, but do not overdo it!
Total Response:
  • data: An Array of Items (See below)!
  • hasNext: If this Endpoint has more Items yet (Boolean Value)
Single Item:
  • id: The ID of the Item. It is used with the /item Endpoint to actually get the Details of the Item!
  • name: The Name of the Item (This cannot be empty!)
  • description: The Description of the Item (This can be empty but has to be limited to 128 Characters!)
  • image: The URL to the Image of this Item (Cannot be empty)
  • thumbnail: The URL to the Thumbnail of this Item (Cannot be empty and should be smaller than 10kb)

Sample:

Sample Reqeust from SlapLab:
GET http://your.api.url/v1/new?type=Toy&p=40
Sample Response from your API:
{
	"data":
	[
		{
			"id": 20,
			"name": "Some Name",
			"description": "Some Desc",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		},
		{
			"id": 103,
			"name": "Some Name#2",
			"description": "Some Desc",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		},
		{
			"id": 56,
			"name": "Some Name#4",
			"description": "",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		}
	],
	"hasNext": false
}

Popular Endpoint

Documentation:

The Popular Endpoint should return a list of items that were most popular (We do not specify how you should Filter these, you can implement your own sorting algorithms)!

Parameters:
  • type: The Type of Item SlapLab currently reqeusts (Can be: 'Rule','Regulation','Toy','Position','Action')
  • cat: (Optional) We supply a "cat" Attribute, if the user filters by a category ID!
  • p: Used for Pagination. p=20, means start at Item 21! You can return as many Items per Page as you like, but do not overdo it!
Total Response:
  • data: An Array of Items (See below)!
  • hasNext: If this Endpoint has more Items yet (Boolean Value)
Single Item:
  • id: The ID of the Item. It is used with the /item Endpoint to actually get the Details of the Item!
  • name: The Name of the Item (This cannot be empty!)
  • description: The Description of the Item (This can be empty but has to be limited to 128 Characters!)
  • image: The URL to the Image of this Item (Cannot be empty)
  • thumbnail: The URL to the Thumbnail of this Item (Cannot be empty and should be smaller than 10kb)

Sample:

Sample Reqeust from SlapLab:
GET http://your.api.url/v1/popular?type=Toy&p=40
Sample Response from your API:
{
	"data":
	[
		{
			"id": 20,
			"name": "Some Name",
			"description": "Some Desc",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		},
		{
			"id": 103,
			"name": "Some Name#2",
			"description": "Some Desc",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		},
		{
			"id": 56,
			"name": "Some Name#4",
			"description": "",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		}
	],
	"hasNext": false
}

Most Views Endpoint

Documentation:

The Most Views Endpoint should return a list of items that were most viewed (We do not specify how you should Filter these, you can implement your own sorting algorithms)!

Parameters:
  • type: The Type of Item SlapLab currently reqeusts (Can be: 'Rule','Regulation','Toy','Position','Action')
  • cat: (Optional) We supply a "cat" Attribute, if the user filters by a category ID!
  • p: Used for Pagination. p=20, means start at Item 21! You can return as many Items per Page as you like, but do not overdo it!
Total Response:
  • data: An Array of Items (See below)!
  • hasNext: If this Endpoint has more Items yet (Boolean Value)
Single Item:
  • id: The ID of the Item. It is used with the /item Endpoint to actually get the Details of the Item!
  • name: The Name of the Item (This cannot be empty!)
  • description: The Description of the Item (This can be empty but has to be limited to 128 Characters!)
  • image: The URL to the Image of this Item (Cannot be empty)
  • thumbnail: The URL to the Thumbnail of this Item (Cannot be empty and should be smaller than 10kb)

Sample:

Sample Reqeust from SlapLab:
GET http://your.api.url/v1/mostviews?type=Toy&p=40
Sample Response from your API:
{
	"data":
	[
		{
			"id": 20,
			"name": "Some Name",
			"description": "Some Desc",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		},
		{
			"id": 103,
			"name": "Some Name#2",
			"description": "Some Desc",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		},
		{
			"id": 56,
			"name": "Some Name#4",
			"description": "",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		}
	],
	"hasNext": false
}

Most Downloads Endpoint

Documentation:

The Most Downloads Endpoint should return a list of items that were most downloaded (We do not specify how you should Filter these, you can implement your own sorting algorithms)!

Parameters:
  • type: The Type of Item SlapLab currently reqeusts (Can be: 'Rule','Regulation','Toy','Position','Action')
  • cat: (Optional) We supply a "cat" Attribute, if the user filters by a category ID!
  • p: Used for Pagination. p=20, means start at Item 21! You can return as many Items per Page as you like, but do not overdo it!
Total Response:
  • data: An Array of Items (See below)!
  • hasNext: If this Endpoint has more Items yet (Boolean Value)
Single Item:
  • id: The ID of the Item. It is used with the /item Endpoint to actually get the Details of the Item!
  • name: The Name of the Item (This cannot be empty!)
  • description: The Description of the Item (This can be empty but has to be limited to 128 Characters!)
  • image: The URL to the Image of this Item (Cannot be empty)
  • thumbnail: The URL to the Thumbnail of this Item (Cannot be empty and should be smaller than 10kb)

Sample:

Sample Reqeust from SlapLab:
GET http://your.api.url/v1/mostdownloads?type=Toy&p=40
Sample Response from your API:
{
	"data":
	[
		{
			"id": 20,
			"name": "Some Name",
			"description": "Some Desc",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		},
		{
			"id": 103,
			"name": "Some Name#2",
			"description": "Some Desc",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		},
		{
			"id": 56,
			"name": "Some Name#4",
			"description": "",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		}
	],
	"hasNext": false
}

Featured Endpoint

Documentation:

The Featured Endpoint should return a list of items that you want to appear as featured (We do not specify how you should Filter these, you can implement your own sorting algorithms)!

Parameters:
  • type: The Type of Item SlapLab currently reqeusts (Can be: 'Rule','Regulation','Toy','Position','Action')
  • cat: (Optional) We supply a "cat" Attribute, if the user filters by a category ID!
  • p: Used for Pagination. p=20, means start at Item 21! You can return as many Items per Page as you like, but do not overdo it!
Total Response:
  • data: An Array of Items (See below)!
  • hasNext: If this Endpoint has more Items yet (Boolean Value)
Single Item:
  • id: The ID of the Item. It is used with the /item Endpoint to actually get the Details of the Item!
  • name: The Name of the Item (This cannot be empty!)
  • description: The Description of the Item (This can be empty but has to be limited to 128 Characters!)
  • image: The URL to the Image of this Item (Cannot be empty)
  • thumbnail: The URL to the Thumbnail of this Item (Cannot be empty and should be smaller than 10kb)

Sample:

Sample Reqeust from SlapLab:
GET http://your.api.url/v1/featured?type=Toy&p=40
Sample Response from your API:
{
	"data":
	[
		{
			"id": 20,
			"name": "Some Name",
			"description": "Some Desc",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		},
		{
			"id": 103,
			"name": "Some Name#2",
			"description": "Some Desc",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		},
		{
			"id": 56,
			"name": "Some Name#4",
			"description": "",
			"image": "http://some/img/url.jpg",
			"thumbnail": "http://some/img/url.jpg"
		}
	],
	"hasNext": false
}

Item Endpoint

Documentation:

The Item Endpoint should return Detailed Infos about a single Item!

Parameters:
  • id: The ID of the Item that your response should contain
Response:
  • id: The ID of the Item we reqeusted
  • name: The Name of the Item
  • description: The full Description of the Item
  • image: An URL to the Image of this Item (Cannot be empty!)
  • thumbnail: The URL to the Thumbnail (Cannot be empty and should not exceed 10kb!)
  • karma: The Karma Value of the Item (Can be INT or null) [Only for Actions & Regulations]
  • goodkarma: The Good Karma Value of the Item (Can be INT or null) [Only for Rules]
  • badkarma: The Bad Karma Value of the Item (Can be INT or null) [Only for Rules]
  • actiontype: The Actiontype of this Item (Can be: null, "None", "Times", "Seconds", "Minutes", "Hours" or "Days") [Only for Actions & Rules]
  • actioncount: The Actioncount of this Item (Can be INT or null) [Only for Actions & Rules]

Sample:

Sample Reqeust from SlapLab:
GET http://your.api.url/v1/item?id=40
Sample Response from your API:
{
	"id": 40,
	"name": "Name of your Item",
	"description": "Some Description",
	"image": "http://url.to/your.image.jpg",
	"thumbnail": "http://url.to/your.thumb.jpg",
	"karma": 0,
	"goodkarma": 0,
	"badkarma": 0,
	"actiontype": null,
	"actioncount": 0
}