Client

class freshbooks.client.Client(client_id, client_secret=None, redirect_uri=None, access_token=None, refresh_token=None, user_agent=None, api_version=None, timeout=30, auto_retry=True)

Bases: object

property attachments: UploadsResource

FreshBooks attachment upload resource with call to upload, get

property bill_payments: AccountingResource

FreshBooks bill_payments resource with calls to get, list, create, update, delete

property bill_vendors: AccountingResource

FreshBooks bill_vendors resource with calls to get, list, create, update, delete

property bills: AccountingResource

FreshBooks bills resource with calls to get, list, create, update, delete

property callbacks: EventsResource

FreshBooks callbacks (webhook callbacks) resource with calls to get, list, create, update, delete, resend_verification, verify

property clients: AccountingResource

FreshBooks clients resource with calls to get, list, create, update, delete

property credit_notes: AccountingResource

FreshBooks credit_notes resource with calls to get, list, create, update, delete

current_user()

The identity details of the currently authenticated user.

See FreshBooks API - Business, Roles, and Identity

Return type:

:sphinx_autodoc_typehints_type:\:py\:class\:\``~freshbooks.models.Identity

property estimates: AccountingResource

FreshBooks estimates resource with calls to get, list, create, update, delete

property expenses: AccountingResource

FreshBooks expenses resource with calls to get, list, create, update, delete

property expenses_categories: AccountingResource

FreshBooks expenses categories resource with calls to get and list

property gateways: AccountingResource

FreshBooks gateways resource with calls to list, delete

get_access_token(code)

Makes a call to the FreshBooks token URL to get an access_token.

This requires the access_grant code obtained after the user is redirected by the authorization step. See freshbooks.client.Client.get_auth_request_url.

This call sets the access_token, refresh_token, and access_token_expires_at attributes on the Client instance and also returns those values in an object.

Return type:

:sphinx_autodoc_typehints_type:\:py\:class\:\``~types.SimpleNamespace

Parameters:

code – access_grant code from the authorization redirect

Returns:

Simple namespace containing access_token, refresh_token, and access_token_expires_at

Raises:
get_auth_request_url(scopes=None)

Returns the url that a client needs to request an oauth grant from the server.

To get an oauth access token, send your user to this URL. The user will be prompted to log in to FreshBooks, after which they will be redirected to the redirect_uri set on the client with the access grant as a parameter. That grant can then be used to fetch an access token by calling get_access_token.

Note: The redirect_uri must be one of the URLs your application is registered for.

If scopes are not specified, then the access token will be given the default scopes your application is registered for.

Return type:

:sphinx_autodoc_typehints_type:\:py\:class\:\``str

Parameters:

scopes – List of scopes if your want an access token with only a subset of your registered scopes

Returns:

The URL for the authorization request

Raises:

FreshBooksClientConfigError – If redirect_uri is not set on the client instance.

property images: UploadsResource

FreshBooks image upload resource with call to upload, get

property invoice_payment_options: PaymentsResource

FreshBooks default payment options resource with calls to defaults, get, create

property invoice_profiles: AccountingResource

FreshBooks invoice_profiles resource with calls to get, list, create, update, delete

property invoices: AccountingResource

FreshBooks invoices resource with calls to get, list, create, update, delete

property items: AccountingResource

FreshBooks items resource with calls to get, list, create, update, delete

property ledger_accounts: AccountingBusinessResource

FreshBooks accounts resource with calls to get, list

property other_income: AccountingResource

FreshBooks other_incomes resource with calls to get, list, create, update, delete

property payments: AccountingResource

FreshBooks payments resource with calls to get, list, create, update, delete

property projects: ProjectsResource

FreshBooks projects resource with calls to get, list, create, update, delete

refresh_access_token(refresh_token=None)

Makes a call to the FreshBooks token URL to refresh an access_token.

If refresh_token is provided, it will call to refresh it, otherwise it will use the refresh_token on the Client instance.

This call sets the access_token, refresh_token, and access_token_expires_at attributes on the Client instance to the new values from the refresh call, and also returns those values in an object.

Return type:

:sphinx_autodoc_typehints_type:\:py\:class\:\``~types.SimpleNamespace

Parameters:

refresh_token – (Optional) refresh_token from initial get_access_token call

Returns:

Simple namespace containing access_token, refresh_token, and access_token_expires_at

Raises:

FreshBooksClientConfigError – If refresh_token is not set on the client instance and is not provided.

property service_rates: CommentsSubResource

FreshBooks service_rates resource with calls to get, list, create, update

property services: CommentsResource

FreshBooks services resource with calls to get, list, create, update, delete

property staff: AccountingResource

FreshBooks staff resource with calls to get, list, update, delete

property systems: AccountingResource

FreshBooks systems resource with calls to get only

property tasks: AccountingResource

FreshBooks tasks resource with calls to get, list, create, update, delete

Note: There is a lot of overlap between Services and Tasks. In general services are used to add categories of work to projects, and tasks are used to add billable work to invoices.

Creating a task should create the corresponding service and vice versa.

property taxes: AccountingResource

FreshBooks taxes resource with calls to get, list, create, update, delete

property time_entries: TimetrackingResource

FreshBooks time_entries resource with calls to get, list, create, update, delete

freshbooks.client.DEFAULT_TIMEOUT = 30

Default request timeout to FreshBooks