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.

logout()[source]

The session becomes invalid and will raise error if tried to request anything.

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

__repr__()[source]

Return repr(self).

__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.

getServer(i: int = 0) → minehost.server.MCServer[source]

Helper method get a server quickly. Most people will only want to interact with 1 server.

Parameters

i (int, optional) – Index of server (0 indexed), defaults to 0

Returns

A MCServer

getServers() → list[source]

Returns a list of minecraft server objects.

Returns

List of MCServer

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]

__repr__()[source]

Return repr(self).

__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.

start() → bool[source]

Tries starting the server.

Returns

Whether if it succeded in starting the server.

stop() → bool[source]

Tries stopping the server.

Returns

Whether if it succeded in stopping 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

open()[source]

Opens a channel used to send commands.

Raises

Exception – Raised if channel is already open

send(*args)[source]

Send commands to the server. You are able to send to multiple commands by giving multiple arguments.

Parameters

*args (str) – Commands you would like the server to execute.

Raises

Exception – Raised if channel is not open

Exceptions

class minehost.server.InvalidDomainException[source]

Raised when trying to change a server address with an unsupported domain.

class minehost.session.IncorrectLoginException[source]

Raised when the given email and passwords are incorrect.

class minehost.session.InvalidSessionException[source]

Raised when the current session is logged out or timed out.