atconnect#
Stores API connection session and sends requests
AternosConnect
#
Class for sending API requests bypass Cloudflare and parsing responses
atsession()
property
#
Aternos session cookie, empty string if not logged in
Returns:
Type | Description |
---|---|
str
|
Session cookie |
convert_num(num, base, frombase=10)
#
Converts an integer to specified base
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num |
Union[int, float, str]
|
Integer in any base to convert.
If it is a float starting with |
required |
base |
int
|
New base |
required |
frombase |
int
|
Given number base |
10
|
Returns:
Type | Description |
---|---|
str
|
Number converted to a specified base |
generate_aternos_rand(randlen=16)
#
Generates a random string using Aternos algorithm from main.js file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
randlen |
int
|
Random string length |
16
|
Returns:
Type | Description |
---|---|
str
|
Random string for SEC token |
generate_sec()
#
Generates Aternos SEC token which is also needed for most API requests
Returns:
Type | Description |
---|---|
str
|
Random SEC |
parse_token()
#
Parses Aternos ajax token that is needed for most requests
Raises:
Type | Description |
---|---|
RuntimeWarning
|
If the parser can not
find |
TokenError
|
If the parser is unable to extract ajax token from HTML |
Returns:
Type | Description |
---|---|
str
|
Aternos ajax token |
request_cloudflare(url, method, params=None, data=None, headers=None, reqcookies=None, sendtoken=False, retry=5)
#
Sends a request to Aternos API bypass Cloudflare
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
Request URL |
required |
method |
str
|
Request method, must be GET or POST |
required |
params |
Optional[Dict[Any, Any]]
|
URL parameters |
None
|
data |
Optional[Dict[Any, Any]]
|
POST request data, if the method is GET, this dict will be combined with params |
None
|
headers |
Optional[Dict[Any, Any]]
|
Custom headers |
None
|
reqcookies |
Optional[Dict[Any, Any]]
|
Cookies only for this request |
None
|
sendtoken |
bool
|
If the ajax and SEC token should be sent |
False
|
retry |
int
|
How many times parser must retry connection to API bypass Cloudflare |
5
|
Raises:
Type | Description |
---|---|
CloudflareError
|
When the parser has exceeded retries count |
NotImplementedError
|
When the specified method is not GET or POST |
Returns:
Type | Description |
---|---|
requests.Response
|
API response |