Custom API Documentation


The LED Ticker Custom API allows advanced users to develop a custom ticker to display any data and customize the format of how the data is displayed. The API works by defining text to draw on the Ticker's display. The size, position, color, and alignment of the text can also be defined. The custom API can be accessed in one of two ways:

  • An http POST request sent to the Ticker through your local area network (LAN)
  • An http GET request sent by the Ticker to a url endpoint to fetch data periodically
  • API Parameters


    The API expects a set of parameters in order to fully define where and how text will be displayed.

    Parameter Type Required Values Default Value
    text String true Up to 18 characters None
    size Integer false 1 to 4 2
    color String false 000000 to FFFFFF FFFFFF
    x Integer false 0 to 63 0
    y Integer false 0 to 31 7
    align String false L, C, or R L
    page Integer false 0 to 2 0
    alert Boolean false true or false false

    POST Request (LAN Only)


    The API can be accessed locally by sending a POST request to the Ticker through your local area network (LAN).

  • Send the POST request to http://ticker.local/api (or http://<IP ADDRESS>/api)
  • API Parameters should be url encoded, i.e. spaces as %20
  • Multiple texts can be sent in the same request
  • An example request might be:

  • http://ticker.local/api?
    text=Size%201&color=FF0000&size=1&x=31&y=4&align=C&
    text=Size%202&color=00FF00&size=2&x=1&y=15&align=L&
    text=Size%203&color=0000FF&size=3&x=62&y=15&align=R&
    text=Size%204&color=FFFFFF&size=4&x=1&y=30&align=L

  • Up to 15 text strings may be defined
  • Sending multiple requests will overwrite any previous requests
  • Setting optional parameter alert=true will cause the Ticker to display the text immediately and full-screen as a momentary alert
  • GET Request


    The API can be accessed by having the Ticker send a GET request to a url endpoint.

  • The Ticker will send a GET request to the url endpoint and at the interval defined in the Ticker Settings page
  • The endpoint should be HTTP Secure (https)
  • The endpoint must return a JSON response
  • An example response might be:

  • [
     {
      "text":"Size 1",
      "color":"FF0000",
      "size":1,
      "x":31,
      "y":4,
      "align":"C"
     },
     {
      "text":"Size 2",
      "color":"00FF00",
      "size":2,
      "x":1,
      "y":15,
      "align":"L"
     },
     {
      "text":"Size 3",
      "color":"0000FF",
      "size":3,
      "x":62,
      "y":15,
      "align":"R"
     },
     {
      "text":"Size 4",
      "color":"00FF00",
      "size":4,
      "x":1,
      "y":30,
      "align":"L"
     }
    ]

  • Up to 15 text strings may be defined per page
  • Up to 3 pages can be defined using a nested array
  • The optional parameter alert has no function in GET requests
  • Output


    The example requests above will produce the following output on the Ticker display:

    Example Using Google Script


    The following demonstrates how to setup a Custom API to display Google Calendar events using Google Script. This is example assumes a basic understanding of Google Scripts.

    • 1.) Vist script.google.com to open the script editor. (You'll need to be signed in to your Google account.) If this is the first time you've been to script.google.com, you'll be redirected to a page that introduces Apps Script. Click Start Scripting to proceed to the script editor.
    • 2.) A welcome screen will ask what kind of script you want to create. Click Blank Project or Close.
    • 3.) Delete any code in the script editor and paste in the code below.
    • 4.) Select the menu item File > Save. Name your new script and click OK.
    • 5.) Click Publish on the main menu and then Deploy as web app....
    • 6.) Change Who has access to the app: to Anyone, even anonymous.
    • 7.) Click Deploy.
    • 8.) Click Review Permissions.
    • 9.) Authorize the app by clicking Allow.
    • 10.) Copy the web app URL and paste into the Ticker Custom API URL setting on the LED Ticker Settings Page.

    // Main function to handle GET requests
    function doGet(e) {

    // Set display size
     var size = 1; // Valid values: 1, 2, or 4 (1/4, 1/2, or full screen)
     if (e.parameter['size']) size = e.parameter['size'];
     var ylim = (size == 4) ? 31 : 15;
     var y0 = (size == 4) ? 5 : 6;
     var dy = (size == 4) ? 6 : 7;
     var x = (size == 1) ? 30 : 62;
     var max1 = (size == 1) ? 0 : 12;
     var max2 = (size == 1) ? 8 : 17;

     // Get all calendars
     var calendars = CalendarApp.getAllCalendars();

     // Select calendar
     var calendar = calendars[0];

     // Find events that are happening in the next 48 hours
     var now = new Date();
     var twoHoursFromNow = new Date(now.getTime() + (48 * 3600 * 1000));
     var events = calendar.getEvents(now, twoHoursFromNow);

     // Define JS objects
     var obj = [];
     var page = [];

     // Iterate through events
     var y = y0;
     var page_pos = 0;
     for (var i = 0; i < events.length; i++) {

      // Get event title, start time, color, and if its all day
      var title = events[i].getTitle();
      var start = events[i].getStartTime();
      var color = events[i].getColor();
      var allDay = events[i].isAllDayEvent();

      // Split event title onto 2 lines if too long
      var title1 = "";
      var title2 = "";
      title = title.substr(0, (max1 + max2));
      if (title.length >= max1) {
       var n = reverseString(title.substr(0, max1)).indexOf(" ");
       if (n >= 0) {
        title1 = title.substr(0, (max1 - 1) - n);
        title2 = title.substr(max1 - n);
       } else {
        title1 = title.substr(0, max1);
        title2 = title.substr(max1);
       }
      } else {
       title1 = title;
      }

      if (
       y > ylim ||
       (title2 != "" && (y + dy) > ylim)
      ) {
       obj.push(page);
       page = [];
       y = y0;
       page_pos += 1;
      }

      if (page_pos >= 3) break;


      // Print event time, right aligned in white
      page.push({
       text: sameDay(now, start) ? (allDay ? "Today" : formatTime(start)) : dayOfWeek(start.getDay()),
       color: colors[0],
       size: 1,
       x: 1,
       y: y,
       align: "L"
      });

      // Print event title 1st line, left aligned in event color
      page.push({
       text: title1,
       color: colors[color],
       size: 1,
       x: x,
       y: y,
       align: "R"
      });

      // Print event title 2nd line (if needed), left aligned in event color
      if (title2 != "") {
       y += dy;
       page.push({
        text: title2,
        color: colors[color],
        size: 1,
        x: x,
        y: y,
        align: "R"
       });
      }
      y += dy;
     }

     if (page_pos == 0) obj.push(page);

     // Return JSON
     var JSONString = JSON.stringify(obj);
     var JSONOutput = ContentService.createTextOutput(JSONString);
     JSONOutput.setMimeType(ContentService.MimeType.JSON);
     return JSONOutput;
    }

    // Helper function to format date
    function formatTime(date) {
     var hours = date.getHours();
     var minutes = date.getMinutes();
     var ampm = hours >= 12 ? 'p' : 'a';
     hours = hours % 12;
     hours = hours ? hours : 12;
     minutes = minutes < 10 ? '0' + minutes : minutes;
     var strTime = hours + ':' + minutes + ampm;
     return strTime;
    }

    function dayOfWeek(dayIndex) {
     return ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][dayIndex];
    }

    // Helper function to reverse string
    function reverseString(str) {
     var splitString = str.split("");
     var reverseArray = splitString.reverse();
     var joinArray = reverseArray.join("");
     return joinArray;
    }

    // Helper function to check same date
    function sameDay(d1, d2) {
     return d1.getFullYear() === d2.getFullYear() &&
      d1.getMonth() === d2.getMonth() &&
      d1.getDate() === d2.getDate();
    }
    // Map Google Calendar Colors
    var colors = ["ffffff", "a4bdfc", "7ae7bf", "dbadff", "ff887c", "fbd75b", "ffb878", "46d6db", "e1e1e1", "5484ed", "51b749", "dc2127"];

    Contact Us

    Email: support@ledtickers.com
    Minneapolis, Minnesota

    Copyright © 2019 LED Tickers, LLC