Skip to content

A simple C# wrapper for accessing cPanel v2 APIs

License

Notifications You must be signed in to change notification settings

zealofzebras/cPanelSharpCore

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cPanelSharp

A simple C# wrapper for accessing cPanel APIs.

Installation

Install-Package cPanelSharp

Usage

First, we declare a cPanelClient with required params.

To connect to a cPanel instance, the required parameters are:

  • username
  • hostname (will be something like *.sgcpanel.com)
  • password

also the cPanel argument needs to be set to true.

var client = new cPanelClient("<username>", "<hostname>", password: "<password>", cPanel: true);

Look up the cPanel API 2 and find the call you want to make.

Consider that you want to get the list of email accounts. You'll see Email::listpops on the title. Everything to the left of :: forms the module and everything to the right of :: forms the function. With this we get:

  • Module: Email
  • Function: listpops

Now, we can call the Api2 function with the required parameters

var response = client.Api2("Email", "listpops");

Parameters can be specified using an object. Email::listpops takes an optional regex param to search by. Lets pass that to the function in the form of an object

var response = client.Api2("Email", "listpops", new 
{
  regex = "foo"
});

Credits

All credits to https://github.com/vexxhost/python-cpanelapi

Caveats

  • Currently the API returns the json in a string format. The user is expected to define the object and deserialize using a json deserializer (json.net, Jil).
  • Only API v2 supported

About

A simple C# wrapper for accessing cPanel v2 APIs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%