API for PHP and Python
  |  
API for .NET



The following applies to versions MikroBILL 2.0.6 and newer.
To create extensions in PHP you will need to include the apicore.php
file (you can find it in the Apache WEB documents folder in the kassa subfolder).
Full class descriptions available here.
Python version of the class here.



1. Example in PHP for connecting to the MikroBILL server.






You can copy the apicore.php file to another WEB server where there is no MikroBILL cash register, then when creating an instance of the MikroBILL_API class, you need to add 2 more arguments:






You can take the $CRYPTO_KEY_1 variable from the config.php file, which is located in the root of WEB server MikroBILL, and the variable $CRYPTO_KEY_2 from the MikroBILL database from the `workparams` table.
Please note that the values of these variables are unique and will be changed if MikroBILL is reinstalled!





2. Command format.

Commands are called along their path. The path separator is the dot character. The path corresponds to the classes in their hierarchy, a description of the classes is available here.
As you can see, the command for receiving or searching for users is located directly in the API class, which means the call will look like this:




The result will be JSON like:




The return field contains an array of user IDs. Field code = 0 indicates no errors. Any other number signals a problem, then the return will contain a description.
To access user property, you must specify the user ID in the command path:




Result:




Another example. Let's set a new IP for the user. To do this, you must first obtain all user accounts:




The result will be an array of account GUIDs:




Now let's go to the required account to get the "IP" property.




Result:




To set the value, you need to add a second argument to the Process function:




If a function requires several input arguments, then they must be passed as an array.
We remind you that a description of the input arguments can be found in the class descriptions here.




If the operation was successful, you will receive a message like:






3. Batch Commands.

You can request several values in one command (starting from MikroBILL 2.0.9), for this you need to pass an array as the second argument to the Process function.
In the array, you need to list the arguments so that the initial path in the Process function + element name of the array forms a complete path.




The result will be JSON like:




Starting with MikroBILL 2.0.15, the "object" parameter has been added to the response, returning the result of the entire request as a JSON object.

In order to set several parameters at the same time, you need to add an associated value to each argument in the array.




The result will be JSON like:




It is also possible to read parameters and set them in one command.




The result will be JSON like:





You can use arrays with any nesting depth.
For example, here:




And here:




In both cases the path is called:







4. Data search.

Starting with MikroBILL 2.0.14, data search is available using the Find operator, which is present inside all base classes. The search returns GUIDs of objects that have the searched data in their fields.
The search command looks like this:
$Api->Process("API.Class.Find", ['Path', 'Comparison_operator', Compared_value]);
For example:




The second argument to the Process function is an array. The first argument of the array is the path, the value of which we will compare with the condition. The second argument is the mathematical condition. The third argument is the value we are comparing with.
That is, in our example, the function will return the GUID of all subscribers whose StatusInfo.BlockReason = -1, i.e. all those who are allowed access.
More detailed information on the class description page.

You can use multiple search conditions. To do this, the fourth argument in the array is equal to AND or OR, the next three arguments are identical in essence to the first three, i.e. these are: path, comparison logic and the value being compared.
The number of additional selection conditions can be any.
In the example below, we search for the GUID of subscribers who are allowed access and whose IP matches the mask:



As we can see from the example above, you can search within any enumeration, for example, in the list of accounts. To do this, you need to put the * symbol in the path instead of the element's GUID.