Results 1 to 3 of 3

Thread: How to make request to DirectAdmin with REST API?

  1. #1
    Join Date
    Jul 2017
    Posts
    1

    How to make request to DirectAdmin with REST API?

    Does anyone know how I can make a query for API from DirectAdmin? https://www.directadmin.com/api.php

    I'm using AngularJS + .NET and I communicate with services via REST API - POST, GET, UPDATE, DELETE etc. but in documentation from directadmin there is not any URL where I can make request. There are only Commands: CMD_ACCOUNT_RESELLER etc. I guess this is for PHP services. So how can I communicate with that API in "normal way"?

  2. #2
    Join Date
    Feb 2016
    Posts
    34
    There is no REST API for DirectAdmin, and what you see is the "normal way". It's language agnostic, and works with PHP, Ruby, .NET, and every other language that can make an HTTP request.

  3. #3
    Join Date
    May 2008
    Location
    The Netherlands
    Posts
    1,161
    Bare in mind that the DA API format was made like 14 years ago; at which time the REST format was no way the standard that it is today.

    Screenshot-2016-11-01-16.01.29.png
    Source: https://blog.readme.io/the-history-of-rest-apis/

    A very basic PHP example is this:

    PHP Code:
    <?php

    $x 
    file_get_contents('https://admin:yourpass@hostname:2222/CMD_API_SHOW_USER_USAGE?user=admin');

    $y urldecode($x);

    parse_str($y$output);

    print_r($output);

    ?>
    I just tested this; this returns an array with the info from the API.

    Note:


    So basically you need to make a simple http request, with basic authentication: https://en.wikipedia.org/wiki/Basic_...authentication

    Then you need to decode the url, and parse it. You could search for replacement functions of urldecode and parse_str for your language; usually those are easily found in any popular language.
    ~ Arieh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •