WHMCSpy reference

API

class whmcspy.api.WHMCS(url, identifier, secret)[source]

Bases: object

WHMCS interface.

accept_order(order_id, **params)[source]

Accept an order.

Parameters:
  • order_id (int) – The id of the order to accept.
  • **params – Additional params.

Hint

For additional params, see the official API docs: https://developers.whmcs.com/api-reference/acceptorder/

add_client(firstname, lastname, email, address1, city, state, postcode, country, phonenumber, password2, **params)[source]

Add client.

Parameters:
  • firstname (str) – The client’s firstname.
  • lastname (str) – The client’s lastname.
  • email (str) – The client’s email address.
  • address1 (str) – The client’s address.
  • city (str) – The client’s city.
  • state (str) – The client’s state.
  • postcode (str) – The client’s postcode.
  • country (str) – 2 character ISO country code.
  • phonenumber (str) – The client’s phone number.
  • password2 (str) – The client’s password.
  • **params – Additional params.
Returns:

The id of the created client.

Return type:

int

Hint

For additional params, see the official API docs: https://developers.whmcs.com/api-reference/addclient/

add_order(clientid, domains=None, paymentmethod='banktransfer', products=None, **params)[source]

Add an order.

Parameters:
  • clientid (int) – The id of the client whom the order is for.
  • **params – Additional params.
Keyword Arguments:
 
  • domains (list) – A list of domains to include in the order.
  • paymentmethod (str) – The payment method for the order.
  • products – A list of products (dict) with an id and a domain name (pid, domain).
Returns:

The response of the successfully created order.

Hint

For additional params, see the official API docs: https://developers.whmcs.com/api-reference/addorder/

add_product(name, gid, **params)[source]

Add product.

Parameters:
  • name (str) – The name of the product.
  • gid (int) – The id of the group to add the product to.
  • **params – Additional params.
Returns:

The id of the created product (pid).

Return type:

int

Hint

For additional params, see the official API docs: https://developers.whmcs.com/api-reference/addproduct/

add_transaction(paymentmethod, **params)[source]

Add a transaction.

Parameters:
  • paymentmethod (str) – The payment method used to perform the
  • transaction.
  • **params – Additional params.

Hint

For additional params, see the official API docs: https://developers.whmcs.com/api-reference/addtransaction/

call(action, **params)[source]

Call the WHMCS api.

This is an abstract way to call the WHMCS API. Basically only the action and additional params are required to make a call.

Parameters:
  • action (str) – The action to perform.
  • **params – Additional params.
Returns:

The result of the call.

Return type:

dict

Raises:
  • MissingPermission – When access is denied due to a missing permission.
  • Error – Whenever the call fails.
cancel_order(orderid, **params)[source]

Cancel a pending order.

Parameters:
  • orderid (int) – The id of the order.
  • **params – Additional params.

Hint

For additional params, see the official API docs: https://developers.whmcs.com/api-reference/cancelorder/

delete_order(orderid, **params)[source]

Delete a cancelled or fraud order.

Parameters:orderid (int) – The id of the order.
get_clients_domains(active=None, **params)[source]

Get domains (registrations).

Parameters:**params – Additional params.
Keyword Arguments:
 active (bool) – Filter on active or inactive domains.
Yields:The domains.

Hint

For additional params, see the official API docs: https://developers.whmcs.com/api-reference/getclientsdomains/

get_clients_products(active=None, productid=None, **params)[source]

Get client products.

Parameters:

**params – Additional params.

Keyword Arguments:
 
  • active (bool) – Filter on active or inactive domains.
  • productid (int) – Only get products with this product id.
Yields:

The products.

Hint

For additional params, see the official API docs: https://developers.whmcs.com/api-reference/getclientsproducts/

get_invoice(invoiceid)[source]

Get an invoice.

Parameters:invoiceid (int) – The id of the invoice.
Returns:The invoice
get_orders(**params)[source]

Get orders.

Parameters:**params – Additional params.
Yields:The matching orders.

Hint

For additional params, see the official API docs: https://developers.whmcs.com/api-reference/getorders/

get_servers(**params)[source]

Get servers configured in WHMCS.

Parameters:**params – Additional params.

Hint

For additional params, see the official API docs: https://developers.whmcs.com/api-reference/getservers/

get_tickets(**params)[source]

Get support tickets.

Parameters:**params – Additional params.
Yields:The tickets.

Hint

For additional params, see the official API docs: https://developers.whmcs.com/api-reference/gettickets/

get_tld_pricing()[source]

Get the TLD pricing.

Returns:The TLD pricing info.
Return type:dict
get_transactions(**params)[source]

Get (find) transactions.

Parameters:**params – Additional params.
Returns:A list of matching transactions.

Hint

For additional params, see the official API docs: https://developers.whmcs.com/api-reference/gettransactions/

module_create(serviceid)[source]

Run the module create action for a service.

Parameters:serviceid (int) – The id of the service.
open_ticket(deptid, subject, message, **params)[source]

Open a support ticket

Parameters:
  • deptid (int) – The id of the department to open the ticket for.
  • subject (str) – The subject of the ticket.
  • message (str) – The initial message of the ticket.
  • **params – Additional params.

Hint

For additional params, see the official API docs: https://developers.whmcs.com/api-reference/openticket/

Note

Markdown doesn’t seem to work when opening a ticket by using the API. Maybe it’s fixed in later versions of WHMCS. Consider it unstable.

paginated_call(action, limitstart=0, **params)[source]

Perform a WHMCS API call, but paginated.

Instead of returning just a single result a result is yielded for every iteration until an empty result returns from WHMCS. See call() for common params.

Keyword Arguments:
 limitstart (int) – The offset from which to start. Initially this is 0.
Yields:An API response.
pending_order(orderid, **params)[source]

Set an order and it’s items to Pending.

Parameters:orderid (int) – The id of the order.
send_email(**params)[source]

Send a client email notification.

Parameters:**params – Additional params.

Hint

For additional params, see the official API docs: https://developers.whmcs.com/api-reference/sendemail/

update_client_domain(domain, **params)[source]

Update a client’s domain registration.

Parameters:
  • domain (dict) – The domain to update.
  • **params – Additional params.

Hint

For additional params, see the official API docs: https://developers.whmcs.com/api-reference/updateclientdomain/

update_client_product(productid, **params)[source]

Update a client’s product.

Parameters:
  • productid (int) – The id of the client product.
  • **params – Additional params.

Hint

For additional params, see the official API docs: https://developers.whmcs.com/api-reference/updateclientproduct/

Exceptions

exception whmcspy.exceptions.Error[source]

Bases: Exception

An unspecified error.

exception whmcspy.exceptions.MissingPermission[source]

Bases: whmcspy.exceptions.Error

Missing permission when calling the API.