CloudPanel API is organized around REST. Our API is designed so anything that the CloudPanel web portal can do, you can do yourself with your own code.
The CloudPanel API is secured by using an API key, user permissions, and IP addresses. Each API key is tied to a user in CloudPanel and locked down so the key can only be used by specific IP Addresses. Since the API is bound to a user in the CloudPanel database, it will inherit the same permissions as if the user were to log into the CloudPanel portal.
The API key must be passed as a query parameter for all requests.
using RestSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudPanel.Demo.Api.Client
{
// This is the class you bind to your request using
// RestSharp. This example returns a list of users which
// sends back integer values draw, recordsTotal, recordsFiltered
// (which are jQuery DataTables values) and a list of user
// objects in value 'data'
public class Users
{
public int draw { get; set; }
public int recordsTotal { get; set; }
public int recordsFiltered { get; set; }
public List<UserObject> data { get; set; }
}
// Class containing SOME of the values returned by
// CloudPanel. All values not shown in example.
public class UserObject
{
public Guid UserGuid { get; set; }
public string CompanyCode { get; set; }
public string DisplayName { get; set; }
}
class Program
{
const string BaseUrl = "http://server/CloudPanel";
static string ApiKey = "Af4tA4];%d)!Q7`geQ6V71";
static void Main(string[] args)
{
GetUsers();
Console.ReadKey();
}
static void GetUsers()
{
var client = new RestClient(BaseUrl);
var request = new RestRequest("company/COM2/users", Method.GET);
request.AddQueryParameter("ApiKey", ApiKey); // API Key can be form or query value
var response = client.Execute<Users>(request);
foreach (var u in response.Data.data)
{
Console.WriteLine(u.DisplayName);
}
}
}
}
For user specific queries, please visit: /api/users