No description, website, or topics provided.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



Python clients for accessing simpl-games-api.


from simpl_client import GamesAPIClient
games_client = GamesAPIClient(url=SIMPL_GAMES_URL, auth=SIMPL_GAMES_AUTH)


pip install simpl-client


Endpoints are available as properties on the main instance.


Retrieves all resources (essentially a simple GET on the endpoint):

games_client.runusers.all()  # GET /runusers/

.filter(**kwargs) calls a GET with kwargs as querystring values:

games_client.runusers.filter(run=12, world=1)  # GET /runusers/?run=12&world=1


A special case of .filter().

If kwargs contains id, pk, slug or username, that value will be used in the URL path, in that order.

Otherwise, it calls a GET with kwargs as querystring values.

If the returned list is empty, will raise ResourceNotFound.

If the returned list contains more than 1 resource, will raise MultipleResourcesFound

Note that .get() will return a Resource, not a list of Resource s

games_client.runusers.filter(run=12, world=1)  # GET /runusers/?run=12&world=1
games_client.runusers.filter(id=12)  # GET /runusers/12/
games_client.users.filter(username='alice')  # GET /users/alice/


Will result in a POST, with payload (a dict) as the request's body, returning a new Resource:

runuser = games_client.runusers.create({'run': 12, 'world': 1})  # POST /runusers/

.get_or_create(defaults, **kwargs)

Issues a GET to fetch the resource. If the resource is not found, issues a POST to create the resource.

# Assuming it doesn't exist run =, defaults={'active': True}) # GET /runs/?game=12, then POST /runs/


If payload contains a key called 'id', will issue a PUT, otherwise it will call .create:

runuser = games_client.runusers.create_or_update({'id': 1234, 'world': 1})  # PUT /runusers/1234/


Will issue a DELETE, and will use pk as part of the URL:

games_client.runusers.delete(24)  # DELETE /runusers/24/


All endpoints methods (with the exception of .delete()) return either a Resource or a list of Resource s.

A Resource is just a wrapping class for a dict, where keys can be accessed as properties.

Additionally, Resource s have a special property called .payload, which contains the original payload received from the server.

Resource s have the following methods:

Resource.delete() will result in a DELETE, with as par of the URL:

runuser = games_client.runusers.create({'run': 12, 'world': 1})  # POST /runusers/
runuser.delete()  # DELETE /runuser/345/ -- the ID 345 was returned by the server in the previous response will result in a PUT, with as par of the URL:

runuser = games_client.runusers.create({'run': 12, 'world': 1})  # POST /runusers/ = 13  # PUT /runuser/345/

Bulk requests

games_client.bulk.results.create([...], return_ids=False)

Detail Routes


Setup development environment

git clone
cd simpl-client
mkvirtualenv simpl-client
pip install -e .


Running the tests requires having libmagic installed.

On OS X, simply run brew install libmagic.


Copyright © 2018 The Wharton School,  The University of Pennsylvania

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.