API Reference¶
Session¶
-
class
minehost.
Session
(email: str = None, password: str = None)[source]¶ Wrapper object around the requests.Session. Checks if it’s logged on every request.
-
__init__
(email: str = None, password: str = None)[source]¶ Initializes session if email and password are given.
- Parameters
email (str, optional) – If provided with password will try to login.
password (str, optional) – If provided with email will try to login.
-
isValid
() → bool[source]¶ Returns true if current session is logged in, otherwise false.
- Returns
True if logged in.
-
login
(email: str, password: str)[source]¶ Attempts to login using the given credentials.
- Parameters
email (str) – Email used to login.
password (str) – Password associated to given email.
- Raises
IncorrectLoginException – Raised on failed login.
-
request
(method, url, *args, **kvargs) → requests.models.Response[source]¶ Wrapper function around the default requests.request method. Instead of giving the whole url like “https://minehost.lt/logout” now you only need to write “/logout”.`
- Returns
requests.Response object
-
Account¶
-
class
minehost.
Account
(email: str = None, password: str = None, session: minehost.session.Session = None)[source]¶ Used to get servers, history, balance and other details associated to a specific account.
-
__init__
(email: str = None, password: str = None, session: minehost.session.Session = None)[source]¶ Initializes an account
- Parameters
email (str, optional) – email used to login, defaults to None
password (str, optional) – password used to login, defaults to None
session (
Session
, optional) – an already created session can be provided, defaults to None
- Raises
InvalidSessionException – Raised when the given custom session is invalid or when nothing was provided
-
__weakref__
¶ list of weak references to the object (if defined)
-
getBalance
() → float[source]¶ Current balance in account.
- Returns
A float representing the current balance.
-
getDetails
() → dict[source]¶ Returns a dictionary containing general details about account. Available details: email, name, surname, phone, skype.
- Returns
A dictionary with account details.
-
getFinanceHistory
(limit: int = inf) → list[source]¶ Returns a list of entries where each entry describes a transaction. Entry keys: date, action, balance_change, balance_remainder
- Parameters
limit (int, optional) – The maximum number of entries it should try getting, defaults to math.inf
- Returns
A list of entries where each entry is a dictionary.
-
getLoginHistory
(limit: int = inf) → list[source]¶ Returns a list of entries, where each entry holds the date and ip of who logged in. Entry keys: date, ip.
- Parameters
limit (int, optional) – The maximum number of entries it should try getting, defaults to math.inf
- Returns
A list of entries where each entry is a dictionary.
-
getProfileDetailsHistory
(limit: int = inf) → list[source]¶ Returns a list of entries where each entry describes what was changed and by who. Entry keys: date, name, surname, phone, skype, ip.
- Parameters
limit (int, optional) – The maximum number of entries it should try getting, defaults to math.inf
- Returns
A list of entries where each entry is a dictionary.
-
MCServer¶
-
class
minehost.
MCServer
(server_id: str, session: minehost.session.Session)[source]¶ Used to control a minehost minecraft server
-
CommandSender
() → minehost.server.CommandSender[source]¶ Creates a new CommandSender which allow you to easily send commands to the console.
- Returns
The newly created CommandSender.
-
FTP
() → ftplib.FTP[source]¶ Creates a new FTP connection to the server. The password will be automatically inputted.
- Returns
An open FTP connection
-
SSH
() → paramiko.client.SSHClient[source]¶ Creates a new SSH connection to the server. The password will be automatically inputted.
- Returns
An open SSH connection
-
__init__
(server_id: str, session: minehost.session.Session)[source]¶ Initializes minecraft server instance. Retrieves some initial data like: address, ip and port.
- Parameters
server_id (str) – [description]
session (Session) – [description]
-
__weakref__
¶ list of weak references to the object (if defined)
-
changePassword
() → bool[source]¶ Change the current password to a new randomly generated password. Passwords can only be changed every few minutes.
- Returns
Whether the change was successful
-
getExpirationDate
() → datetime.datetime[source]¶ Returns the date at which the server will expire.
- Returns
A datetime object
-
getPassword
() → str[source]¶ Retrieves the password used to login to SSH, FTP and SFTP.
- Returns
A string containing the password
-
getStats
() → dict[source]¶ Returns a dictionary containing the current statistcs of the server.
- Returns
A dictionary containing “state”, “version”, “ping”, “online_players” and “max_players”
-
kill
() → bool[source]¶ Tries killing the server. This is the same as stopping but killing dosen’t save anything.
- Returns
Whether if it succeded in killing the server.
-
CommandSender¶
-
class
minehost.server.
CommandSender
(host: str, password: str, port: int = 22)[source]¶ Used to directly send commands to a minecraft server. Rather than loggin into ssh, entering console manually.
-
close
()[source]¶ Closes channel used to send commands.
- Raises
Exception – Raised if channel is already closed
-