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:




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: