This repository was archived by the owner on Jul 30, 2024. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork5
An API client for MyOwnFreeHost in Python
License
NotificationsYou must be signed in to change notification settings
Wallvon/mofh
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An API wrapper forMyOwnFreeHost.
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:
importmofh# With a context managerwithmofh.Client(username="example",password="password")asclient:response=client.create(username='example',password='password',contactemail='example@example.com',domain='subdomain.example.com',plan='MyAwesomePlan')print(response)# ---# Without a context managerclient=mofh.Client(username="example",password="password")response=client.create(username='example',password='password',contactemail='example@example.com',domain='subdomain.example.com',plan='MyAwesomePlan')print(response)client.close()
Async:
importmofh# With a context managerasyncwithmofh.AsyncClient(username="example",password="password")asclient:response=awaitclient.create(username='example',password='password',contactemail='example@example.com',domain='subdomain.example.com',plan='MyAwesomePlan')print(response)# ---# Without a context managerclient=mofh.AsyncClient(username="example",password="password")response=awaitclient.create(username='example',password='password',contactemail='example@example.com',domain='subdomain.example.com',plan='MyAwesomePlan')print(response)awaitclient.close()
It is possible to use custom requests or aiohttp session with configured timeouts and other settings.
Sync:
importmofhfromrequestsimportSessionclient=mofh.Client(username="example",password="password",session=Session())
Async:
importmofhfromaiohttpimportClientSession,ClientTimeoutclient=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:
importmofhclient=mofh.Client(username="example",password="password",api_url="https://panel.myownfreehost.net/xml-api/")