Pirate

Source code in APIrate/seaofthieves.py
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
class Pirate:

    def __init__(self, api_key,):
        if api_key is None:
            # TODO write docs for getting RAT cookie
            raise APIKeyMissingError(
                "RAT Cookie is required. See https://github.com/Kumariz0/APIrate/wiki for how to retrieve an authentication token from Sea of Thieves.")
        self.session = session
        self.api_key_cookie = {'rat': api_key}
        self.headers = {'Referer': 'https://www.seaofthieves.com/'}

    def get_profilev2(self, endpoint):
        """Gets data from the sea of thieves api server about your own pirate.

        Args:
            endpoint (string): The endpoint, of where you want to get data from. Allowed endpoints are: reputation, balance, status, captaincy, adventures, chest, achievements, overview

        Raises:
            InvalidEndpointError: Invalid endpoint

        Returns:
            dict (dict): A dict with the information gathered from the endpoint.
        """
        ALLOWED_ENDPOINTS = [
            "reputation",
            "balance",
            "status",
            "captaincy",
            "adventures",
            "chest",
            "achievements",
            "overview"
        ]
        BASE_URL = "https://www.seaofthieves.com/api/profilev2"
        if endpoint not in ALLOWED_ENDPOINTS:
            raise InvalidEndpointError(
                "Invalid endpoint. Allowed endpoints are: " + ', '.join(ALLOWED_ENDPOINTS))

        url = f"{BASE_URL}/{endpoint}"
        response = session.get(url, headers=self.headers,
                               cookies=self.api_key_cookie,)
        return response.json()

    def get_user(self, endpoint):
        """Gets data from the sea of thieves api server about your friends.

        Args:
            endpoint (string): The endpoint, of where you want to get data from. Allowed endpoints are: get-suggested-friend, playing, get-recent-friends

        Raises:
            InvalidEndpointError: Invalid endpoint

        Returns:
            dict (dict): A dict with the information gathered from the endpoint.
        """
        ALLOWED_ENDPOINTS_USER = [
            "get-suggested-friend",
            "playing",
            "get-recent-friends",
        ]
        BASE_URL = "https://www.seaofthieves.com/api/user"
        if endpoint not in ALLOWED_ENDPOINTS_USER:
            raise InvalidEndpointError(
                "Invalid endpoint. Allowed endpoints are: " + ', '.join(ALLOWED_ENDPOINTS_USER))

        url = f"{BASE_URL}/{endpoint}"
        response = session.get(url, headers=self.headers,
                               cookies=self.api_key_cookie,)
        return response.json()

    def get_ledger(self, endpoint):
        """Gets data from the sea of thieves api server about the global ledger.

        Args:
            endpoint (string): the endpoint, of where you want to get data from. Allowed endpoint are: GoldHoarders, OrderOfSouls, AthenasFortune, MerchantAlliance, ReapersBones

        Raises:
            InvalidEndpointError: Invalid endpoint

        Returns:
            dict (dict): A dict with the information gathered from the endpoint.
        """
        ALLOWED_ENDPOINTS = [
            "GoldHoarders",
            "OrderOfSouls",
            "AthenasFortune",
            "MerchantAlliance",
            "ReapersBones"
        ]

        BASE_URL = "https://www.seaofthieves.com/api/ledger/global/"
        if endpoint not in ALLOWED_ENDPOINTS:
            raise InvalidEndpointError(
                "Invalid endpoint. Allowed endpoints are: " + ', '.join(ALLOWED_ENDPOINTS))

        url = f"{BASE_URL}/{endpoint}"
        response = session.get(url, headers=self.headers,
                               cookies=self.api_key_cookie,)
        return response.json()

get_ledger(endpoint)

Gets data from the sea of thieves api server about the global ledger.

Parameters:
  • endpoint (string) –

    the endpoint, of where you want to get data from. Allowed endpoint are: GoldHoarders, OrderOfSouls, AthenasFortune, MerchantAlliance, ReapersBones

Raises:
  • InvalidEndpointError

    Invalid endpoint

Returns:
  • dict( dict ) –

    A dict with the information gathered from the endpoint.

Source code in APIrate/seaofthieves.py
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
def get_ledger(self, endpoint):
    """Gets data from the sea of thieves api server about the global ledger.

    Args:
        endpoint (string): the endpoint, of where you want to get data from. Allowed endpoint are: GoldHoarders, OrderOfSouls, AthenasFortune, MerchantAlliance, ReapersBones

    Raises:
        InvalidEndpointError: Invalid endpoint

    Returns:
        dict (dict): A dict with the information gathered from the endpoint.
    """
    ALLOWED_ENDPOINTS = [
        "GoldHoarders",
        "OrderOfSouls",
        "AthenasFortune",
        "MerchantAlliance",
        "ReapersBones"
    ]

    BASE_URL = "https://www.seaofthieves.com/api/ledger/global/"
    if endpoint not in ALLOWED_ENDPOINTS:
        raise InvalidEndpointError(
            "Invalid endpoint. Allowed endpoints are: " + ', '.join(ALLOWED_ENDPOINTS))

    url = f"{BASE_URL}/{endpoint}"
    response = session.get(url, headers=self.headers,
                           cookies=self.api_key_cookie,)
    return response.json()

get_profilev2(endpoint)

Gets data from the sea of thieves api server about your own pirate.

Parameters:
  • endpoint (string) –

    The endpoint, of where you want to get data from. Allowed endpoints are: reputation, balance, status, captaincy, adventures, chest, achievements, overview

Raises:
  • InvalidEndpointError

    Invalid endpoint

Returns:
  • dict( dict ) –

    A dict with the information gathered from the endpoint.

Source code in APIrate/seaofthieves.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def get_profilev2(self, endpoint):
    """Gets data from the sea of thieves api server about your own pirate.

    Args:
        endpoint (string): The endpoint, of where you want to get data from. Allowed endpoints are: reputation, balance, status, captaincy, adventures, chest, achievements, overview

    Raises:
        InvalidEndpointError: Invalid endpoint

    Returns:
        dict (dict): A dict with the information gathered from the endpoint.
    """
    ALLOWED_ENDPOINTS = [
        "reputation",
        "balance",
        "status",
        "captaincy",
        "adventures",
        "chest",
        "achievements",
        "overview"
    ]
    BASE_URL = "https://www.seaofthieves.com/api/profilev2"
    if endpoint not in ALLOWED_ENDPOINTS:
        raise InvalidEndpointError(
            "Invalid endpoint. Allowed endpoints are: " + ', '.join(ALLOWED_ENDPOINTS))

    url = f"{BASE_URL}/{endpoint}"
    response = session.get(url, headers=self.headers,
                           cookies=self.api_key_cookie,)
    return response.json()

get_user(endpoint)

Gets data from the sea of thieves api server about your friends.

Parameters:
  • endpoint (string) –

    The endpoint, of where you want to get data from. Allowed endpoints are: get-suggested-friend, playing, get-recent-friends

Raises:
  • InvalidEndpointError

    Invalid endpoint

Returns:
  • dict( dict ) –

    A dict with the information gathered from the endpoint.

Source code in APIrate/seaofthieves.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def get_user(self, endpoint):
    """Gets data from the sea of thieves api server about your friends.

    Args:
        endpoint (string): The endpoint, of where you want to get data from. Allowed endpoints are: get-suggested-friend, playing, get-recent-friends

    Raises:
        InvalidEndpointError: Invalid endpoint

    Returns:
        dict (dict): A dict with the information gathered from the endpoint.
    """
    ALLOWED_ENDPOINTS_USER = [
        "get-suggested-friend",
        "playing",
        "get-recent-friends",
    ]
    BASE_URL = "https://www.seaofthieves.com/api/user"
    if endpoint not in ALLOWED_ENDPOINTS_USER:
        raise InvalidEndpointError(
            "Invalid endpoint. Allowed endpoints are: " + ', '.join(ALLOWED_ENDPOINTS_USER))

    url = f"{BASE_URL}/{endpoint}"
    response = session.get(url, headers=self.headers,
                           cookies=self.api_key_cookie,)
    return response.json()