Noko Expenses

The NokoClient offers multiple methods to interact with expenses 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

create_expense(**kwargs) list[dict]

Create a new expense in Noko.

Keyword Arguments:
  • date (str | datetime) – The date of the expense. If provided as string, must be in ISO 8601 format (YYYY-MM-DD).

  • project_id (str | int) – The ID of the project to log the expense to.

  • price (int | float) – The numeric price of the expense. Must be numeric only, and can be negative. Do not add the currency to this price.

  • user_id (str | int | None) – The ID of the user who created the expense. If no value is provided, the authenticated user will be used by default.

  • taxable (bool | str | None) – Whether the expense is taxable or not. Defaults to True.

  • description (str | None) – The description of the expense. Tags and hashtags will not be parsed. Defaults to None.

Returns:

The newly created expense as a dictionary.

Return type:

(list[dict])

delete_expense(expense_id: str | int) None

Delete an expense from Noko.

Parameters:

expense_id (str | int) – The ID of the expense to delete.

Returns:

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

Return type:

(None)

edit_expense(expense_id: str | int, **kwargs) list[dict]

Edit an expense in Noko.

Parameters:

expense_id (str | int) – The ID of the expense to edit.

Keyword Arguments:
  • date (str | datetime | None) – The date of the expense. If provided as string, must be in ISO 8601 format (YYYY-MM-DD). Defaults to None.

  • project_id (str | int) – The ID of the project to log the expense to. Defaults to None.

  • price (int | float) – The numeric price of the expense. Must be numeric only, and can be negative. Do not add the currency to this price. Defaults to None.

  • user_id (str | int | None) – The ID of the user who created the expense. Defaults to None.

  • taxable (bool | str | None) – Whether the expense is taxable or not. Defaults to None.

  • description (str | None) – The description of the expense. Tags and hashtags will not be parsed. Defaults to None.

Returns:

The edited expense as a dictionary.

Return type:

(list[dict])

get_single_expense(expense_id: str | int) list[dict]

Retrieve a single expense from Noko.

Parameters:

expense_id (str | int) – The ID of the expense to retrieve.

Returns:

The retrieve expense as a dictionary.

Return type:

(list[dict])

list_expenses(**kwargs) list[dict]

List expenses from Noko.

Keyword Arguments:
  • user_ids (str | list | None) – The IDs of the users to filter expenses by. If provided as string, must be a comma separated string. Defaults to None.

  • description (str | None) – Only expenses containing this text in their description are returned.

  • project_ids (str | list | None) – The IDs of the projects to filter expenses by. If provided as string, must be a comma separated string. Defaults to None.

  • invoice_ids (str | list | None) – The IDs of the invoices to filter expenses by. If provided as string, must be a comma separated string. Defaults to None.

  • from (str | datetime | None) – Only expenses from or after this date will be returned. If provided as string, must be in ISO 8601 format (YYY-MM-DD). Defaults to None.

  • to (str | datetime | None) – Only expenses on or before this date will be returned. If provided as string, must be in ISO 8601 format (YYY-MM-DD). Defaults to None.

  • price_from (int | float | None) – Only expenses with a price grater than or equal to this will be returned. Defaults to None.

  • price_to (int | float | None) – Only expenses with a price less than or equal to this will be returned. Defaults to None.

  • taxable (bool | str | None) – Return only expenses where taxes are applied or not applied. Defaults to both.

  • invoiced (bool | str | None) – Return only invoiced or uninvoiced expenses. Defaults to both.

Returns:

All retrieved expenses as a list of dictionaries.

Return type:

(list[dict])