Welcome to wheniwork’s documentation!

Contents:

A Python Wrapper for WhenIWork.com
class wheniwork.WhenIWork(token=None, options=None)
Parameters:
  • token – The user WhenIWork API token
  • options – Allows you to set the headers and the endpoint from a dict.

Methods:

create(method, params=None, headers=None)

Synonym of post

Parameters:
  • method
  • params
  • headers
Returns:

delete(method, headers=None)

Delete an object on WhenIWork

Parameters:
  • method – The API method to call, e.g. ‘/users/1’ MUST INCLUDE ID OF OBJECT.
  • headers – a dictionary of custom headers to be passed.
Returns:

a dictionary of the decoded json API response.

endpoint

Used to set or retrieve the api endpoint:

from wheniwork import WhenIWork

a = WhenIWork()
a.endpoint = "https://api.wheniwork.com/2"
print(a.endpoint)
get(method, params=None, headers=None)

Send a get request to the WhenIWork api

Parameters:
  • method – The API method to call, e.g. ‘/users’
  • params – a dictionary of arguments to pass the method
  • headers – a dictionary of custom headers to be passed.
Returns:

a dictionary of the decoded json API response.

headers

Used to set or retrieve the api endpoint:

from wheniwork import WhenIWork

a = WhenIWork()
a.headers = {W-Key:"iworksoharditsnotfunny"}
print(a.headers['W-Key'])
login(username, password, key)

Sets the user API token, and returns a dictionary of user information.

Parameters:
  • username – The email for the user account.
  • password – The password for the user account.
  • key – the developer key given to you by WhenIWork.com
Return dict:
post(method, params=None, headers=None)

POST to the WhenIWork api

Parameters:
  • method – The API method to call, e.g. ‘/users’
  • params – a dictionary of arguments to pass the method
  • headers – a dictionary of custom headers to be passed.
Returns:

a dictionary of the decoded json API response.

resp

Used to get the last API Response Data:

from wheniwork import WhenIWork

a = WhenIWork(token="iworksomuchitsnotfunny")
a.get("/locations")
print(a.resp)

Note: This is a read only variable.

token

Used to set or retrieve the user’s api token:

from wheniwork import WhenIWork

a = WhenIWork()
a.token = "ilovemyboss"
print(a.token)
update(method, params=None, headers=None)

Update an object on WhenIWork

Parameters:
  • method – The API method to call, e.g. ‘/users/1’ MUST INCLUDE ID OF OBJECT.
  • params – a dictionary of arguments to pass the method
  • headers – a dictionary of custom headers to be passed.
Returns:

a dictionary of the decoded json API response.

Indices and tables