python Game Jolt API wrapper
- complete subcomponents /scores/
- able to operate from a User model (basically being able to open sessions, give/remove trophies, etc)
- documentation
- examples
- use index of the api version instead of manually using numbers?
gamejolt expects you to create the _post and evaluate methods _post sends the request to the gamejolt api evaluate: parses the response and returns a dictionary with 3 keys: success, response and message
fromgamejoltimportGameJoltasGameJoltApiimportrequestsclassGameJolt(GameJoltApi):
def_post(self, url: str) ->requests.Response:
returnrequests.post(url, timeout=10)
defevaluate(self, response: requests.Response) ->dict:
json: dict=response.json()
return {
"success": json["response"]["success"],
"response": json["response"],
"message": json["response"].get("message"),
}
gamejolt=GameJolt("YOUR_GAME_KEY", game="YOUR_GAME_ID")user=gamejolt.users.fetch("1")
print(user) # output: User(id=14728, type='Developer', username='1', signed_up='12 years ago', last_logged_in='12 years ago', status='Active')[!NOTE] depending on your ide/editor; you can hover over the functions to get documentation or even read the code
[!WARN] all the below methods require the user token to be set. use
User.set_token()to set the user token
the_trophy=gamejolt.trophies.fetch(user, 1234) # remove trophy id to fetch all trophiesprint(the_trophy)
gamejolt.trophies.add_achieved(user, 12345) # could raises UserAlreadyHasTrophy or IncorrectTrophyIDgamejolt.sessions.open(user)
gamejolt.data_store.set("key", "value") # set an item globally for the gamegamejolt.data_store.set(user, "cookies", "100") # set an item for a user