Api
Fixtures
Bases: Requester
Source code in cartola_project/api.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
Matches
Bases: Requester
Source code in cartola_project/api.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
Players
Bases: Requester
Source code in cartola_project/api.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
Requester
Bases: ABC
Source code in cartola_project/api.py
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 |
|
__init__(api_host_key, api_secert_key)
Abstract base class for all API requesters. Work as interface for all API requesters, forcing to implement some methods. Also use an exteranl library for rate limiting and back-off exponential to timing out requests.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_host_key |
str
|
Api credentials host key |
required |
api_secert_key |
str
|
Api credentials secret key |
required |
Source code in cartola_project/api.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
get_data(**kwargs)
Method to get the data from the API. This methods warperd get_response to set some parameters for the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Extra parameters for the API |
{}
|
Returns:
Type | Description |
---|---|
dict | list[dict]
|
Json response from the API |
Source code in cartola_project/api.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
get_response(endpoint, header, param)
Concrete method to get the response from the API. This request method use back-off exponential to timing out requests, with max retries and factor are set to 10. Also only retry if the response is not 2xx.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint |
str
|
Endpoint string |
required |
header |
str
|
Header for the request |
required |
param |
dict
|
Parameter for the request |
required |
Returns:
Type | Description |
---|---|
requests.Response
|
Response from the API |
Source code in cartola_project/api.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
Teams
Bases: Requester
Source code in cartola_project/api.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|