Noko Teams

The NokoClient offers multiple methods to interact with teams in Noko. On methods where keyword arguments are supported, parameter validation happens through Pydantic, allowing Python types other than what’s supported by the Noko API to be used when making requests, and providing a validation layer before the request is even made to the API.

class noko_client.client.NokoClient(access_token: str)

Simple Client for the Noko API.

Provide a friendlier interface to interact with the Noko API. Where Noko expects parameters to be passed in a specific way (for example, a list of strings for IDs, provide support for multiple types and handle formatting and validation.

This client does not currently support oAuth.

access_token

The Noko access token to authenticate the requests.

Type:

str

add_users_to_team(team_id: str | int, user_ids: str | list[str | int]) list[dict]

Add users to a team.

Parameters:
  • team_id (str | int) – The ID of the team to add users to.

  • user_ids (str | list[str | int]) – The IDs of the users to add to the team. If provided as string, must be a comma separated string.

Returns:

A list of all users associated with the team.

Return type:

(list[dict])

create_team(**kwargs) list[dict]

Create a new team in Noko.

Keyword Arguments:
  • name (str) – The name of the team to be created.

  • int] (user_ids (str | list[str |) – List of users to associate with the team. If provided as a string,

  • string. (must be a comma separated) –

Returns:

The created team as a dictionary.

Return type:

(list[dict])

delete_team(team_id: str | int) None

Delete a team from Noko.

Deleting a team will not delete the users in the team.

Parameters:

team_id (str | int) – The ID of the team to delete.

Returns:

Doesn’t return anything, if unsuccessful, raises an exception.

Return type:

(None)

edit_team(team_id: str | int, name: str) list[dict]

Edit an existing team in Noko.

Parameters:
  • team_id (str | int) – The ID of the team to edit in Noko.

  • name (str) – The name to give the team.

Returns:

The created team as a dictionary.

Return type:

(list[dict])

get_entries_for_users_in_team(team_id: str | int, **kwargs) list[dict]

Get all entries associated with a team.

Results can be filtered using the same keyword arguments as the ones used for the list entries endpoint. All keyword arguments are optional.

Parameters:

team_id (str | int) – The ID of the team to retrieve entries for.

Keyword Arguments:
  • user_ids (str | list | None) – IDs of users to filter. If provided as a string, must be comma separated. If provided as a list, can be provided as a list of integers or strings. Defaults to None.

  • description (str | None) – Only descriptions containing the provided text will be returned. Defaults to None.

  • project_ids (str | list | None) – IDs of projects to filter for. If provided as a string, must be comma separated. If provided as a list, can be provided as a list of integers or strings. Defaults to None.

  • tag_ids (str | list | None) – IDs of users to filter for. If provided as a string, must be comma separated. If provided as a list, can be provided as a list of integers or strings. Defaults to None.

  • tag_filter_type (str | None) – The type of filter to apply if filtering for tag_ids. Defaults to None.

  • from (str | datetime | None) – The date from which to search. Only entries logged on this day onwards will be returned. If provided as string, must be in ISO 8601 format (YYYY-MM-DD).

  • to (str | datetime | None) – The date up to which to search. Only entries logged up to this day will be returned. If provided as string, must be in ISO 8601 format (YYYY-MM-DD).

  • invoiced (bool | str | None) – Whether to filter for invoiced or uninvoiced entries. If provided as string, must be lower case. Defaults to None.

  • updated_from (str | datetime | None) – Only entries with updates from this timestamp onwards are returned. If provided as string, must be in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ). Defaults to None.

  • updated_to (str | datetime | None) – Only entries with updates up to this timestamp are returned. If provided as string, must be in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ). Defaults to None.

  • billable (bool | str | None) – Whether to filter for billable or unbillable entries. If provided as string, must be lower case. Defaults to None.

  • approved_at_from (str | datetime | None) – Only entries with approvals from this date on will be returned. If provided as string, must be in ISO 8601 format (YYYY-MM-DD). Defaults to None.

  • approved_at_to (str | datetime | None) – Only entries with approvals up to this date will be returned. If provided as string, must be in ISO 8601 format (YYYY-MM-DD). Defaults to None.

Returns:

A list of all retrieved entries meeting the specified criteria.

Return type:

(list[dict])

get_single_team(team_id: str | int) list[dict]

Retrieve a single team from Noko.

Parameters:

team_id (str | int) – The ID of the team to retrieve.

Returns:

The retrieved team as a dictionary.

Return type:

(list[dict])

get_users_in_team(team_id: str | int, **kwargs) list[dict]

Get all users in a team.

Results can be filtered using the same keyword arguments as the ones used for the users entries endpoint. All keyword arguments are optional.

Parameters:

team_id (str | int) – The ID of the team to retrieve users for.

Keyword Arguments:
  • name (str | None) – Only users with this string in their name are returned. Defaults to None.

  • email (str | None) – Only users with this string in their email address are returned. Defaults to None.

  • role (str | None) – Only users with this role will be returned. Defaults to all. Accepted values are: supervisor, leader, coworker, contractor

  • state (str | None) – Only users in this state will be returned. Defaults to all. Accepted values are: disabled, pending, active, suspended

Returns:

A list of all retrieved users meeting the specified criteria.

Return type:

(list[dict])

list_teams(**kwargs) list[dict]

List all teams in Noko.

Keyword Arguments:
  • name (str | None) – Only teams with this string in the name will be returned. Defaults to None.

  • user_ids (str | list[str | int] | None) – List of user IDs to filter teams by. If provided as a string, must be a comma separated string. Defaults to None.

Returns:

The list of teams in Noko as a list of dictionaries.

Return type:

(list[dict])

remove_all_users_from_team(team_id: str | int) None

Remove all users from a team.

Parameters:

team_id (str | int) – The ID of the team to remove all users from.

Returns:

Doesn’t return anything, if unsuccessful, raises an exception.

Return type:

(None)

remove_users_from_team(team_id: str | int, user_ids: str | list[str | int]) None

Remove users from a team.

Parameters:
  • team_id (str | int) – The ID of the team to remove users from.

  • user_ids (str | list[str | int]) – The IDs of the users to remove from the team. If provided as string, must be a comma separated string.

Returns:

Doesn’t return anything, if unsuccessful, raises an exception.

Return type:

(None)