Introduction
Welcome to the MyOwnFreeHost (MOFH) API Docs! You can use our API documentation to learn how the MOFH API works.
There are examples in cURL and Python, but if you know any other coding language and are willing to contribute please consider making a pull request on the GitHub repository. You can view code examples in the dark area to the right, and you can switch the coding language of the examples with the tabs in the top right.
Other MOFH API wrappers:
mofh-client (PHP)
mofh (Python)
mofh-client-js (JS)
mofh-client (JS)
Some other side-notes:
- You can create up to 3 accounts per email with the MOFH API.
- The MOFH API is pretty limited, so you can't really do more than what is listed here.
- The SSL certificate on
https://panel.myownfreehost.net:2087/xml-api/
tends to expire, so you may need to turn off SSL verification.
Authentication
To authorize, use this code:
curl -X POST -u username:password "https://panel.myownfreehost.net:2087/xml-api/"
import requests
url = "https://panel.myownfreehost.net:2087/xml-api/" # This is the base URL
data = {}
response = requests.post(url, params=data, auth=('username' 'password'), verify=False)
Make sure to replace 'username' and 'password' with your API credentials.
MOFH uses API credentials to allow access to the API, you can get them here.
MOFH expects the API credentials to be included in all API requests to the server.
API - Accounts
Create account
curl -X POST -u username:password -d "username=example&password=password&contactemail=example@example.com&domain=subdomain.example.com&plan=MyAwesomePlan" "https://panel.myownfreehost.net:2087/xml-api/createacct.php"
import requests
from requests.auth import HTTPBasicAuth
# from xml.etree.ElementTree import fromstring, ElementTree - Do this if you want to only get the username.
url = "https://panel.myownfreehost.net:2087/xml-api/createacct.php"
data = {'username': 'example', 'password': 'password', 'contactemail': 'example@example.com', 'domain': 'subdomain.example.com', 'plan': 'MyAwesomePlan'} # If you want to use a domain which is not a subdomain, put that domain in.
response = requests.post(url, params=data, auth=HTTPBasicAuth('username', 'password'))
print(response.text)
# tree = ElementTree(fromstring(response.content)) - Do this if you want to only get the username.
# root = tree.getroot() - Do this if you want to only get the username.
# for child in root: - Do this if you want to only get the username.
# print(child[0][1].text) # The vPanel and FTP username - Do this if you want to only get the username.
The above command returns XML structured like this:
<createacct>
<result>
<options>
<ip>n</ip>
<vpusername>hname_12345678</vpusername>
<nameserver>ns1.byet.org</nameserver>
<nameserver2>ns2.byet.org</nameserver2>
<nameserver3/>
<nameserver4/>
<nameservera/>
<nameservera2/>
<nameservera3/>
<nameservera4/>
<nameserverentry/>
<nameserverentry2/>
<nameserverentry3/>
<nameserverentry4/>
<package></package>
</options>
<rawout>
account added to queue to be added
</rawout>
<status>1</status>
<statusmsg>This account has been successfuly created</statusmsg>
</result>
</createacct>
This endpoint creates a new user account with the provided information.
HTTP Request
POST https://panel.myownfreehost.net:2087/xml-api/createacct.php
Suspend account
curl -X POST -u username:password -d "user=example&reason=My beautiful reason." "https://panel.myownfreehost.net:2087/xml-api/suspendacct.php"
import requests
from requests.auth import HTTPBasicAuth
# from xml.etree.ElementTree import fromstring, ElementTree - Do this if you want to only get the status code.
url = "https://panel.myownfreehost.net:2087/xml-api/suspendacct.php"
data = {'user': 'username', 'reason': 'My beautiful reason.'} # For the username, use the same username you set when creating the account.
response = requests.post(url, params=data, auth=HTTPBasicAuth('username', 'password'))
print(response.text)
# tree = ElementTree(fromstring(response.content)) - Do this if you want to only get the status code.
# root = tree.getroot() - Do this if you want to only get the status code.
# for child in root: - Do this if you want to only get the status code.
# print(child[0].text) # The status code (can either be 0 or 1) - Do this if you want to only get the status code.
The above command returns XML structured like this:
<suspendacct>
<result>
<status>1</status>
<statusmsg>
<script>if (self['clear_ui_status']) { clear_ui_status(); }</script>
Changing Shell to /bin/false...Changing shell for username.
Shell changed.
Locking Password...Locking password for user username.
marking user vhosts / databases for suspension.
..
..
Completed, this account will be fully suspended in 2 minutes.
</statusmsg>
</result>
</suspendacct>
This endpoint suspends a user account with the provided information.
HTTP Request
POST https://panel.myownfreehost.net:2087/xml-api/suspendacct.php
Unsuspend account
curl -X POST -u username:password -d "user=username" "https://panel.myownfreehost.net:2087/xml-api/unsuspendacct.php"
import requests
from requests.auth import HTTPBasicAuth
# from xml.etree.ElementTree import fromstring, ElementTree - Do this if you want to only get the status code.
url = "https://panel.myownfreehost.net:2087/xml-api/unsuspendacct.php"
data = {'user': 'username'} # For the username, use the same username you set when creating the account.
response = requests.post(url, params=data, auth=HTTPBasicAuth('username', 'password'))
print(response.text)
# tree = ElementTree(fromstring(response.content)) - Do this if you want to only get the status code.
# root = tree.getroot() - Do this if you want to only get the status code.
# for child in root: - Do this if you want to only get the status code.
# print(child[0].text) # The status code (can either be 0 or 1) - Do this if you want to only get the status code.
The above command returns XML structured like this:
<unsuspendacct>
<result>
<status>1</status>
<statusmsg>
<script>if (self['clear_ui_status']) { clear_ui_status(); }</script>
username account has been unsuspended
</statusmsg>
</result>
</unsuspendacct>
This endpoint unsuspends a user account with the provided information.
HTTP Request
POST https://panel.myownfreehost.net:2087/xml-api/unsuspendacct.php
Change password
curl -X POST -u username:password -d "user=username&pass=password" "https://panel.myownfreehost.net:2087/xml-api/passwd.php"
import requests
from requests.auth import HTTPBasicAuth
# from xml.etree.ElementTree import fromstring, ElementTree - Do this if you want to only get the status code.
url = "https://panel.myownfreehost.net:2087/xml-api/passwd.php"
data = {'user': 'username', 'pass': 'password'} # For the username, use the same username you set when creating the account.
response = requests.post(url, params=data, auth=HTTPBasicAuth('username', 'password'))
print(response.text)
# tree = ElementTree(fromstring(response.content)) - Do this if you want to only get the status code.
# root = tree.getroot() - Do this if you want to only get the status code.
# for child in root: - Do this if you want to only get the status code.
# print(child[5].text) # The status code (can either be 0 or 1) - Do this if you want to only get the status code.
The above command returns XML structured like this:
<passwd>
<passwd>
<rawout>
Changing password for username
Password for username has been changed
Updating ftp passwords for username
Ftp password files updated.
Ftp vhost passwords synced
</rawout>
<services>
<app>system</app>
</services>
<services>
<app>ftp</app>
</services>
<services>
<app>mail</app>
</services>
<services>
<app>mySQL</app>
</services>
<status>1</status>
<statusmsg>Password changed for user username</statusmsg>
</passwd>
</passwd>
This endpoint changes the password of a user account with the provided information.
HTTP Request
POST https://panel.myownfreehost.net:2087/xml-api/passwd.php
API - Domains
Check if a domain is available
curl -X POST -u username:password -d "api_user=username&api_key=password&domain=subdomain.example.com" "https://panel.myownfreehost.net:2087/xml-api/checkavailable.php"
import requests
from requests.auth import HTTPBasicAuth
url = "https://panel.myownfreehost.net:2087/xml-api/checkavailable.php"
data = {'api_user': 'username', 'api_key': 'password', 'domain': 'subdomain.example.com'} # If you want to use a domain which is not a subdomain, put that domain in.
response = requests.post(url, params=data, auth=HTTPBasicAuth('username', 'password'))
print(response.text) # Returns the status code, either 0 or 1.
The above command returns XML structured like this:
1
This endpoint checks if the requested domain name is available.
HTTP Request
POST https://panel.myownfreehost.net:2087/xml-api/checkavailable.php
Get a user's domains
curl -X POST -u username:password -d "api_user=username&api_key=password&username=hname_12345678" "https://panel.myownfreehost.net:2087/xml-api/getuserdomains.php"
import requests
from requests.auth import HTTPBasicAuth
url = "https://panel.myownfreehost.net:2087/xml-api/getuserdomains.php"
data = {'api_user': 'username', 'api_key': 'password', 'username': 'hname_12345678'}
response = requests.post(url, params=data, auth=HTTPBasicAuth('username', 'password'))
print(response.text)
The above command returns a list/array structured like this:
[["ACTIVE","subdomain.example.com"]]
This endpoint gets the domains connected to a user's account.
HTTP Request
POST https://panel.myownfreehost.net:2087/xml-api/getuserdomains.php
Get a user by a domain
curl -X POST -u username:password -d "api_user=username&api_key=password&domain=subdomain.example.com" "https://panel.myownfreehost.net:2087/xml-api/getdomainuser.php"
import requests
from requests.auth import HTTPBasicAuth
url = "https://panel.myownfreehost.net:2087/xml-api/getdomainuser.php"
data = {'api_user': 'username', 'api_key': 'password', 'domain': 'subdomain.example.com'}
response = requests.post(url, params=data, auth=HTTPBasicAuth('username', 'password'))
print(response.text)
The above command returns a list/array structured like this:
["ACTIVE","subdomain.example.com","\/home\/vol15_2\/example.com\/hname_12345678\/htdocs","hname_12345678"]
This endpoint gets a user which has the requested domain connected to their account.
HTTP Request
POST https://panel.myownfreehost.net:2087/xml-api/getdomainuser.php
Errors
The MOFH API doesn't use any error codes, and will always return a 200 HTTP code.
You would have to get the text inside the <status></status>
tags to get the status of your request (either 0
or 1
). Or if you try to use the getuserdomains.php
and getdomainuser.php
endpoints you will see that it just returns null
instead of the list/array it usually gives.