Permalink
Fetching contributors…
Cannot retrieve contributors at this time
3167 lines (2749 sloc) 90 KB
<br><br>
<h2 id="api-type-overview">Overview</a></h2>
<p>
A type describes the structure of a device. In its simplest form every type can be defined
as the combination of three key elements.
</p>
<ul>
<li>Properties (what vary during time)</li>
<li>Functions (what a device can do)</li>
<li>Statuses (what a device is in a specific time of its life)</li>
</ul>
<p>
Follow a sample type structure for a basic light.
</p>
<table class="table table-stripped table-hover">
<tbody>
<tr><td>Properties</td><td>status, intensity</td></tr>
<tr><td>Functions</td><td>turn on, turn off, set intensity</td></tr>
<tr><td>Statuses</td><td>on, off, turning on, turning off, setting intensity</td></tr>
</tbody>
</table>
<h3 id="types-api-learn">Do I need to learn the Type API?</h3>
<p>
No, you don't. The <a href="http://lelylan.github.io/types-dashboard-ng/#/">Types Dashboard</a> gives you everything you need to create new and browse existing types. This is all you need to get started. But if you want to fully understand how a type is structured and how to use the Type API, this is the right place where to start.
</p>
<hr>
<h2 id="api-type-types">Types</h2>
<hr>
<h2 id="get-a-type">GET /types/:id</h2>
<p>
Returns extended information for a given <a href="/api#core-concepts-public-resources">public</a>
type identified from its ID.
</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>GET http://api.lelylan.com/types/:id</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>id</span>
<span class="info">required</span>
</td>
<td>
The ID of the desired type.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#get-a-type-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#get-a-type-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#get-a-type-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#get-a-type-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#get-a-type-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="get-a-type-curl">
<div class="preview">
<pre><xmp>curl http://api.lelylan.com/types/<id></xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-a-type-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')();
Lelylan.Type.find('<id>', callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-a-type-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">{{type}}</div>
<script>
function LelylanController($scope, Type) {
Type.find('<ID>').success(function(response) { $scope.type = response })
}
</script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-a-type-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new
type = lelylan.type('<id>')</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-a-type-python">
<div class="preview">
<pre class="prettyprint"><xmp>from lelylan import types
type = types.get_type('<id>')</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3 id="type-representation">Example body response</h3>
<div class="code-block"><pre><code>{
"id": "5042234270eda61200000006",
"uri": "http://api.lelylan.com/types/5042234270eda61200000006",
"name": "Connected Light",
"description": "Define a *basic* light structure",
"owner": {
"id": "5036227a4f1b030200000001",
"uri": "http://api.lelylan.com/people/5036227a4f1b030200000001"
},
"created_at": "2012-09-01T15:01:22Z",
"updated_at": "2012-09-01T15:01:22Z",
"categories": ["lights"],
"properties": [{
"name": "Status",
"id": "50420c3a267ff51300000001",
"uri": "http://api.lelylan.com/properties/50420c3a267ff51300000001",
"type": "text",
"default": "off",
"accepted": [
{ "key": "on", "value": "On" },
{ "key": "off", "value": "Off" }
]
}, {
"name": "Intensity",
"id": "518be8b100045e99cc000004",
"uri": "http://api.lelylan.com/properties/518be8b100045e99cc000004",
"type": "range",
"range": { "min": "0", "max": "100", "step": "1" }
"default": "50",
"accepted": null,
}],
"functions": [{
"name": "Turn on",
"id": "5042205c70eda61000000003",
"uri": "http://api.lelylan.com/functions/5042205c70eda61000000003",
"properties": [{
"id": "50420c3a267ff51300000001",
"uri": "http://api.lelylan.com/properties/50420c3a267ff51300000001",
"expected": "on",
"pending": true
}]
}, {
"name": "Turn off",
"uri": "http://api.lelylan.com/functions/5042209370eda61000000004",
"id": "5042209370eda61000000004",
"properties": [{
"id": "50420c3a267ff51300000001",
"uri": "http://api.lelylan.com/properties/50420c3a267ff51300000001",
"expected": "off",
"pending": true
}]
}, {
"name": "Set intensity",
"uri": "http://api.lelylan.com/functions/504220c470eda60d00000005",
"id": "504220c470eda60d00000005",
"properties": [{
"uri": "http://api.lelylan.com/properties/518be8b100045e99cc000004",
"id": "518be8b100045e99cc000004",
"expected": null,
"pending": true
}]
}],
"statuses": [{
"name": "Light is On",
"id": "518bea2500045e99cc000009",
"uri": "http://api.lelylan.com/statuses/518bea2500045e99cc000009",
"function": {
"id": "5042209370eda61000000004",
"uri": "http://api.lelylan.com/functions/5042209370eda61000000004"
},
"properties": [{
"id": "50420c3a267ff51300000001",
"uri": "http://api.lelylan.com/properties/50420c3a267ff51300000001",
"pending": false,
"values": ["on"],
"range": null
}],
}, {
"name": "Light is Off",
"id": "518bea3100045e99cc00000b",
"uri": "http://api.lelylan.com/statuses/518bea3100045e99cc00000b",
"function": {
"id": "5042205c70eda61000000003",
"uri": "http://api.lelylan.com/functions/5042205c70eda61000000003"
},
"properties": [{
"id": "50420c3a267ff51300000001",
"uri": "http://api.lelylan.com/properties/50420c3a267ff51300000001",
"pending": false,
"values": ["off"],
"range": null
}],
}]
}</code></pre></div>
<h3>Body Response explained</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td>uri</td>
<td>Type URI</td>
</tr>
<tr>
<td>id</td>
<td>Type ID</td>
</tr>
<tr>
<td>name</td>
<td>Type name</td>
</tr>
<tr>
<td>description</td>
<td>Type description</td>
</tr>
<tr>
<td>owner</td>
<td>Type creator</td>
</tr>
<tr>
<td>categories</td>
<td>List of type categories</td>
</tr>
<tr>
<td>properties</td>
<td>Learn more about <a href="#api-type-properties">properties</a></td>
</tr>
<tr>
<td>functions</td>
<td>Learn more about <a href="#api-type-functions">functions</a></td>
</tr>
<tr>
<td>statuses</td>
<td>Learn more about <a href="#api-type-statuses">statuses</a></td>
</tr>
</tbody>
</table>
<hr>
<h2 id="get-all-types">GET /types</h2>
<p>Returns a list of owned (and <a href="/api#core-concepts-public-resources">public</a>) types.</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code># owned types
GET http://api.lelylan.com/types
<hr>
# all types
GET http://api.lelylan.com/types/public</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>name</span>
<span class="info">optional</span>
</td>
<td>
Type name to search.
</td>
</tr>
<tr>
<td class="parameter">
<span>start</span>
<span class="info">optional</span>
</td>
<td>
ID of the last fetched record.
Learn more about <a href="/api#core-concepts-infinite-scrolling-pagination">pagination</a>.
</td>
</tr>
<tr>
<td class="parameter">
<span>per</span>
<span class="info">optional</span>
<span class="info">default to '25'</span>
</td>
<td>
Number of resources per page.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#get-all-types-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#get-all-types-node" data-toggle="tab" class="node"> Node.js</a></li>
<li><a href="#get-all-types-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#get-all-types-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#get-all-types-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="get-all-types-curl">
<div class="preview"><pre><xmp>curl http://api.lelylan.com/types \
-H 'Authorization: Bearer <token>'</xmp></pre></div>
</div>
<div class="tab-pane" id="get-all-types-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')({ token: token });
Lelylan.Type.all({}, callback); // owned resources
var Lelylan = require('lelylan-node')();
Lelylan.Type.public({}, callback); // all existing resources</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-types-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">
<div ng-repeat="type in owned">{{type}}</div>
<div ng-repeat="type in public">{{type}}</div>
</div>
<script>
function LelylanController($scope, Type) {
Type.all({ name: 'light' }).success(function(response) { $scope.owned = response })
Type.public({ name: 'light' }).success(function(response) { $scope.public = response })
}
</script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-types-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new(token: token)
types = lelylan.types # owned resources
lelylan = Lelylan::Client.new
types = lelylan.public_types # all existing resources</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-types-python">
<div class="preview">
<pre class="prettyprint"><xmp>oauth.set_access_token()
from lelylan import types
types = types.get_owned_type() # owned resources
from lelylan import types
types = types.get_all_type() # all existing resources</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3>Example body response</h3>
<div class="code-block"><pre><code>[
{
"uri": "http://api.lelylan.com/types/5042223470eda60d00000005",
"id": "5042223470eda60d00000005",
"name": "Light",
"categories": ["lights"],
"created_at": "2012-09-01T14:56:52Z",
"updated_at": "2012-09-01T14:56:52Z"
}, {
"uri": "http://api.lelylan.com/types/5042229270eda61200000005",
"id": "5042229270eda61200000005",
"name": "Basic Light",
"categories": ["lights"],
"created_at": "2012-09-01T14:58:26Z",
"updated_at": "2012-09-01T14:58:26Z"
}, ...
]</code></pre></div>
<div class="alert alert-info">
<p>
<span class="label label-lelylan">notice</span>
Due to the type complex structure when you get a list of types each of them is returned with
a simplified JSON representation. Having the name, the ID and the category will be more than
enough.
</p>
</div>
<hr>
<h2 id="create-a-type">POST /types</h2>
<p>
Create a type and returns extended information for it.
</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>POST http://api.lelylan.com/types</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>name</span>
<span class="info">required</span>
</td>
<td>
Type name.
</td>
</tr>
</tr>
<tr>
<td class="parameter">
<span>description</span>
<span class="info">optional</span>
</td>
<td>
Type description.
</td>
</tr>
<tr>
<td class="parameter">
<span>categories</span>
<span class="info">optional</span>
</td>
<td>
List of categories.
</td>
</tr>
<tr>
<td class="parameter">
<span>properties</span>
<span class="info">optional</span>
</td>
<td>
List of property IDs.
</td>
</tr>
<tr>
<td class="parameter">
<span>functions</span>
<span class="info">optional</span>
</td>
<td>
List of function IDs.
</td>
</tr>
<tr>
<td class="parameter">
<span>statuses</span>
<span class="info">optional</span>
</td>
<td>
List of status IDs.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#create-a-type-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#create-a-type-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#create-a-type-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#create-a-type-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#create-a-type-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="create-a-type-curl">
<div class="preview">
<pre><xmp>curl -X POST http://api.lelylan.com/types \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{
"name": "Light",
"categories": ["lights"],
"properties": [ "<status>", "<intensity>" ],
"functions": [ "<turn-on>", "<turn-off>", "<set-intensity>" ],
"statuses": [ "<light-on>", "<light-off>" ]
}'</xmp></pre>
</div>
</div>
<div class="tab-pane" id="create-a-type-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')({ token: token });
var params = {
name: 'Light',
categories: [ 'lights' ],
properties: [ '<status>', '<intensity>' ],
functions: [ '<turn-on>', '<turn-off>', '<set-intensity>' ],
statuses: [ '<light-on>', '<light-off>' ] };
Lelylan.Type.create(params, callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="create-a-type-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">{{type}}</div>
<script>
function LelylanController($scope, Type) {
var params = {
name: 'Light',
categories: [ 'light' ],
properties: [ '<status-id>', '<intensity-id>' ],
functions: [ '<turn-on-id>', '<turn-off-id>', '<set-intensity-id>' ],
statuses: [ '<light-on-id>', '<light-off-id>' ] };
Type.create(params).success(function(response) { $scope.type = response })
}
</script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="create-a-type-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new(token: token)
params = {
name: 'Light',
categories: [ 'lights' ],
properties: [ '<status-id>', '<intensity-id>' ],
functions: [ '<turn-on-id>', '<turn-off-id>', '<set-intensity-id>' ],
statuses: [ '<light-on-id>', '<light-off-id>' ] };
type = lelylan.create_type(params)</xmp></pre>
</div>
</div>
<div class="tab-pane" id="create-a-type-python">
<div class="preview">
<pre class="prettyprint"><xmp>oauth.set_access_token()
params = {
name: 'Light',
categories: [ 'lights' ],
properties: [ '<status>', '<intensity>' ],
functions: [ '<turn-on>', '<turn-off>', '<set-intensity>' ],
statuses: [ '<light-on>', '<light-off>' ] };
from lelylan import types
type = types.create_type(params)</xmp></pre>
</div>
</div>
</div>
<br>
<div class="alert alert-info">
<p>
<span class="label label-lelylan">notice</span>
In this example the resource IDs are replaced from friendly names.
</p>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 201 Created
Location: http://api.lelylan.com/types/5042234270eda61200000006</code></pre></div>
<h3>Example body response</h3>
<p>
See <a href="#type-representation">type representation</a> for body response.
</p>
<hr>
<h2 id="update-a-type">PUT /types/:id</h2>
<p>
Update a type identified from its ID and returns extended information for it.
</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>PUT http://api.lelylan.com/types/:id</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>id</span>
<span class="info">required</span>
</td>
<td>
The ID of the desired type.
</td>
</tr>
<tr>
<td class="parameter">
<span>name</span>
<span class="info">optional</span>
</td>
<td>
Type name.
</td>
</tr>
<tr>
<td class="parameter">
<span>description</span>
<span class="info">optional</span>
</td>
<td>
Type description.
</td>
</tr>
<tr>
<td class="parameter">
<span>categories</span>
<span class="info">optional</span>
</td>
<td>
List of categories.
</td>
</tr>
<tr>
<td class="parameter">
<span>properties</span>
<span class="info">optional</span>
</td>
<td>
List of property IDs.
</td>
</tr>
<tr>
<td class="parameter">
<span>functions</span>
<span class="info">optional</span>
</td>
<td>
List of function IDs.
</td>
</tr>
<tr>
<td class="parameter">
<span>statuses</span>
<span class="info">optional</span>
</td>
<td>
List of status IDs.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#update-a-type-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#update-a-type-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#update-a-type-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#update-a-type-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#update-a-type-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="update-a-type-curl">
<div class="preview"><pre><xmp>curl -X PUT http://api.lelylan.com/types/<id> \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{ "name": "RBG Light" }'</xmp></pre>
</div>
</div>
<div class="tab-pane" id="update-a-type-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')({ token: token });
var params = { name: 'RBG Light' };
Lelylan.Type.update('<id>', params, callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="update-a-type-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">{{type}}</div>
<script>
function LelylanController($scope, Type) {
var params = { name: 'RBG Light' };
Type.update('<ID>', params).success(function(response) { $scope.type = response })
}
</script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="update-a-type-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new(token: token)
params = { name: 'RBG Light' }
type = lelylan.update_type('<id>', params)</xmp></pre>
</div>
</div>
<div class="tab-pane" id="update-a-type-python">
<div class="preview">
<pre class="prettyprint"><xmp>oauth.set_access_token()
params = { name: 'RBG Light' }
from lelylan import types
type = types.update_type('<id>', params)</xmp></pre>
</div>
</div>
</div>
<br>
<div class="alert alert-info">
<p>
<span class="label label-lelylan">notice</span>
When updating a type connection (e.g. properties)
all previous connected resources are replaced.
</p>
</div>
</p>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3>Example body response</h3>
<p>
See <a href="#type-representation">type representation</a> for body response.
</p>
<hr>
<h2 id="delete-a-type">DELETE /types/:id</h2>
<p>
Delete a type identified from its ID and returns extended information for it.
All connected resources (e.g. properties, functions and statuses) are not deleted.
</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>DELETE http://api.lelylan.com/types/:id</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>id</span>
<span class="info">required</span>
</td>
<td>
The ID of the desired type.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#delete-a-type-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#delete-a-type-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#delete-a-type-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#delete-a-type-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#delete-a-type-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="delete-a-type-curl">
<div class="preview"><pre><xmp>curl -X DELETE http://api.lelylan.com/types/<id> \
-H 'Authorization: Bearer <token>'</xmp></pre>
</div>
</div>
<div class="tab-pane" id="delete-a-type-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')({ token: token });
Lelylan.Type.delete('<id>', callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="delete-a-type-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">{{type}}</div>
<script>
function LelylanController($scope, Type) {
Type.delete('<ID>').success(function(response) { $scope.type = response })
}
</script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="delete-a-type-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new(token: token)
type = lelylan.delete_type('<id>')</xmp></pre>
</div>
</div>
<div class="tab-pane" id="delete-a-type-python">
<div class="preview">
<pre class="prettyprint"><xmp>oauth.set_access_token()
from lelylan import types
type = types.delete_type('<id>')</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3>Example body response</h3>
<p>
See <a href="#type-representation">type representation</a> for body response.
</p>
<hr>
<h2 id="get-all-categories">GET /categories</h2>
<p>
Returns a list of common categories to associate to your types.
</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>GET http://api.lelylan.com/categories</code></pre>
</div>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#get-all-categories-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#get-all-categories-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#get-all-categories-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#get-all-categories-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#get-all-categories-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="get-all-categories-curl">
<div class="preview">
<pre><xmp>curl http://api.lelylan.com/categories</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-categories-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')();
Lelylan.Category.all({}, callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-categories-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">
<div ng-repeat="category in categories">{{category}}</div>
</div>
<script>
function LelylanController($scope, Category) {
Category.all().success(function(response) { $scope.categories = response });
}
</script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-categories-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new
categories = lelylan.categories</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-categories-python">
<div class="preview">
<pre class="prettyprint"><xmp>from lelylan import types
categories = types.get_type_cat()</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3>Example body response</h3>
<div class="code-block"><pre><code>[
{ "name": "lights" },
{ "name": "locks" },
{ "name": "thermostats" },
...
]</code></pre></div>
<hr>
<h2 id="api-type-properties">Property API</a></h2>
<p>
A property is whatever vary in a device during time. It can be the intensity in
a dimmer, the temperature in a cooling system or the speed in a car.
</p>
<hr>
<h2 id="get-a-property">GET /properties/:id</h2>
<p>Returns extended information for a given <a href="/api#core-concepts-public-resources">public</a> property identified from its ID.</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>GET http://api.lelylan.com/properties/:id</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>id</span>
<span class="info">required</span>
</td>
<td>
The ID of the desired property.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#get-a-property-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#get-a-property-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#get-a-property-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#get-a-property-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#get-a-property-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="get-a-property-curl">
<div class="preview">
<pre><xmp>curl http://api.lelylan.com/properties/<id></xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-a-property-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')();
Lelylan.Property.find('<id>', callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-a-property-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">{{property}}</div>
<script>
function LelylanController($scope, Property) {
Property.find('<ID>').success(function(response) { $scope.property = response });
}
</script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-a-property-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new
property = lelylan.property('<id>')</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-a-property-python">
<div class="preview">
<pre class="prettyprint"><xmp>from lelylan import properties
property = properties.get_prop('<id>')</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3 id="property-representation">Example body response</h3>
<p>Light status accepting text values on and off</p>
<div class="code-block"><pre><code>{
"name": "Status",
"id": "50420c3a267ff51300000001",
"uri": "http://api.lelylan.com/properties/50420c3a267ff51300000001",
"type": "text",
"default": "0",
"accepted": [{ "key": "on", "value": "On" }, { "key": "off", "value": "Off" }],
"created_at": "2012-09-01T10:56:41Z",
"updated_at": "2012-09-01T10:56:41Z"
}</code></pre></div>
<p>Light intensity accepting any value between the range that goes from 0 to 100 with step 1</p>
<div class="code-block"><pre><code>{
"name": "Intensity",
"id": "518be8b100045e99cc000004",
"uri": "http://api.lelylan.com/properties/518be8b100045e99cc000004",
"type": "range",
"range": { "min": "0", "max": "100", "step": "1" }
"default": "50",
"accepted": null,
"created_at": "2012-09-01T10:56:41Z",
"updated_at": "2012-09-01T10:56:41Z"
}</code></pre></div>
<h3>Body Response explained</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td>uri</td>
<td>Type URI</td>
</tr>
<tr>
<td>id</td>
<td>Type ID</td>
</tr>
<tr>
<td>name</td>
<td>Type name</td>
</tr>
<tr>
<td>type</td>
<td>Property type</td>
</tr>
<tr>
<td>range</td>
<td>Accepted range values. Visible only when type has <code>range</code> as value</td>
</tr>
<tr>
<td>default</td>
<td>Default property value assigned to the property when the device is created</td>
</tr>
<tr>
<td>accepted</td>
<td>List of accepted values from the property.
<a href="/support#faq-accepted-values">Learn more about</a></td>
</tr>
</tbody>
</table>
<hr>
<h2 id="get-all-properties">GET /properties</h2>
<p>Returns a list of owned (and <a href="/api#core-concepts-public-resources">public</a>) properties.</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code># created properties
GET http://api.lelylan.com/properties
<hr>
# all properties
GET http://api.lelylan.com/properties/public</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>name</span>
<span class="info">optional</span>
</td>
<td>
Property name to search.
</td>
</tr>
<tr>
<td class="parameter">
<span>start</span>
<span class="info">optional</span>
</td>
<td>
ID of the last fetched record.
Learn more about <a href="/api#core-concepts-infinite-scrolling-pagination">pagination</a>.
</td>
</tr>
<tr>
<td class="parameter">
<span>per</span>
<span class="info">optional</span>
<span class="info">default to '25'</span>
</td>
<td>
Number of resources per page.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#get-all-properties-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#get-all-properties-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#get-all-properties-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#get-all-properties-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#get-all-properties-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="get-all-properties-curl">
<div class="preview"><pre><xmp>curl http://api.lelylan.com/properties \
-H 'Authorization: Bearer <token>'</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-properties-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')({ token: token });
Lelylan.Property.all({}, callback); // owned resources
var Lelylan = require('lelylan-node')();
Lelylan.Property.public({}, callback); // all existing resources</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-properties-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">
<div ng-repeat="property in owned">{{property}}</div>
<div ng-repeat="property in public">{{property}}</div>
</div>
<script>
function LelylanController($scope, Property) {
Property.all({ name: 'status' }).success(function(response) { $scope.owned = response });
Property.public({ name: 'status' }).success(function(response) { $scope.public = response });
}
</script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-properties-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new(token: token)
properties = lelylan.properties # owned resources
lelylan = Lelylan::Client.new
properties = lelylan.public_properties # all existing resources</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-properties-python">
<div class="preview">
<pre class="prettyprint"><xmp>oauth.set_access_token()
from lelylan import properties
properties = properties.get_created_prop() # owned resources
from lelylan import properties
properties = properties.get_all_prop() # all existing resources</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3>Example body response</h3>
<div class="code-block"><pre><code>[
{ # property representation },
{ # property representation },
...
]</code></pre></div>
<p>
See <a href="#property-representation">property representation</a> for body response.
</p>
<hr>
<h2 id="create-a-property">POST /properties</h2>
<p>
Create a property and returns extended information for it.
</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>POST http://api.lelylan.com/properties</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>name</span>
<span class="info">required</span>
</td>
<td>
Property name.
</td>
</tr>
<tr>
<td class="parameter">
<span>type</span>
<span class="info">optional</span>
<span class="info">default to 'text'</span>
</td>
<td>
Property type.
<span class="info">Valid values: text, number, range, color, password, date, time, datetime, url.</span>
</td>
</tr>
<tr>
<td class="parameter">
<span>range</span>
<span class="info">optional</span>
</td>
<td>
Object containing the <code>min</code>, <code>max</code> and <code>step </code> range values.<br/>
Usi it only when <code>type</code> is set to <code>range</code>.</dd>
</td>
</tr>
<tr>
<td class="parameter">
<span>default</span>
<span class="info">optional</span>
</td>
<td>
Default property value assigned to the device when created.
</td>
</tr>
<tr>
<td class="parameter">
<span>accepted</span>
<span class="info">optional</span>
</td>
<td>
List of accepted values. <a href="/support#faq-accepted-values">Learn more about</a>.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#create-a-property-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#create-a-property-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#create-a-property-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#create-a-property-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#create-a-property-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="create-a-property-curl">
<div class="preview">
<pre><xmp>curl -X POST http://api.lelylan.com/properties \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{
"name": "Intensity",
"default": "50",
"type": "range",
"range": {"min": "0", "max": "100", "step": "1"}
}'</xmp></pre>
</div>
</div>
<div class="tab-pane" id="create-a-property-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')({ token: token });
var params = {
name: 'Intensity',
default: '50',
type: 'range',
range: {'min': '0', 'max': '100', 'step': '1'} };
Lelylan.Property.create(params, callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="create-a-property-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">{{property}}</div>
<script>
function LelylanController($scope, Property) {
var params = {
name: 'Intensity',
default: '50',
type: 'range',
range: {'min': '0', 'max': '100', 'step': '1'} };
Property.create(params).success(function(response) { $scope.property = response })
}
</script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="create-a-property-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new(token: token)
var params = {
name: 'Intensity',
default: '50',
type: 'range',
range: {'min': '0', 'max': '100', 'step': '1'} };
property = lelylan.create_property(params)</xmp></pre>
</div>
</div>
<div class="tab-pane" id="create-a-property-python">
<div class="preview">
<pre class="prettyprint"><xmp>oauth.set_access_token()
var params = {
name: 'Intensity',
default: '50',
type: 'range',
range: {'min': '0', 'max': '100', 'step': '1'} };
from lelylan import properties
property = properties.create_prop(params)</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 201 Created
Location: http://api.lelylan.com/properties/5041e9e9230de31300000001</code></pre>
</div>
<h3>Example body response</h3>
<p>
See <a href="#property-representation">property representation</a> for body response.
</p>
<hr>
<h2 id="update-a-property">PUT /properties/:id</h2>
<p>
Update a property identified from its ID and returns extended information for it.
</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>PUT http://api.lelylan.com/properties/:id</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>id</span>
<span class="info">required</span>
</td>
<td>
The ID of the desired property.
</td>
</tr>
<tr>
<td class="parameter">
<span>name</span>
<span class="info">optional</span>
</td>
<td>
Property name.
</td>
</tr>
<tr>
<td class="parameter">
<span>type</span>
<span class="info">optional</span>
</td>
<td>
Property type.
<span class="info">Valid values: text, number, range, color, password, date, time, datetime, url.</span>
</td>
</tr>
<tr>
<td class="parameter">
<span>range</span>
<span class="info">required</span>
</td>
<td>
Object containing the <code>min</code>, <code>max</code> and <code>step </code> range values.<br/>
Usi it only when <code>type</code> is set to <code>range</code>.</dd>
</td>
</tr>
<tr>
<td class="parameter">
<span>default</span>
<span class="info">optional</span>
</td>
<td>
Default property value assigned to the device when created.
</td>
</tr>
<tr>
<td class="parameter">
<span>accepted</span>
<span class="info">optional</span>
</td>
<td>
List of accepted values. <a href="/support#faq-accepted-values">Learn more about</a>.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#update-a-property-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#update-a-property-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#update-a-property-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#update-a-property-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#update-a-property-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="update-a-property-curl">
<div class="preview"><pre><xmp>curl -X PUT http://api.lelylan.com/properties/<id> \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{ "default": "100" }'</xmp></pre>
</div>
</div>
<div class="tab-pane" id="update-a-property-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')({ token: token });
var params = { default: '100' };
Lelylan.Property.update('<id>', params, callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="update-a-property-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">{{property}}</div>
<script>
function LelylanController($scope, Property) {
var params = { default: '100' };
Property.update('<ID>', params).success(function(response) { $scope.property = response })
}
</script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="update-a-property-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new(token: token)
params = { default: '100' };
property = lelylan.update_property('<id>', params)</xmp></pre>
</div>
</div>
<div class="tab-pane" id="update-a-property-python">
<div class="preview">
<pre class="prettyprint"><xmp>oauth.set_access_token()
params = { default: '100' };
from lelylan import properties
property = properties.update_prop('<id>', params)</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3>Example body response</h3>
<p>
See <a href="#property-representation">property representation</a> for body response.
</p>
<hr>
<h2 id="delete-a-property">DELETE /properties/:id</h2>
<p>
Delete a property identified from its ID and returns extended information for it.
</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>DELETE http://api.lelylan.com/properties/:id</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>id</span>
<span class="info">required</span>
</td>
<td>
The ID of the desired property.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class=" active"><a href="#delete-a-property-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#delete-a-property-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#delete-a-property-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#delete-a-property-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#delete-a-property-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="delete-a-property-curl">
<div class="preview"><pre><xmp>curl -X DELETE http://api.lelylan.com/properties/<id> \
-H 'Authorization: Bearer <token>'</xmp></pre>
</div>
</div>
<div class="tab-pane" id="delete-a-property-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')({ token: token });
Lelylan.Property.delete('<id>', callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="delete-a-property-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">{{property}}</div>
<script>
function LelylanController($scope, Property) {
Property.delete('<ID>').success(function(response) { $scope.property = response })
}
</script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="delete-a-property-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new(token: token)
property = lelylan.delete_property('<id>')</xmp></pre>
</div>
</div>
<div class="tab-pane" id="delete-a-property-python">
<div class="preview">
<pre class="prettyprint"><xmp>oauth.set_access_token()
from lelylan import properties
property = properties.delete_prop('<id>')</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3>Example body response</h3>
<p>
See <a href="#property-representation">property representation</a> for body response.
</p>
<hr>
<h2 id="api-type-functions">Function API</h2>
<p>
A Function defines the daily interactions you have with the devices in your house, for example turning on a light, closing a door or raising the temperature of your thermostat. With functions you can control any device in the same way you do everyday.
</p>
<hr>
<h2 id="get-a-function">GET /functions/:id</h2>
<p>Returns extended information for a given <a href="/api#core-concepts-public-resources">public</a> function identified from its ID.</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>GET http://api.lelylan.com/functions/:id</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>id</span>
<span class="info">required</span>
</td>
<td>
The ID of the desired function.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#get-a-function-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#get-a-function-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#get-a-function-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#get-a-function-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#get-a-function-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="get-a-function-curl">
<div class="preview">
<pre><xmp>curl http://api.lelylan.com/functions/<id></xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-a-function-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')();
Lelylan.Function.find('<id>', callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-a-function-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">{{function}}</div>
<script>
function LelylanController($scope, Function) {
Function.find('<ID>').success(function(response) { $scope.function = response })
}
</script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular-resource.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular-cookies.min.js"></script>
<script src="//s.lelylan.com/angularjs/0.1.0/lelylan.min.js"/></script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-a-function-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new
function = lelylan.function('<id>')</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-a-function-python">
<div class="preview">
<pre class="prettyprint"><xmp>from lelylan import functions
function = functions.get_func('<id>')</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3 id="function-representation">Example body response</h3>
<div class="code-block"><pre><code>{
"uri": "http://api.lelylan.com/functions/504210df70eda60a00000003",
"id": "504210df70eda60a00000003",
"name": "Set intensity",
"created_at": "2012-09-01T13:42:55Z",
"updated_at": "2012-09-01T13:42:55Z",
"properties": [{
"id": "50420c7e267ff51000000001",
"uri": "http://api.lelylan.com/properties/50420c7e267ff51000000001",
"expected": "on"
"pending": "true"
}, {
"id": "50420c7e267ff51000000001",
"uri": "http://api.lelylan.com/properties/50420c3a267ff51300000001",
"expected": null
"pending": true
}]
}</code></pre></div>
<h3>Body response explained</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td>uri</td>
<td>Function URI</td>
</tr>
<tr>
<td>id</td>
<td>Function ID</td>
</tr>
<tr>
<td>name</td>
<td>Function name</td>
</tr>
<tr>
<td>properties</td>
<td>Function properties</td>
</tr>
<tr>
<td class="nested">
<span>&raquo; property.uri</span>
</td>
<td>Property URI</td>
</tr>
<tr>
<td class="nested">
<span>&raquo; property.id</span>
</td>
<td>Property ID</td>
</tr>
<tr>
<td class="nested">
<span>&raquo; property.expected</span>
</td>
<td>Expected property value.</td>
</tr>
<tr>
<td class="nested">
<span>&raquo; property.pending</span>
</td>
<td>Property pending status.</td>
</tr>
</tbody>
</table>
<hr>
<h2 id="get-all-functions">GET /functions</h2>
<p>Returns a list of owned (and <a href="/api#core-concepts-public-resources">public</a>) functions.</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code># created functions
GET http://api.lelylan.com/functions
<hr>
# all existing functions
GET http://api.lelylan.com/functions/public</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>name</span>
<span class="info">optional</span>
</td>
<td>
Property name to search.
</td>
</tr>
<tr>
<td class="parameter">
<span>start</span>
<span class="info">optional</span>
</td>
<td>
ID of the last fetched record. Learn more about <a href="/api#core-concepts-infinite-scrolling-pagination">pagination</a>.
</td>
</tr>
<tr>
<td class="parameter">
<span>per</span>
<span class="info">optional</span>
<span class="info">default to '25'</span>
</td>
<td>
Number of resources per page.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class=" active"><a href="#get-all-functions-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#get-all-functions-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#get-all-functions-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#get-all-functions-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#get-all-functions-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="get-all-funcitons-curl">
<div class="preview"><pre><xmp>curl http://api.lelylan.com/functions \
-H 'Authorization: Bearer <token>'</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-functions-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')({ token: token });
Lelylan.Function.all({}, callback); // owned resources
var Lelylan = require('lelylan-node')();
Lelylan.Function.public({}, callback); // all existing resources</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-functions-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">
<div ng-repeat="function in owned">{{function}}</div>
<div ng-repeat="function in public">{{function}}</div>
</div>
<script>
function LelylanController($scope, Function) {
Function.all({ name: 'turn' }).success(function(response) { $scope.owned = response })
Function.public({ name: 'turn' }).success(function(response) { $scope.public = response })
}
</script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular-resource.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular-cookies.min.js"></script>
<script src="//s.lelylan.com/angularjs/0.1.0/lelylan.min.js"/></script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-functions-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new(token: token)
functions = lelylan.functions # owned resources
lelylan = Lelylan::Client.new
functions = lelylan.public_functions # all existing resources</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-functions-python">
<div class="preview">
<pre class="prettyprint"><xmp>oauth.set_access_token()
from lelylan import functions
functions = functions.get_created_func() # owned resources
from lelylan import functions
functions = functions.get_all_func() # all existing resources</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3>Example body response</h3>
<div class="code-block highlight"><pre><code>[
{ # function representation },
{ # function representation },
...
]</code></pre></div>
<p>
See <a href="#function-representation">function representation</a> for body response.
</p>
<hr>
<h2 id="create-a-function">POST /functions</h2>
<p>
Create a function and returns extended information for it.
</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>POST http://api.lelylan.com/functions</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>name</span>
<span class="info">required</span>
</td>
<td>
Function name.
</td>
</tr>
<tr>
<td class="parameter">
<span>properties</span>
<span class="info">optional</span>
</td>
<td>
Array of properties.
</td>
</tr>
<tr>
<td class="parameter nested">
<span>&raquo; property.id</span>
<span class="info">required</span>
</td>
<td>
Property ID.
</td>
</tr>
<tr>
<td class="parameter nested">
<span>&raquo; property.expected</span>
<span class="info">optional</span>
</td>
<td>
Expected value assigned to the device property when the function is executed.
Don't set it (null) if the value needs to be fullfilled by the user.
<a href="/support#faq-value-expected-pending">Learn more about</a>.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#create-a-function-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#create-a-function-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#create-a-function-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#create-a-function-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#create-a-function-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="create-a-function-curl">
<div class="preview">
<pre><xmp>curl -X POST http://api.lelylan.com/functions \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{
"name": "Set intensity",
"properties": [
{ "id": "<status>", "expected": "on" },
{ "id": "<intensity>" }
]
}'</xmp></pre>
</div>
</div>
<div class="tab-pane" id="create-a-function-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')({ token: token });
var params = {
name: 'Set intensity',
properties:
[ { id: '<status>', expected: 'on'},
{ id: '<intensity>' } ] };
Lelylan.Function.create(params, callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="create-a-function-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">{{function}}</div>
<script>
function LelylanController($scope, Function) {
var params = {
name: 'Set intensity',
properties: [
{ id: '<status>', expected: 'on'},
{ id: '<intensity>' } ] };
Function.create(params).success(function(response) { $scope.function = response })
}
</script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular-resource.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular-cookies.min.js"></script>
<script src="//s.lelylan.com/angularjs/0.1.0/lelylan.min.js"/></script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="create-a-function-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new(token: token)
params = {
name: 'Set intensity',
properties:
[ { id: '<status>', expected: 'on'},
{ id: '<intensity>' } ] }
function = lelylan.create_function(params)</xmp></pre>
</div>
</div>
<div class="tab-pane" id="create-a-function-python">
<div class="preview">
<pre class="prettyprint"><xmp>oauth.set_access_token()
params = {
name: 'Set intensity',
properties:
[ { id: '<status>', expected: 'on'},
{ id: '<intensity>' } ] }
from lelylan import functions
function = functions.create_func(params)</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 201 Created
Location: http://api.lelylan.com/functions/504210df70eda60a00000003</code></pre>
</div>
<h3>Example body response</h3>
<p>
See <a href="#function-representation">function representation</a> for body response.
</p>
<hr>
<h2 id="update-a-function">PUT /functions/:id</h2>
<p>
Update a function identified from its ID and returns extended information for it.
</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>PUT http://api.lelylan.com/functions/:id</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>id</span>
<span class="info">required</span>
</td>
<td>
The ID of the desired function.
</td>
</tr>
<tr>
<td class="parameter">
<span>name</span>
<span class="info">optional</span>
</td>
<td>
Function name.
</td>
</tr>
<tr>
<td class="parameter">
<span>properties</span>
<span class="info">optional</span>
</td>
<td>
Array of properties.
</td>
</tr>
<tr>
<td class="parameter nested">
<span>&raquo; property.id</span>
<span class="info">required</span>
</td>
<td>
Property ID.
</td>
</tr>
<tr>
<td class="parameter nested">
<span>&raquo; property.expected</span>
<span class="info">optional</span>
</td>
<td>
Expected value assigned to the device property when the function is executed.
Set it to <code>null</code> if the value needs to be fullfilled by the user.
<a href="/support#faq-value-expected-pending">Learn more about</a>.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#update-a-function-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#update-a-function-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#update-a-function-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#update-a-function-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#update-a-function-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="update-a-function-curl">
<div class="preview"><pre><xmp>
curl -X PUT http://api.lelylan.com/functions/<id> \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{
"name": "Set intensity to 50%",
"properties": [
{ "id": "<status>", "expected": "on"},
{ "id": "<intensity>", "expected": "50" }
]
}'</xmp></pre>
</div>
</div>
<div class="tab-pane" id="update-a-function-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')({ token: token });
var params = {
name: 'Set intensity to 50%',
properties:
[ { id: '<status>', expected: 'on'},
{ id: '<intensity>', expected: '50' } ] };
Lelylan.Function.update('<id>', params, callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="update-a-function-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">{{function}}</div>
<script>
function LelylanController($scope, Function) {
var params = {
name: 'Set intensity to 50%',
properties:
[ { id: '<status>', expected: 'on'},
{ id: '<intensity>', expected: '50' } ] };
Function.update('<ID>', params).success(function(response) { $scope.function = response })
}
</script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular-resource.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular-cookies.min.js"></script>
<script src="//s.lelylan.com/angularjs/0.1.0/lelylan.min.js"/></script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="update-a-function-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new(token: token)
params = {
name: 'Set intensity to 50%',
properties:
[ { id: '<status>', expected: 'on'},
{ id: '<intensity>', expected: '50' } ] }
function = lelylan.update_function('<id>', params)</xmp></pre>
</div>
</div>
<div class="tab-pane" id="update-a-function-python">
<div class="preview">
<pre class="prettyprint"><xmp>oauth.set_access_token()
params = {
name: 'Set intensity to 50%',
properties:
[ { id: '<status>', expected: 'on'},
{ id: '<intensity>', expected: '50' } ] }
from lelylan import functions
function = functions.update_func('<id>', params)</xmp></pre>
</div>
</div>
</div>
<br>
<div class="alert alert-info">
<p>
<span class="label label-lelylan">notice</span>
When updating properties all previous connected properties are replaced.
</p>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3>Example body response</h3>
<p>
See <a href="#function-representation">function representation</a> for body response.
</p>
<hr>
<h2 id="delete-a-function">DELETE /functions/:id</h2>
<p>
Delete a function identified from its ID and returns extended information for it. </br>
Connected properties are not deleted.
</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>DELETE http://api.lelylan.com/functions/:id</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>id</span>
<span class="info">required</span>
</td>
<td>
The ID of the desired function.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#delete-a-function-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#delete-a-function-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#delete-a-function-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#delete-a-function-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#delete-a-function-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="delete-a-function-curl">
<div class="preview"><pre><xmp>curl -X DELETE http://api.lelylan.com/functions/<id> \
-H 'Authorization: Bearer <token>'</xmp></pre>
</div>
</div>
<div class="tab-pane" id="delete-a-function-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')({ token: token });
Lelylan.Function.delete('<id>', callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="delete-a-function-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">{{function}}</div>
<script>
function LelylanController($scope, Function) {
Function.delete('<ID>').success(function(response) { $scope.function = response })
}
</script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular-resource.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular-cookies.min.js"></script>
<script src="//s.lelylan.com/angularjs/0.1.0/lelylan.min.js"/></script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="delete-a-function-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new(token: token)
function = lelylan.delete_function('<id>')</xmp></pre>
</div>
</div>
<div class="tab-pane" id="delete-a-function-python">
<div class="preview">
<pre class="prettyprint"><xmp>oauth.set_access_token()
from lelylan import functions
function = functions.delete_func('<id>')</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3>Example body response</h3>
<p>
See <a href="#function-representation">function representation</a> for body response.
</p>
<hr>
<h2 id="api-type-statuses">Status API</h2>
<p>
Properties are not always enough to describe the status of a device. Think at a window for
example. It has the property aperture to 100 when open or 0 when closed. But what if the
roller shutter is opening? It is nether open or close. To have a complete control over the
device status in every specific moment of its life use the Status API.
</p>
<hr>
<h2 id="get-a-status">GET /statuses/:id</h2>
<p>Returns extended information for a given <a href="/api#core-concepts-public-resources">public</a> status identified from its ID.</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>GET http://api.lelylan.com/statuses/:id</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>id</span>
<span class="info">required</span>
</td>
<td>
The ID of the desired status.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#get-a-status-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#get-a-status-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#get-a-status-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#get-a-status-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#get-a-status-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="get-a-status-curl">
<div class="preview">
<pre><xmp>curl http://api.lelylan.com/statuses/<id></xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-a-status-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')();
Lelylan.Status.find('<id>', callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-a-status-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">{{status}}</div>
<script>
function LelylanController($scope, Status) {
Status.find('<ID>').success(function(response) { $scope.status = response })
}
</script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-a-status-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new
status = lelylan.status('<id>')</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-a-status-python">
<div class="preview">
<pre class="prettyprint"><xmp>from lelylan import statuses
status = statuses.get_status('<id>')</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3 id="status-representation">Example body response</h3>
<div class="code-block"><pre><code>{
"name": "Setting intensity",
"id": "5042176370eda61200000004",
"uri": "http://api.lelylan.com/statuses/5042176370eda61200000004",
"created_at": "2012-09-01T14:10:43Z",
"updated_at": "2012-09-01T14:10:43Z",
"function": {
"id": "5042205c70eda61000000003",
"uri": "http://api.lelylan.com/functions/5042205c70eda61000000003"
},
"properties":[{
"id": "50420c7e267ff51000000001",
"uri": "http://api.lelylan.com/properties/50420c7e267ff51000000001",
"pending": false,
"values": ["on"],
}, {
"id": "50420c7e267ff51300000001",
"uri": "http://api.lelylan.com/properties/50420c7e267ff51300000001",
"pending": true,
"ranges": [{"min": "0", "max": "100"}]
}]
}</code></pre>
</div>
<h3>Body response explained</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td>uri</td>
<td>Device URI.</td>
</tr>
<tr>
<td>id</td>
<td>Device ID.</td>
</tr>
<tr>
<td>name</td>
<td>Device name.</td>
</tr>
<tr>
<td>function</td>
<td>
Default function associated to the status.
</td>
</tr>
<tr>
<td>properties</td>
<td>Device properties.</td>
</tr>
<tr>
<td class="nested">
<span>&raquo; property.uri</span>
</td>
<td>Property URI.</td>
</tr>
<tr>
<td class="nested">
<span>&raquo; property.id</span>
</td>
<td>Property ID.</td>
</tr>
<tr>
<td class="nested">
<span>&raquo; property.values</span>
</td>
<td>
Property values.
<a href="/support#faq-value-expected-pending">Learn more about</a>.
</td>
</tr>
<tr>
<td class="nested">
<span>&raquo; property.pending</span>
</td>
<td>
Property pending status.
<a href="/support#faq-value-expected-pending">Learn more about</a>.
</td>
</tr>
</tbody>
</table>
<h3>How do I use the matching values?</h3>
<p>
A status is based on its properties. To understand when a status match to a device in a specific
moment of its life you need to check two things.
</p>
<ul>
<li>If the current device property value is included into the status <code>values</code> list.</li>
<li>If the current device property value is included into the status <code>ranges</code> list.</li>
<li>If the current device property pending status is the same as the status <code>pending</code> value.</li>
</ul>
<div class="alert alert-info">
<p>
<span class="label label-lelylan">notice</span>
At the moment it's not possible to get the device status from server side.
A basic implementation is available on the
<a href="http://lelylan.github.io/device-directive-ng/">AngularJS Device Component</a>.
</p>
</div>
<hr>
<h2 id="get-all-statuses">GET /statuses</h2>
<p>Returns a list of owned (and <a href="/api#core-concepts-public-resources">public</a>) statuses.</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code># created statuses
GET http://api.lelylan.com/statuses
<hr>
# all statuses
GET http://api.lelylan.com/statuses/public</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>name</span>
<span class="info">optional</span>
</td>
<td>
Status name to search.
</td>
</tr>
<tr>
<td class="parameter">
<span>start</span>
<span class="info">optional</span>
</td>
<td>
ID of the last fetched record. Learn more about <a href="/api#core-concepts-infinite-scrolling-pagination">pagination</a>.
</td>
</tr>
<tr>
<td class="parameter">
<span>per</span>
<span class="info">optional</span>
<span class="info">default to '25'</span>
</td>
<td>
Number of resources per page.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#get-all-statuses-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#get-all-statuses-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#get-all-statuses-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#get-all-statuses-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#get-all-statuses-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="get-all-statuses-curl">
<div class="preview"><pre><xmp>curl http://api.lelylan.com/statuses \
-H 'Authorization: Bearer <token>'</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-statuses-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')({ token: token });
Lelylan.Status.all({}, callback); // owned resources
var Lelylan = require('lelylan-node')();
Lelylan.Status.public({}, callback); // all existing resources</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-statuses-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">
<div ng-repeat="status in owned">{{status}}</div>
<div ng-repeat="status in public">{{status}}</div>
</div>
<script>
function LelylanController($scope, Status) {
Status.all({ name: 'turn' }).success(function(response) { $scope.owned = response })
Status.public({ name: 'turn' }).success(function(response) { $scope.public = response })
}
</script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-statuses-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new(token: token)
statuses = lelylan.statuses # owned resources
lelylan = Lelylan::Client.new
statuses = lelylan.public_statuses # all existing resources</xmp></pre>
</div>
</div>
<div class="tab-pane" id="get-all-statuses-python">
<div class="preview">
<pre class="prettyprint"><xmp>oauth.set_access_token()
from lelylan import statuses
statuses = statuses.get_created_status() # owned resources
from lelylan import statuses
statuses = statuses.get_all_status() # all existing resources</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3>Example body response</h3>
<div class="code-block highlight"><pre><code>[
{ # status representation },
{ # status representation },
...
]</code></pre>
</div>
<p>
See <a href="#status-representation">status representation</a> for body response.
</p>
<hr>
<h2 id="create-a-status">POST /statuses</h2>
<p>
Create a status and returns extended information for it.
</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>POST http://api.lelylan.com/statuses</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>name</span>
<span class="info">required</span>
</td>
<td>
Status name.
</td>
</tr>
<tr>
<td class="parameter">
<span>properties</span>
<span class="info">optional</span>
</td>
<td>
Array of properties affecting the status.
</td>
</tr>
<tr>
<td class="parameter nested">
<span>&raquo; property.id</span>
<span class="info">required</span>
</td>
<td>
Property ID.
</td>
</tr>
<tr>
<td class="parameter nested">
<span>&raquo; property.value</span>
<span class="info">optional</span>
</td>
<td>
List of matching values.
<a href="/support#faq-value-expected-pending">Learn more about</a>.
</td>
</tr>
<tr>
<td class="parameter nested">
<span>&raquo; property.pending</span>
<span class="info">optional</span>
</td>
<td>
Property pending status.
<a href="/support#faq-value-expected-pending">Learn more about</a>.
<span class="info">Valid values: true, false.</span>
</td>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#create-a-status-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#create-a-status-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#create-a-status-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#create-a-status-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#create-a-status-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="create-a-status-curl">
<div class="preview">
<pre><xmp>curl -X POST http://api.lelylan.com/statuses \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{
"name": "On",
"function": {"id": "<turn-off>" },
"properties": [{
"id": "<intensity>",
"values": ["100"],
"pending": false
}]
}'</xmp></pre>
</div>
</div>
<div class="tab-pane" id="create-a-status-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')({ token: token });
var params = {
name: 'On',
function: { id: '<turn-off>' },
properties:
[ { id: '<intensity>',
value: ['100'],
pending: false } ] };
Lelylan.Status.create(params, callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="create-a-status-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">{{status}}</div>
<script>
function LelylanController($scope, Status) {
var params = {
name: 'On',
function: { id: '<turn-off>' },
properties:
[ { id: '<status>',
value: ['on'] } ] };
Status.create(params).success(function(response) { $scope.status = response })
}
</script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="create-a-status-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new(token: token)
params = {
name: 'On',
function: { id: '<turn-off>' },
properties:
[ { id: '<intensity>',
value: ['100'],
pending: false } ] }
status = lelylan.create_status(params)</xmp></pre>
</div>
</div>
<div class="tab-pane" id="create-a-status-python">
<div class="preview">
<pre class="prettyprint"><xmp>oauth.set_access_token()
params = {
name: 'On',
function: { id: '<turn-off>' },
properties:
[ { id: '<intensity>',
value: ['100'],
pending: false } ] }
from lelylan import statuses
status = statuses.create_status(params)</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 201 Created
Location: http://api.lelylan.com/statuses/5042176370eda61200000004</code></pre></div>
<h3>Example body response</h3>
<p>
See <a href="#status-representation">status representation</a> for body response.
</p>
<hr>
<h2 id="update-a-status">PUT /statuses/:id</h2>
<p>
Update a status identified from its ID and returns extended information for it.
</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>PUT http://api.lelylan.com/statuses/:id</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>id</span>
<span class="info">required</span>
</td>
<td>
The ID of the desired status.
</td>
</tr>
<tr>
<td class="parameter">
<span>name</span>
<span class="info">optional</span>
</td>
<td>
Status name.
</td>
</tr>
<tr>
<td class="parameter">
<span>properties</span>
<span class="info">optional</span>
</td>
<td>
Array of properties affecting the status.
</td>
</tr>
<tr>
<td class="parameter nested">
<span>&raquo; property.id</span>
<span class="info">required</span>
</td>
<td>
Property ID.
</td>
</tr>
<tr>
<td class="parameter nested">
<span>&raquo; property.values</span>
<span class="info">optional</span>
</td>
<td>
List of matching values.
<a href="/support#faq-value-expected-pending">Learn more about</a>.
</td>
</tr>
<tr>
<td class="parameter nested">
<span>&raquo; property.ranges</span>
<span class="info">optional</span>
</td>
<td>
List of matching ranges.
<a href="/support#faq-value-expected-pending">Learn more about</a>.
</td>
</tr>
<tr>
<td class="parameter nested">
<span>&raquo; property.pending</span>
<span class="info">optional</span>
</td>
<td>
Property pending status.
<a href="/support#faq-value-expected-pending">Learn more about</a>.
<span class="info">Valid values: true, false.</span>
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class="active"><a href="#update-a-status-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#update-a-status-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#update-a-status-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#update-a-status-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#update-a-status-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="update-a-status-curl">
<div class="preview"><pre><xmp>curl -X PUT http://api.lelylan.com/statuses/5042176370eda61200000004 \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{ "name": "Light On" }'</xmp></pre>
</div>
</div>
<div class="tab-pane" id="update-a-status-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')({ token: token });
var params = { name: 'Light On' }
Lelylan.Status.update('<id>', params, callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="update-a-status-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">{{status}}</div>
<script>
function LelylanController($scope, Status) {
var params = { name: 'Light On' };
Status.update('<ID>', params).success(function(response) { $scope.status = response })
}
</script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="update-a-status-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new(token: token)
params = { name: 'Light On' }
status = lelylan.update_status('<id>', params)</xmp></pre>
</div>
</div>
<div class="tab-pane" id="update-a-status-python">
<div class="preview">
<pre class="prettyprint"><xmp>oauth.set_access_token()
params = { name: 'Light On' }
from lelylan import statuses
status = statuses.update_status('<id>', params)</xmp></pre>
</div>
</div>
</div>
<p class="notice">
<span class="label">Notice</span>
When updating the <code>properties</code> field all previous connected properties are replaced.
</p>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3>Example body response</h3>
<p>
See <a href="#status-representation">status representation</a> for body response.
</p>
<hr>
<h2 id="delete-a-status">DELETE /statuses/:id</h2>
<p>
Delete a statuses identified from its ID and returns extended information for it.</br>
Connected properties are not deleted.
</p>
<h3>Resource URL</h3>
<div class="code-block">
<pre><code>DELETE http://api.lelylan.com/statuses/:id</code></pre>
</div>
<h3>Parameters</h3>
<table class="table table-stripped table-hover">
<tbody>
<tr>
<td class="parameter">
<span>id</span>
<span class="info">required</span>
</td>
<td>
The ID of the desired status.
</td>
</tr>
</tbody>
</table>
<h3>Example Request</h3>
<ul class="nav nav-tabs">
<li class=" active"><a href="#delete-a-status-curl" data-toggle="tab" class="curl">Curl</a></li>
<li><a href="#delete-a-status-node" data-toggle="tab" class="node">Node.js</a></li>
<li><a href="#delete-a-status-angular" data-toggle="tab" class="angular">AngularJS</a></li>
<li><a href="#delete-a-status-ruby" data-toggle="tab" class="ruby">Ruby</a></li>
<li><a href="#delete-a-status-python" data-toggle="tab" class="python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="delete-a-status-curl">
<div class="preview"><pre><xmp>curl -X DELETE http://api.lelylan.com/statuses/<id> \
-H 'Authorization: Bearer <token>'</xmp></pre>
</div>
</div>
<div class="tab-pane" id="delete-a-status-node">
<div class="preview">
<pre class="prettyprint"><xmp>var Lelylan = require('lelylan-node')({ token: token });
Lelylan.Status.delete('<id>', callback);</xmp></pre>
</div>
</div>
<div class="tab-pane" id="delete-a-status-angular">
<div class="preview">
<pre class="prettyprint"><xmp><html ng-app="lelylan.client">
<body>
<!-- login component here (dev.lelylan.com/api/oauth#implicit-grant-angular) -->
<div ng-controller="LelylanController">{{status}}</div>
<script>
function LelylanController($scope, Status) {
Status.delete('<ID>').success(function(response) { $scope.status = response })
}
</script>
</body>
</html></xmp></pre>
</div>
</div>
<div class="tab-pane" id="delete-a-status-ruby">
<div class="preview">
<pre class="prettyprint"><xmp>lelylan = Lelylan::Client.new(token: token)
status = lelylan.delete_status('<id>')</xmp></pre>
</div>
</div>
<div class="tab-pane" id="delete-a-status-python">
<div class="preview">
<pre class="prettyprint"><xmp>oauth.set_access_token()
from lelylan import statuses
status = statuses.delete_status('<id>')</xmp></pre>
</div>
</div>
</div>
<h3>Example header response</h3>
<div class="code-block"><pre><code>HTTP/1.1 200 OK</code></pre></div>
<h3>Example body response</h3>
<p>
See <a href="#status-representation">status representation</a> for body response.
</p>