Skip to content

Commit 8b30bc1

Browse files
committed
Add Current User info methods
Return User Usage Limits / Current Usage towards Throttle Limits with `receive_user_rate_info` Return full account info with `receive_user_info` Fixes #126
1 parent 99bd004 commit 8b30bc1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

adafruit_io/adafruit_io.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,35 @@ def receive_random_data(self, generator_id: int):
855855
path = self._compose_path("integrations/words/{0}".format(generator_id))
856856
return self._get(path)
857857

858+
def receive_user_info(self):
859+
"""
860+
Get detailed account information for the current user.
861+
862+
See https://io.adafruit.com/api/docs/#get-user-info
863+
"""
864+
return self._get("https://io.adafruit.com/api/v2/user")
865+
866+
def receive_user_rate_info(self):
867+
"""
868+
Get rate limit and usage information for the current user.
869+
870+
See https://io.adafruit.com/api/docs/#get-detailed-user-info
871+
872+
:code-block: json
873+
{
874+
"data_rate_limit": 90,
875+
"active_data_rate": 2,
876+
"authentication_rate": 0,
877+
"subscribe_authorization_rate": 0,
878+
"publish_authorization_rate": 0,
879+
"hourly_ban_rate": 0,
880+
"mqtt_ban_error_message": null,
881+
"sms_message_limit": 0
882+
}
883+
"""
884+
path = self._compose_path("throttle")
885+
return self._get(path)
886+
858887
def receive_time(self, timezone: str = None):
859888
"""
860889
Returns a struct_time from the Adafruit IO Server based on the device's IP address.

0 commit comments

Comments
 (0)