Flapit API user guide
Avanzar al contenido principal
en
it
de
fr
pt
ru
es
zh
Estás navegando por nuestro servidor seguro.VOLVER A PÁGINA DE INICIO

API Documentation

POST /control/device endpoint

Sends a command to a device or a set of devices belonging to a single user. The request should have mime type "application/json". The request body should be a JSON object with the following fields:

  • device_id -- a string or an array of strings. Each string should be a device serial number. All devices should belong to a single user.
  • token -- a string. This should be the token given to the user from the web UI.
  • message -- a string containing the symbols to be displayed on the Flapit devices

The API also supports x-www-form-urlencoded data. In that case the fields are the same as in the JSON object, however device_id should be a comma-separated list of Flapit serial numbers.

Examples

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"device_id":["DEVICE_ID_1","DEVICE_ID_2"], "token":"USER_ACCESS_TOKEN", "message":"facebook 1000"}' \
  https://www.flapit.com/control/device

curl \
  -d device_id=DEVICE_ID_1,DEVICE_ID_2 \
  -d token=USER_ACCESS_TOKEN \
  -d message="facebook 1000" \
  https://www.flapit.com/control/device

request = require('request');

function show(message, callback) {
  request.post({
    url:'https://www.flapit.com/control/device',
    form: {
      'device_id':'DEVICE_ID_1,DEVICE_ID_2',
      'token': "USER_ACCESS_TOKEN",
      "message": message
    }
  }, callback);
}

show(":) FLAPIT");
import json, requests

def show(message):
  data = {'device_id':['DEVICE_ID_1','DEVICE_ID_2'],'token':'USER_ACCESS_TOKEN','message':'facebook 1000'}
  return requests.post('https://www.flapit.com/control/device', data=data)

show(":) FLAPIT")
require 'rest_client'

def show(message)
  RestClient.post "https://www.flapit.com/control/device",
    :device_id => "DEVICE_ID_1,DEVICE_ID_2",
    :token => "USER_ACCESS_TOKEN",
    :message => message
end

show ":) FLAPIT"
import java.io.IOException;
import org.apache.http.client.fluent.Form;
import org.apache.http.client.fluent.Request;

public class App
{
    public static void show(String message) throws IOException
    {
        Request request = Request.Post("https://www.flapit.com/control/device")
            .setHeader("content-type", "application/x-www-form-urlencoded")
            .bodyForm(Form.form()
                .add("device_id", "DEVICE_ID_1")
                .add("token", "USER_ACCESS_TOKEN")
                .add("message", message)
                .build());

        request.execute();
    }

    public static void main(String[] args) throws IOException
    {
        show(":) FLAPIT");
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;

public class App
{
    public static async Task Show(string message)
    {
        var client = new HttpClient();
        var uri = new Uri("https://www.flapit.com/control/device");
        var fields = new Dictionary
        {
            {"device_id","DEVICE_ID_1,DEVICE_ID_2"},
            {"token","USER_ACCESS_TOKEN"},
            {"message", message}
        };
        var content = new FormUrlEncodedContent(fields);
        await client.PostAsync(uri, content);
    }

  public static void Main()
  {
    var task = Show(":) FLAPIT");
    task.Wait();
  }
}
-- requires http-streams and io-streams
{-# LANGUAGE OverloadedStrings #-}
import Network.Http.Client

send message = postForm "https://www.flapit.com/control/device"
       [("device_id", "DEVICE_ID_1,DEVICE_ID_2"),
        ("token", "USER_ACCESS_TOKEN"),
        ("message", message)] $ \_ _-> return ()

main:: IO ()
main = send ":) FLAPIT"

POST /control/group endpoint

This call sends a command to a named group of devices, specified in the web UI. The request must contain the following fields:

  • group_id -- The name of the group, chosen by the user in the web UI.
  • token -- a string. This should be the token given to the user from the web UI.
  • message -- a string containing the symbols to be displayed on the Flapit devices

Every device has a program associated to it, which is responsible for sending commands to the device. Multiple devices can be assigned the same program from the Flapit web UI, in which case they will be assigned a group name. When the API control is activated for such a group, the previous program controlling the group will be suppressed and the user will be fully responsible for managing the group through the API. Deactivating the API control will restore the previous program assigned to the group.

If you want to have a default automatic behavior for a Flapit device but still want to send direct commands occasionally, you should use the 'control/device' API call.

Examples

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"group_id": "GROUP_ID", "token": "USER_ACCESS_TOKEN", "message": ":) FLAPIT"}' \
  https://www.flapit.com/control/group
var request = require('request');

function show(message, callback) {
  request.post({
    url:'https://www.flapit.com/control/group',
    form: {
      'group_id': "GROUP_ID",
      'token': "USER_ACCESS_TOKEN",
      "message": message
    }
  }, callback);
}

show(":) FLAPIT");
import json, requests

def show(message):
  data = {'group_id': 'GROUP_ID', 'token': 'USER_ACCESS_TOKEN', 'message': message}
  return requests.post('https://www.flapit.com/control/group', data=data)

show(":) FLAPIT")
require 'rest_client'

def show(message)
  RestClient.post "https://www.flapit.com/control/group",
    :group_id => "GROUP_ID",
    :token => "USER_ACCESS_TOKEN",
    :message => message
end

show ":) FLAPIT"
import java.io.IOException;
import org.apache.http.client.fluent.Form;
import org.apache.http.client.fluent.Request;

public class App
{
    public static void show(String message) throws IOException
    {
        Request request = Request.Post("https://www.flapit.com/control/group")
            .setHeader("content-type", "application/x-www-form-urlencoded")
            .bodyForm(Form.form()
                .add("group_id", "GROUP_ID")
                .add("token", "USER_ACCESS_TOKEN")
                .add("message", message)
                .build());

        request.execute();
    }

    public static void main(String[] args) throws IOException
    {
        show(":) FLAPIT");
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;

public class App
{
    public static async Task Show(string message)
    {
        var client = new HttpClient();
        var uri = new Uri("https://www.flapit.com/control/group");
        var fields = new Dictionary
        {
            {"group_id", "GROUP_ID"},
            {"token","USER_ACCESS_TOKEN"},
            {"message", message}
        };
        var content = new FormUrlEncodedContent(fields);
        await client.PostAsync(uri, content);
    }

    public static void Main()
    {
        var task = Show(":) FLAPIT");
        task.Wait();
    }
}
-- requires http-streams and io-streams
{-# LANGUAGE OverloadedStrings #-}
import Network.Http.Client

send message = postForm "https://www.flapit.com/control/group"
       [("group_id", "GROUP_ID"),
        ("token", "USER_ACCESS_TOKEN"),
        ("message", message)] $ \_ _->return ()

main:: IO ()
main = send ":) FLAPIT"

POST /control/slot endpoint

This call sends a command to a slot in a program associated to a group of devices. The request must contain the following fields:

  • slot_id -- The name of the slot. It can be retrieved from the web UI.
  • token -- a string. This should be the token given to the user from the web UI.
  • message -- a string containing the symbols to be displayed on the Flapit devices

Each program associated to a device consists of one or more slots which can display messages of different types for the duration given in the program. clock. An API slot is a slot which is directly controled by the user. Every slot has an id which is given to the user from the web UI. The user can use this call to change the current message of an API slot.

Examples

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"slot_id": "SLOT_ID", "token": "USER_ACCESS_TOKEN", "message": ":) FLAPIT"}' \
  https://www.flapit.com/control/slot
var request = require('request');

function show(message, callback) {
  request.post({
    url:'https://www.flapit.com/control/slot',
    form: {
      'slot_id': "SLOT_ID",
      'token': "USER_ACCESS_TOKEN",
      "message": message
    }
  }, callback);
}

show(":) FLAPIT");
import json, requests

def show(message):
  data = {'slot_id': 'SLOT_ID', 'token': 'USER_ACCESS_TOKEN', 'message': message}
  return requests.post('https://www.flapit.com/control/slot', data=data)

show(":) FLAPIT")
require 'rest_client'

def show(message)
  RestClient.post "https://www.flapit.com/control/slot",
    :slot_id => "SLOT_ID",
    :token => "USER_ACCESS_TOKEN",
    :message => message
end

show ":) FLAPIT"
import java.io.IOException;
import org.apache.http.client.fluent.Form;
import org.apache.http.client.fluent.Request;

public class App
{
    public static void show(String message) throws IOException
    {
        Request request = Request.Post("https://www.flapit.com/control/slot")
            .setHeader("content-type", "application/x-www-form-urlencoded")
            .bodyForm(Form.form()
                .add("slot_id", "SLOT_ID")
                .add("token", "USER_ACCESS_TOKEN")
                .add("message", message)
                .build());

        request.execute();
    }

    public static void main(String[] args) throws IOException
    {
        show(":) FLAPIT");
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;

public class App
{
    public static async Task Show(string message)
    {
        var client = new HttpClient();
        var uri = new Uri("https://www.flapit.com/control/slot");
        var fields = new Dictionary
        {
            {"slot_id", "SLOT_ID"},
            {"token","USER_ACCESS_TOKEN"},
            {"message", message}
        };
        var content = new FormUrlEncodedContent(fields);
        await client.PostAsync(uri, content);
    }

    public static void Main()
    {
        var task = Show(":) FLAPIT");
        task.Wait();
    }
}
-- requires http-streams and io-streams
{-# LANGUAGE OverloadedStrings #-}
import Network.Http.Client

send message = postForm "https://www.flapit.com/control/slot"
       [("slot_id", "SLOT_ID"),
        ("token", "USER_ACCESS_TOKEN"),
        ("message", message)] $ \_ _->return ()

main:: IO ()
main = send ":) FLAPIT"