DreamHost API

If you want to learn how to use the DreamHost API then you have come to the right place. Before we start, you need to learn what API is and how one can use API.

API is a short form of Application Programming Interface. API is used to communicate between programs. Let’s understand it in details.

Let’s take an example of DreamHost API itself. DreamHost offers API facility to the developers to access the DreamHost account details. Let’s assume that you are making a website and you want to display all your domains hosted at DreamHost. In normal situation, you will just write down a list of all the domains hosted at your DreamHost account. This is very simple but what if you add or remove a domain from your DreamHost account. You will have to change your hosted domains list on the site every time you add or remove the domain.

You can get rid of editing problem if you use the DreamHost API to display a list of domains hosted in your account. When you use the DreamHost API to display the list of domains hosted with your DreamHost account, your list is generated dynamically in real time displaying only domain hosted at that time. The code on your webpage is not using API to display a list of domains hosted in your DreamHost account. In other words, your webserver program communicates to DreamHost server using API.

I assume that you have fully understand what API is.

How To Use DreamHost API?

You can very easily use DreamHost API in your programs. All you need to do is visit a DreamHost API URL and DreamHost will return the result in tab-delimited plain text. I would suggest you to first use web browser to check the DreamHost API URL. If your API URL is correct then you should see a tab-delimited text on your web page. Now you can use the same URL in your program and read the result.

What You Need?

For accessing the DreamHost API, you need to make API URL. For making the URL, you need two parameters, key & cmd. Key is unique identifier for DreamHost. From the key only, DreamHost will understand that the API data is requested for which account. Cmd is a operation name which you want to person on your DreamHost account.

Don’t make your key public or you can put your DreamHost account at a risk. I would suggest you to create different key for different operation. That way you are reducing the risk of your account. You can create a key at https://panel.dreamhost.com/index.cgi?tree=home.api& .

DreamHost API

While creating a key, select only those functions which you want to use. Don’t select all the function and do not make single key for all your functions.

How to Create DreamHost API URL?

To use DreamHost API, you need to create the API URL. You will use the URL https://api.dreamhost.com/ to make API URL. In this URL, you need to append two variables. The final URL will look like the following.


The value of cmd is a function name which you want to use through API. You can get the values of cmd variable from DreamHost API wiki at http://wiki.dreamhost.com/API .

You may need to append more variables and assign values to those variables in making API url. The extra variables you need are depend upon the function you have selected. If you select the function to display domains list hosted at your DreamHost account then you don’t need any extra variable but if you select the function to list subscribers in your announcement list then you need to append two variables. One is for domain name and another is for list name. All these variables are case-sensitive. So make sure you have used correct variables. The final URL for listing subscriber will look like following.


You can get more information about variable names from DreamHost wiki.

Which Functions Available In DreamHost API?

You may not access all the functions of DreamHost panel using API but still you can access most of them. You can get a full list of function from web panel API section.

DreamHost currently offers 76 functions through API. Here is a current list of all functions available through API.

  • account-domain_usage
  • account-list_accounts
  • account-list_keys
  • account-status
  • account-user_usage
  • announcement_list-add_subscriber
  • announcement_list-list_lists
  • announcement_list-list_subscribers
  • announcement_list-post_announcement
  • announcement_list-remove_subscriber
  • dns-add_record
  • dns-list_records
  • dns-remove_record
  • domain-list_certificates
  • domain-list_domains
  • domain-list_registrations
  • domain-registration_available
  • dreamhost_ps-add_key
  • dreamhost_ps-add_ps
  • dreamhost_ps-list_images
  • dreamhost_ps-list_keys
  • dreamhost_ps-list_pending_ps
  • dreamhost_ps-list_ps
  • dreamhost_ps-list_reboot_history
  • dreamhost_ps-list_settings
  • dreamhost_ps-list_size_history
  • dreamhost_ps-list_usage
  • dreamhost_ps-reboot
  • dreamhost_ps-remove_key
  • dreamhost_ps-remove_pending_ps
  • dreamhost_ps-remove_ps
  • dreamhost_ps-set_settings
  • dreamhost_ps-set_size
  • jabber-add_user
  • jabber-deactivate_user
  • jabber-list_users
  • jabber-list_users_no_pw
  • jabber-list_valid_domains
  • jabber-reactivate_user
  • jabber-remove_user
  • mail-add_filter
  • mail-list_filters
  • mail-remove_filter
  • mysql-add_hostname
  • mysql-add_user
  • mysql-list_dbs
  • mysql-list_hostnames
  • mysql-list_users
  • mysql-remove_hostname
  • mysql-remove_user
  • oneclick-catalog
  • oneclick-describe_app
  • oneclick-destroy_custom
  • oneclick-destroy_simple
  • oneclick-install_custom
  • oneclick-install_simple
  • oneclick-list_custom
  • oneclick-list_settings
  • oneclick-list_simple
  • oneclick-set_settings
  • oneclick-update
  • oneclick-update_all
  • rewards-add_promo_code
  • rewards-disable_promo_code
  • rewards-enable_promo_code
  • rewards-list_promo_codes
  • rewards-promo_details
  • rewards-referral_log
  • rewards-referral_summary
  • rewards-remove_promo_code
  • services-flvencoder
  • services-progress
  • user-add_user
  • user-list_users
  • user-list_users_no_pw
  • user-remove_user

PHP Example of DreamHost API

If you look at the DreamHost API Wiki, you will get an example on how to use API. The example is in bash script. Here I am going to show you how to use DreamHost API using php. For the demo purpose, we will use the above URL which displays the subscribers detail for a given listname.  Following is a PHP code.

// Use your API url
$url = 'https://api.dreamhost.com/?key=6SHU5P2HLDAYECUM&cmd=announcement_list-list_subscribers&listname=dumb&domain=filesforever.com&format=html';

$curl = curl_init ()
or die ('curl_init() failed');
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($curl, CURLOPT_TIMEOUT, 5);
curl_setopt ($curl, CURLOPT_URL, $url);
$data = curl_exec ($curl);
curl_close ($curl);

echo $data;

In this example, we are using curl library to browse the API url. Return data from DreamHost API is saved in $data variable. You can use this variable to perform the operations.

DreamHost API Applications

If you are looking to perform some specific operation on DreamHost account using API then I suggest you to first look at DreamHost API Apps. It might happen that somebody has already made your required application.

I hope you enjoy reading article on DreamHost API.