Client
Client
Source code in src/rated/client.py
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
__init__(api_key, network)
Initialize a client instance with an API key and a network
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_key |
str
|
Rated API key |
required |
network |
str
|
Supported network |
required |
Source code in src/rated/client.py
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 |
|
get(*args, **kwargs)
Make a GET request to the Rated API
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Positional arguments |
()
|
|
**kwargs |
Keyword arguments |
{}
|
Returns:
Type | Description |
---|---|
Any
|
JSON data from the response |
Source code in src/rated/client.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
post(*args, **kwargs)
Make a POST request to the Rated API
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Positional arguments |
()
|
|
**kwargs |
Keyword arguments |
{}
|
Returns:
Type | Description |
---|---|
Response
|
Response |
Source code in src/rated/client.py
95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
yield_paginated_results(url, *, params=None, cls=None, follow_next=False)
Yield all results of a paginated response from the Rated API
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
The URL of the desired resource |
required |
params |
dict | None
|
Query parameters for the request |
None
|
cls |
Type | None
|
Dataclass to be used to instantiate the new Python object |
None
|
follow_next |
bool
|
Follow next page if any and fetch its results |
False
|
Returns:
Type | Description |
---|---|
Iterator
|
An iterator over the results of the page |
Source code in src/rated/client.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
json_to_instance(json_, cls)
Converts a camelCased JSON to a Python object instance
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_ |
Dict
|
The JSON data to convert |
required |
cls |
Type
|
Dataclass to be used to instantiate the new Python object |
required |
Returns:
Type | Description |
---|---|
Any
|
An instance of the given class |
Source code in src/rated/client.py
148 149 150 151 152 153 154 155 156 157 158 159 160 |
|