rawg

The main rawg class

class rawgpy.rawg.RAWG(user_agent)[source]

main RAWG class

the main class used for interactions with the RAWG.io database

collection_games(slug)[source]

generator that yields the collections games json

Parameters:slug (str) – the slug of the collection
Returns:generator of the games json
Return type:pagination_generator
collection_request(slug) → dict[source]

Returns the collection json

Parameters:slug (str) – the collection slug
Returns:The collection json
Return type:dict
create_collection(name, description) → rawgpy.collection.Collection[source]

creates a new collection

Parameters:
  • name (str) – Name of the collection
  • description (str) – Description of the collection
Returns:

Collection object of created collection

Return type:

Collection

current_user() → rawgpy.user.User[source]

Returns the currently authenticated user

Returns:The currently authenticated user
Return type:User
current_user_request() → dict[source]

Returns the currently authenticated user json

Returns:Json of the authenticated user
Return type:dict
game_collections(game_slug)[source]

Retrieve the collections a game is a part of

Parameters:game_slug (str.) – the slug of the game
Returns:generator of the collections json
Return type:pagination_generator
game_request(slug, additional_param='') → dict[source]

uses the get_request method to get a specific games json

Parameters:
  • slug (str) – the slug of the game that shoudl be returned, needs to be correct rawg slug
  • additional_param – any additional request parameter
Returns:

json-like list / dict structure of the returned json

Return type:

dict

game_suggestions(slug)[source]

generator that yields the suggested games for a game

Parameters:slug (str) – the game slug
Returns:generator of the games json
Return type:pagination_generator
get_collection(slug) → rawgpy.collection.Collection[source]

Returns the collection object

Parameters:slug (str) – the collection slug
Returns:The collection object
Return type:Collection
get_game(slug) → rawgpy.game.Game[source]

get a specific game

Parameters:slug (str) – the slug of the game
Returns:the game object
Return type:Game
get_request(url) → dict[source]

Sends a GET request

Parameters:url (str) – the url it sends a request to,
Returns:json-like list / dict structure of the returned json
Return type:dict
get_user(slug) → rawgpy.user.User[source]

gets a user User

Parameters:slug (str) – the userslug
Returns:user json
Return type:dict
Returns:generator of the collections json
Return type:User
login(email, password)[source]

Logs the user in, autheticating all subsequent requests with that user

Parameters:
  • email (str) – The users email
  • password (str) – The users password
pagination_generator(url, results_name='results', next_name='next') → dict[source]

Generator for pagination based urls, reads the value of next_name from the json to get the url for the next request

uses get_request

Parameters:
  • url (str) – the url, needs to return some kind of next url value
  • results_name (str, optional) – the json key used to return the result, defaults to “results”
  • next_name (str, optional) – the key used to get the next url, defaults to “next”
Returns:

the paginated objects json

Return type:

dict

patch_game(slug, data)[source]

Patch (edit) a game

Parameters:
  • slug (str) – The games slug
  • data (dict) – The edited data
Returns:

The response json

Return type:

dict

patch_request(url, data) → dict[source]

Sends a PATCH request

Parameters:
  • url (str) – The PATCH url
  • data (dict) – The PATCH data
Returns:

The response json

Return type:

dict

post_request(url, data) → dict[source]

Sends a POST request

Parameters:
  • url (str) – The POST url
  • data (dict) – The POST data
review_data(level, reactions=None, add_to_library=False, text='', post_twitter=False, post_facebook=False) → dict[source]

creates the data for review operations

Parameters:
  • game_id (int) – the int id of the game
  • level (int) – 1 = skip, 3 = meh, 4 = Recommended, 5 = Exceptional
  • reactions (List[int], optional) – List of the reactions to add, defaults to None
  • add_to_library (bool, optional) – whether the game whouls be added to the authenticated users library, defaults to False
  • text (str, optional) – the review text, uses html formats like <br>, defaults to “”
  • post_twitter (bool, optional) – whether to post on twitter, defaults to False
  • post_facebook (bool, optional) – whether to post on facebook, defaults to False
Returns:

The data that has been made

Return type:

dict

review_game(game_id: int, level, reactions=None, add_to_library=False, text='', post_twitter=False, post_facebook=False)[source]

Adds a review to a game

Parameters:
  • game_id (int) – the int id of the game
  • level (int) – 1 = skip, 3 = meh, 4 = Recommended, 5 = Exceptional
  • reactions (List[int], optional) – List of the reactions to add, defaults to None
  • add_to_library (bool, optional) – whether the game whouls be added to the authenticated users library, defaults to False
  • text (str, optional) – the review text, uses html formats like <br>, defaults to “”
  • post_twitter (bool, optional) – whether to post on twitter, defaults to False
  • post_facebook (bool, optional) – whether to post on facebook, defaults to False
search(query, num_results=5, additional_param='') → rawgpy.game.Game[source]

searches for games

Parameters:
  • query (str) – the search query
  • num_results (int, optional) – the amount of results, defaults to 5
  • additional_param (str, optional) – additional get parameters, defaults to “”
search_request(query, num_results=5, additional_param='') → dict[source]

uses the get_request method to search for a game

Parameters:
  • query (str) – the name of the game that should be searched for
  • num_results (int) – the amount of results the search should return
  • additional_param – any additional search parameter, like &sorting=-_score to sort the games by relevance, excluding popularity
Returns:

json-like list / dict structure of the returned json

Return type:

dict

user_games(slug, status=None)[source]

generator that yields the users games json

Parameters:
  • slug (str) – the users slug
  • status (str, optional) – the status of the game in the users library, can be playing, owned, beaten, dropped, toplay, yet defaults to “playing”
Returns:

generator of the games json

Return type:

pagination_generator

user_request(slug) → dict[source]

Returns a user json

Parameters:slug (str) – the users slug
Returns:the users json
Return type:dict