XML API

OpenVoucher has a powerful XML API that can be used to remote control the system by third party software or plugins.

The API is currently in development and not finished yet – I’m working on this.

You can use the API by sending HTTP requests to the following URL:

http(s)://ip.or.host.name/admin/api.php

Logging in

To use the API, a login is needed. Call it with POST parameters “user” and “pwd”. To run commands on the API, the user has to have the corresponding permissions as he would need for the same actions in the admin interface. Also, the permission “api_login” is needed to use the API in general.

After a successful login the API will respond with:

<authentication>
<state>success</state>
<session>j24nb8oanpqk9lggvpblsdiok6</session>
</authentication>

Parse the <session>-section, this is the session id. You need this id for every interaction with the API. The whole <authentication>-section will be send every time you call the API. This is for your application to make sure it is still authenticated. According to your webserver’s settings, sessions will expire after a specific time.

List vouchers

Example request: http://x.x.x.x/admin/api.php?session_id=j24nb8oanpqk9lggvpblsdiok6&do=lstvouchers

Example response:

<authentication>
    <state>success</state>
    <session>j24nb8oanpqk9lggvpblsdiok6</session>
</authentication>
<voucherlist>
    <state>success</state>
        <voucher>
            <vid>2014-02-11-130498</vid>
            <verification></verification>
            <devcount>3</devcount>
            <validuntil>1392163290</validuntil>
            <comment></comment>
        </voucher>
        <voucher>
            <vid>2014-02-11-268026</vid>
            <verification></verification>
            <devcount>3</devcount>
            <validuntil>1392163290</validuntil>
            <comment></comment>
        </voucher>
        <voucher>
            <vid>2014-02-11-574581</vid>
            <verification></verification>
            <devcount>2</devcount>
            <validuntil>1392150992</validuntil>
            <comment></comment>
        </voucher>
        <voucher>
            <vid>2014-02-11-742327</vid>
            <verification></verification>
            <devcount>3</devcount>
            <validuntil>1392163290</validuntil>
            <comment></comment>
        </voucher>
</voucherlist>

Add vouchers

Example request: http://x.x.x.x/admin/api.php?session_id=j24nb8oanpqk9lggvpblsdiok6&do=addvoucher&devicecount=2&valid_until=1392150992

Example response:

<authentication>
    <state>success</state>
    <session>j24nb8oanpqk9lggvpblsdiok6</session>
</authentication>
<action>
    <job>addvoucher</job>
    <state>success</state>
    <vid>2014-02-11-730534</vid>
</action>

Drop vouchers

Example request: http://x.x.x.x/admin/api.php?session_id=j24nb8oanpqk9lggvpblsdiok6&do=dropvoucher&vid=2014-02-11-730534

Example response:

<authentication>
    <state>success</state>
    <session>j24nb8oanpqk9lggvpblsdiok6</session>
</authentication>
<action>
    <job>dropvoucher</job>
    <state>success</state>
</action>

Drop devices

Example request: http://x.x.x.x/admin/api.php?session_id=j24nb8oanpqk9lggvpblsdiok6&do=dropdevice&type=mac&addr=00:0c:29:34:fc:5c

Example reply:

<authentication>
    <state>success</state>
    <session>j24nb8oanpqk9lggvpblsdiok6</session>
</authentication>
<action>
    <job>dropdevice</job>
    <state>success</state>
</action>

The API is still in development – to be continued

Comments are closed.