Snakeify API REFERENCE
Introduction Authentication
FRONTEND BUILD API
Layout Preview Page Builder
BACKEND PYTHON API
Python Callbacks
WEB COMPONENTS
Button Checkbox Menu Segment Button Select Menu Slider Toggle Switch Text Input Image Text Output Card Divider
 Snakeify
API REFERENCE
Snakeify API Reference

Snakeify is a service that auto-generates fullstack websites for download. The REST API uses standard HTTPS calls in JSON format for all requests and responses.

 

Just getting started? Check out our Quick Start guide for basic templates and working UI components demo downloads.

 BASE  URL 

https://api.snakeify.com
 ENDPOINT 

GET /api

Authentication

Snakeify uses API tokens for access to the API. You can find the API token in your Account → Settings page. The REST API requires your access token to be included with each request call. A simple Test API request is provided to verify your account access.

 

All examples are shown using basic Linux/Mac cURL terminal window commands, but can also be called by other methods.

 REQUEST 

curl https://api.snakeify.com/api -d '{
  "token": "API_TOKEN",
  "request": "Test"
}'
 RESPONSE 

{
  "status": "Ok",
  "result": "Active"
}

Layout Preview

The Layout API request is used for raw layout planning of page user interface (UI) components within a 12-column grid.

 

A minimal set of parameters are used for each item's layout coordinates, width and height. Detailed parameters for styling and text/image content are part of the Build API request.

 

Parameters


pages  array of hashes

An array of website hash page entries containing UI components.
NOTE:  Only the array's first page entry will be shown in previews.


component_type  array of hashes

The button component array is shown as an example. The complete list of component types is under the Web Components section.


x  integer    y  integer    w  integer    h  integer

The upper-left page corner is defined as x = 0 and y = 0.

The w and h values (width & height limits) are component-specific.

More button layouts can be added with new { x, y, w, h } entries.

 REQUEST 

curl https://api.snakeify.com/api -d '{
  "token": "API_TOKEN",
  "request": "Layout",
  "pages": [
    {
      "button": [
        {
          "x": 0, "y": 0, "w": 1, "h": 1
        }
      ]
    }
  ]
}'
 RESPONSE 

{
  "status": "Ok",
  "result":
    "https://www.snakeify.com/grid?
     button=0,0,1,1"
}

 

HINT:  Previews can be directly modified from the web browser's URL parameters for quick visual layout adjustments.

Page Builder

The Build API request is used to generate multi-page websites with both frontend and backend files. The response returns a unique URL link to download the custom snakeify.zip file.

 

Parameters


pages  array of hashes

An array of website pages. Each page is a comma-separated hash entry.


page_name  string

The name of each unique web page entry.


title_bar  string (optional)

The browser's title bar text for the web page entry.

If this line is omitted, the title bar will be blank.


component_type  array of hashes

The button component array is shown as an example. More button components can be added with new comma-separated hash entries. The complete reference of UI parameters is in Web Components.

 REQUEST 

curl https://api.snakeify.com/api -d '{
  "token": "API_TOKEN",
  "request": "Build",
  "pages": [
    {
      "page_name": "index",
      "title_bar": "My Home Page Title",
      "button": [
        {
          "x": 0, "y": 0, "w": 1, "h": 1,
          "text": "Button",
          "label": "Enter",
          "url": ""
        }
      ]
    }
  ]
}'
 RESPONSE 

{
  "status": "Pending (wait 1 minute)",
  "result":
    "https://files.snakeify.com/pub
     /aBcDeFgHiJkL/snakeify.zip"
}

Python Callbacks

The backend consists of Python files matching each frontend page name. Every page's Python callback function is called when its button is clicked. For example, a clicked /index page calls its associated index.py file.

 

Your own custom code can be added to process incoming UI parameters. These parameter values can be directly modified in real-time by your code. The button component parameters are described below.


Button

A button invokes Python callback code in the backend for processing other page inputs. It can also redirect the browser to a specified URL.

 

Parameters


button  array of hashes

Comma-separated hash list of button instances.


x  integer    y  integer    w  integer    h  integer

Coordinates x and y, where x = 0 to 11.

The width w = 1 to 2.  The height h = 1 to 2.


text  string

The visible text above the button.


label  string

The visible text inside the button


url  string (optional)

An optional non-empty string disables callbacks and directs the page to a URL link.

 REQUEST 

curl https://api.snakeify.com/api -d '{
  "token": "API_TOKEN",
  "request": "Build",
  "pages": [
    {
      "page_name": "index",
      "button": [
        {
          "x": 0, "y": 0, "w": 1, "h": 1,
          "text": "Button",
          "label": "Enter",
          "url": ""
        }
      ]
    }
  ]
}'
 PYTHON  EXAMPLE   index.py

def callback(ui):
    ui.button[0]["text"]  = "New"     # New header text
    ui.button[0]["label"] = "Clicked" # New button label
    ui.console = "Label is %s" % ui.button[0]["label"]
    return ui

 

HINT:  The Python ui.console variable prints directly to the web browser console for debugging.

Checkbox

Checkbox parameters can be read or dynamically modified by Python callbacks, but a button must exist on the same page to invoke the code.

 

Parameters


checkbox  array of hashes

Comma-separated hash list of checkbox instances.


x  integer    y  integer    w  integer    h  integer

Coordinates x and y, where x = 0 to 11.

The width w = 1 to 2.  The height h = 1 to 2.


text  string

The visible text above the checkbox.


state  boolean

The checkbox state (true or false).

 REQUEST 

curl https://api.snakeify.com/api -d '{
  "token": "API_TOKEN",
  "request": "Build",
  "pages": [
    {
      "page_name": "index",
      "checkbox": [
        {
          "x": 0, "y": 0, "w": 1, "h": 1,
          "text": "Checkbox",
          "state": false
        }
      ]
    }
  ]
}'
 PYTHON  EXAMPLE   index.py

def callback(ui):
    ui.checkbox[0]["text"] = "New"      # Change text
    if ui.checkbox[0]["state"] == True: # Read the state
        ui.console = "Checkbox is true"
    else:
        ui.console = "Checkbox is false"
    return ui

Menu
Menu
  • Menu1
  • Menu2

Menu item selections redirect the browser to specified URLs. The menu definitions can also be dynamically modified by Python callbacks, but a button must exist on the same page to invoke the code.

 

Parameters


menu  array of hashes

Comma-separated hash list of top-level menu instances.


x  integer    y  integer    w  integer    h  integer

Coordinates x and y, where x = 0 to 11.

The width w = 1 to 2.  The height h = 1.


text  string

The visible text of the top-level menu.


list  array of arrays

Comma-separated list of menu items for redirecting page to URL links.

The format for each menu entry is [ "Item Label", "URL Link"  ].

 REQUEST 

curl https://api.snakeify.com/api -d '{
  "token": "API_TOKEN",
  "request": "Build",
  "pages": [
    {
      "page_name": "index",
      "menu": [
        {
          "x": 0, "y": 0, "w": 1, "h": 1,
          "text": "Menu",
          "list": [
            [ "Menu1", "/index" ],
            [ "Menu2", "/index" ]
          ]
        }
      ]
    }
  ]
}'
 PYTHON  EXAMPLE   index.py

def callback(ui):
    ui.menu[0]["text"] = "New"      # Change header text
    menu_list = ui.menu[0]["list"]
    menu_list[0] = [ "New1", "/first" ]       # Modified
    menu_list[1] = [ "New2", "/second" ]      # Modified
    menu_list.append([ "New3", "/third" ])    # Added
    ui.menu[0]["list"] = menu_list
    ui.console = "Menu entries were modified and added"
    return ui

Segment Button

Segment button parameters can be read or dynamically modified by Python callbacks, but a button must exist on the same page to invoke the code.

 

Parameters


segment_btn  array of hashes

Comma-separated hash list of segment button instances.


x  integer    y  integer    w  integer    h  integer

Coordinates x and y, where x = 0 to 11.

The width w = 4 to 6.  The height h = 1 to 2.


text  string

The visible text above the segment button.


list  array of strings

Comma-separated list of segment text labels. The maximum size is 5.


sel  integer

The selected button segment index, where sel = 0 to 4.

 REQUEST 

curl https://api.snakeify.com/api -d '{
  "token": "API_TOKEN",
  "request": "Build",
  "pages": [
    {
      "page_name": "index",
      "segment_btn": [
        {
          "x": 0, "y": 0, "w": 4, "h": 1,
          "text": "Segment Button",
          "list": [
            "Seg1", "Seg2", "Seg3"
          ],
          "sel": 0
        }
      ]
    }
  ]
}'
 PYTHON  EXAMPLE   index.py

def callback(ui):
    ui.segment_btn[0]["text"] = "New"  # New header text
    seg_list = ui.segment_btn[0]["list"]
    seg_list.append("Seg4")            # Add new segment
    ui.segment_btn[0]["list"] = seg_list
    ui.console = "Index: %d" % ui.segment_btn[0]["sel"]
    return ui

Select Menu

Select menu parameters can be read or dynamically modified by Python callbacks, but a button must exist on the same page to invoke the code.

 

Parameters


select_menu  array of hashes

Comma-separated hash list of select menu instances.


x  integer    y  integer    w  integer    h  integer

Coordinates x and y, where x = 0 to 11.

The width w = 2 to 3.  The height h = 1 to 2.


text  string

The visible text above the select menu.


list  array of strings

Comma-separated list of selection text labels. The maximum size is 10.


sel  integer

The selected menu index, where sel = 0 to 9.

There is no selected menu when sel = -1.

 REQUEST 

curl https://api.snakeify.com/api -d '{
  "token": "API_TOKEN",
  "request": "Build",
  "pages": [
    {
      "page_name": "index",
      "select_menu": [
        {
          "x": 0, "y": 0, "w": 2, "h": 1,
          "text": "Select Menu",
          "list": [
            "Item1", "Item2", "Item3"
          ],
          "sel": -1
        }
      ]
    }
  ]
}'
 PYTHON  EXAMPLE   index.py

def callback(ui):
    ui.select_menu[0]["text"] = "New"  # New header text
    sel_list = ui.select_menu[0]["list"]
    sel_list.append("Item4")           # New menu item
    ui.select_menu[0]["list"] = sel_list
    ui.console = "Index: %d" % ui.select_menu[0]["sel"]
    return ui

Slider

Slider parameters can be read or dynamically modified by Python callbacks, but a button must exist on the same page to invoke the code.

 

Parameters


slider  array of hashes

Comma-separated hash list of slider instances.


x  integer    y  integer    w  integer    h  integer

Coordinates x and y, where x = 0 to 11.

The width w = 1 to 3.  The height h = 1 to 2.


text  string

The visible text above the slider.


percent  integer

The slider position percentage from 0 to 100.

 REQUEST 

curl https://api.snakeify.com/api -d '{
  "token": "API_TOKEN",
  "request": "Build",
  "pages": [
    {
      "page_name": "index",
      "slider": [
        {
          "x": 0, "y": 0, "w": 2, "h": 1,
          "text": "Slider",
          "percent": 50
        }
      ]
    }
  ]
}'
 PYTHON  EXAMPLE   index.py

def callback(ui):
    ui.slider[0]["text"] = "New"   # Change header text
    ui.slider[0]["percent"] = 25   # Change slider value
    ui.console = "%d percent" % ui.slider[0]["percent"]
    return ui

Toggle Switch

Toggle switch parameters can be read or dynamically modified by Python callbacks, but a button must exist on the same page to invoke the code.

 

Parameters


toggle  array of hashes

Comma-separated hash list of toggle switch instances.


x  integer    y  integer    w  integer    h  integer

Coordinates x and y, where x = 0 to 11.

The width w = 1 to 2.  The height h = 1 to 2.


text  string

The visible text above the toggle switch.


state  boolean

The toggle switch state (true or false).

 REQUEST 

curl https://api.snakeify.com/api -d '{
  "token": "API_TOKEN",
  "request": "Build",
  "pages": [
    {
      "page_name": "index",
      "toggle": [
        {
          "x": 0, "y": 0, "w": 1, "h": 1,
          "text": "Toggle",
          "state": true
        }
      ]
    }
  ]
}'
 PYTHON  EXAMPLE   index.py

def callback(ui):
    ui.toggle[0]["text"]  = "New"  # Change header text
    ui.toggle[0]["state"] = False  # Change toggle state
    ui.console = "State: %s" % ui.toggle[0]["state"]
    return ui

Text Input

Text input parameters can be read or dynamically modified by Python callbacks, but a button must exist on the same page to invoke the code.

 

Parameters


text_input  array of hashes

Comma-separated hash list of text input instances.


x  integer    y  integer    w  integer    h  integer

Coordinates x and y, where x = 0 to 11.

The width w = 2 to 3.  The height h = 1 to 2.


text  string

The visible text above the input box. Default text can be pre-filled.


input  string

The user's text input string.


type  string (optional)

An optional non-empty string is used to select special input types.
Use "password" to display the user's input as hidden asterisks.

 REQUEST 

curl https://api.snakeify.com/api -d '{
  "token": "API_TOKEN",
  "request": "Build",
  "pages": [
    {
      "page_name": "index",
      "text_input": [
        {
          "x": 0, "y": 0, "w": 2, "h": 1,
          "text": "Text Input",
          "input": "Enter your text",
          "type": ""
        }
      ]
    }
  ]
}'
 PYTHON  EXAMPLE   index.py

def callback(ui):
    ui.text_input[0]["text"] = "New"   # New header text
    ui.console = "Input: %s" % ui.text_input[0]["input"]
    return ui

Image

Image parameters can be read or dynamically modified by Python callbacks, but a button must exist on the same page to invoke the code.

 

Parameters


image  array of hashes

Comma-separated hash list of image instances.


x  integer    y  integer    w  integer    h  integer

Coordinates x and y, where x = 0 to 11.

The width w = 1 to 6.  The height h = 1 to 6.


source  string

The URL path of the image source.

 REQUEST 

curl https://api.snakeify.com/api -d '{
  "token": "API_TOKEN",
  "request": "Build",
  "pages": [
    {
      "page_name": "index",
      "image": [
        {
          "x": 0, "y": 0, "w": 2, "h": 2,
          "source": "/default_image.jpg"
        }
      ]
    }
  ]
}'
 PYTHON  EXAMPLE   index.py

def callback(ui):
    ui.image[0]["source"] = "/my_image.gif"  # New image
    ui.console = "Source: %s" % ui.image[0]["source"]
    return ui

Text Output
Text Title
Lorem ipsum dolor sit amet. Ut amet eligendi et sapiente explicabo quo.

Text output parameters can be read or dynamically modified by Python callbacks, but a button must exist on the same page to invoke the code.

 

Parameters


text_output  array of hashes

Comma-separated hash list of text output instances.


x  integer    y  integer    w  integer    h  integer

Coordinates x and y, where x = 0 to 11.

The width w = 1 to 6.  The height h = 1 to 6.


title  string

The text output main title.


text  string

The text output main content.

 REQUEST 

curl https://api.snakeify.com/api -d '{
  "token": "API_TOKEN",
  "request": "Build",
  "pages": [
    {
      "page_name": "index",
      "text_output": [
        {
          "x": 0, "y": 0, "w": 3, "h": 2,
          "title": "Text Title",
          "text": "Lorem ipsum dolor..."
        }
      ]
    }
  ]
}'
 PYTHON  EXAMPLE   index.py

def callback(ui):
    ui.text_output[0]["title"] = "New Title"
    ui.text_output[0]["text"]  = "New Content"
    ui.console = "Text output was changed"
    return ui

Card
Card Title
Card Subtitle
Lorem ipsum dolor sit amet. Ut amet eligendi et sapiente explicabo quo ipsa maxime.

Card parameters can be read or dynamically modified by Python callbacks, but a button must be pressed to invoke the code.

 

Parameters


card  array of hashes

Comma-separated hash list of card instances.


x  integer    y  integer    w  integer    h  integer

Coordinates x and y, where x = 0 to 11.

The width w = 2 to 3.  The height h = 2 to 6.


image  string (optional)

The URL path of the card image source.


title  string (optional)

The card main title text.


subt  string (optional)

The card main subtitle text.


text  string (optional)

The card main content text.


button  array of strings (optional)

String entries define button text.
The maximum number of buttons is 2.


url  array of strings (optional)

Optional non-empty strings redirect button clicks to other pages.
The maximum size is 2.

 REQUEST 

curl https://api.snakeify.com/api -d '{
  "token": "API_TOKEN",
  "request": "Build",
  "pages": [
    {
      "page_name": "index",
      "card": [
        {
          "x": 0, "y": 0, "w": 4, "h": 4,
          "image": "/card_image.jpg",
          "title": "Card Title",
          "subt": "Card Subtitle",
          "text": "Lorem ipsum dolor...",
          "button": [ "Btn1", "Btn2" ],
          "url": [ "" , "" ]
        }
      ]
    }
  ]
}'
 PYTHON  EXAMPLE   index.py

def callback(ui):
    ui.card[0]["image"]  = "/my_image.gif"
    ui.card[0]["title"]  = "New Title"
    ui.card[0]["subt"]   = "New Subtitle"
    ui.card[0]["text"]   = "New Content"
    ui.card[0]["button"] = [ "New1", "New2" ]
    ui.console = "Card parameters were changed"
    return ui

Divider

The divider component helps group related page content. The horizontal or vertical orientation is based on its relative width and height ratio.

 

Divider parameters can be read or dynamically modified by Python callbacks, but a button must exist on the same page to invoke the code.

 

Parameters


divider  array of hashes

Comma-separated hash list of divider instances.


x  integer    y  integer    w  integer    h  integer

Coordinates x and y, where x = 0 to 11.

The width w = 1 to 6.  The height h = 1 to 6.


weight  integer

The divider line thickness.

 REQUEST 

curl https://api.snakeify.com/api -d '{
  "token": "API_TOKEN",
  "request": "Build",
  "pages": [
    {
      "page_name": "index",
      "divider": [
        {
          "x": 0, "y": 0, "w": 3, "h": 1,
          "weight": 3
        }
      ]
    }
  ]
}'
 PYTHON  EXAMPLE   index.py

def callback(ui):
    ui.divider[0]["weight"] = 1  # Change line thickness
    ui.console = "Weight: %d" % ui.divider[0]["weight"]
    return ui