An API wrapper for MyOwnFreeHost.
To install from PyPi run
pip install mofh
mofh uses the following versioning pattern:
major.minor.patch
- Major: Breaking changes, the bot is no longer compatible with previous versions.
- Minor: New features, no breaking changes.
- Patch: Bug fixes and small improvements.
Sync:
import mofh
# With a context manager
with mofh.Client(username="example", password="password") as client:
response = client.create(username='example', password='password', contactemail='[email protected]',
domain='subdomain.example.com', plan='MyAwesomePlan')
print(response)
# ---
# Without a context manager
client = mofh.Client(username="example", password="password")
response = client.create(username='example', password='password', contactemail='[email protected]',
domain='subdomain.example.com', plan='MyAwesomePlan')
print(response)
client.close()
Async:
import mofh
# With a context manager
async with mofh.AsyncClient(username="example", password="password") as client:
response = await client.create(username='example', password='password', contactemail='[email protected]',
domain='subdomain.example.com', plan='MyAwesomePlan')
print(response)
# ---
# Without a context manager
client = mofh.AsyncClient(username="example", password="password")
response = await client.create(username='example', password='password', contactemail='[email protected]',
domain='subdomain.example.com', plan='MyAwesomePlan')
print(response)
await client.close()
It is possible to use custom requests or aiohttp session with configured timeouts and other settings.
Sync:
import mofh
from requests import Session
client = mofh.Client(username="example", password="password", session=Session())
Async:
import mofh
from aiohttp import ClientSession, ClientTimeout
client = mofh.AsyncClient(username="example", password="password", session=ClientSession(timeout=ClientTimeout))
In case URL gets changed for some reason it is possible to overwrite the API URL:
import mofh
client = mofh.Client(username="example", password="password", api_url="https://panel.myownfreehost.net/xml-api/")