v1.2.2 - Official User Guide

API Documentation

Bancha ships with a complete API system that permits your apps to completely integrates with the Bancha framework. By default, GET and POST requests are accepted. All responses have the same JSON prototype that consists in three keys:

  1. status (the HTTP status code)
  2. data which contains the requested data
  3. message, a short string indicating the status of the request.

Before all, the client must login with his username/password. Bancha will returns a unique token that needs to be sent on each requests that requires authentication.

Note: the URL of any API method needs to be called by prefixing the administration path, such as admin/api/login.


Returns you the token on success. The token needs to be sent on each requests that requires authentication.

  • Method: GET/POST

  • Response: Json

  • Params: username (string), password (string):

    //Example of call:
    username = demo
    password = demo
    //Outputs on success:
    //Outputs on failure:
    {"status":403,"data":[ ],"message":"USER_PWD_WRONG"}


Needs authentication. This API gives you the ability to query the Bancha ORM system such as the Records class. We called this feature ActiveQuery, and all the methods remains the same of the model methods. It always requires two parameters: token and query.

  • Method: GET/POST

  • Response: Json

  • Params: token (string), query (string):

    //Example of call:
    token = abcdefg123456789
    query = type:Blog|limit:1|order_by:id_record,DESC|get
        "data": {
            "records": [

As you can see, the syntax is very similar to the PHP one. Check this other example:

//PHP Syntax:
$posts = $this->records->type('Products')->like('title', 'Hello')->limit(5)->get();

//Same result with ActiveQuery syntax:

//Pretty simple, uh?

//Another PHP example:
$last_post = $this->records->type('Blog')->order_by('date_publish', 'DESC')->get_first();

//And the same record using the ActiveQuery syntax:

When no records are found, you will receive an output with this prototype:


Note: Functions that accepts arrays are not supported by the ActiveQuery system yet.


Needs authentication. This method is used to save, publish, depublish and delete records.

  • Method: GET/POST
  • Response: Json

URI Params:

  • action: “save”, “publish”, “depublish”
  • type: The type id or name

Any other appended parameter will be used for the record data. Below you can see an example of how a sample call looks like:

Success response:


Error messages:

{"status":403,"data":[],"message":"TYPE IS MANDATORY"}

{"status":403,"data":[],"message":"TYPE NOT FOUND"}


Needs authentication. Destroys the current token.

  • Method: GET/POST
  • Response: Json
  • Params: token (string)
token = abcdefg123456789

//Example of call:


Back to Framework

Bancha - Copyright 2011-2012(C) Squallstar Studio -