Skip to main content

Help Scout API client

This package contains a wrapper to query Help Scout's API. The package tries to be as general and assume as little as possible about the API. Therefore, it will allow any endpoint to be requested and objects and types will be created on the fly.

Information about the available endpoints, objects and other stuff can be found on the API's documentation. The client contains as little internal knowledge of the API as possible, mostly authentication, pagination and how are objects returned.

In order to handle pagination calls to API are done inside a generator. As a consequence, even post and deletes have to be "nexted" if using the hit_ method.

Requirements

Python 3.11+

Installation

Using PyPI into a venv:

pip install python-helpscout --require-virtualenv`

Manually by cloning the repository and executing pip into a venv:

pip install . --require-virtualenv`

Authentication

In order to use the API you need an app id and app secret.

More about credentials can be found in Help Scout's documentation.

General use

The general use is by instantiating a client and then hitting the API by doing client.<endpoint>.<method>(<resource_id>, <params>). Where:

  • Endpoint is one of the endpoints defined in the API's documentation.
  • Method is one of get, post, patch, put or delete as defined in the API.
  • Resource id can be None or the id of the specific resource to access, update or delete. E.g.: a conversation id.
  • Params can be None, a string or a dictionary with the parameters to access in the get method or the data to send otherwise.

To access attributes of specific resources, like the tags of a conversation, you can do: client.<endpoint>[<resource_id>].<attribute>.<method>(<resource_id>, <params>).

Example: client.conversations[212109].threads.get()

Examples

Listing all users

> from helpscout import HelpScout
> hs = HelpScout(app_id='ax0912n', app_secret='axon129')
> users = hs.users.get()
> users[0]
User(id=12391,
     firstName="John",
     lastName="Doe",
     email="john.doe@gmail.com",
     role="user",
     timezone="America/New_York",
     createdAt="2019-01-03T19:00:00Z",
     updatedAt="2019-05-20T18:00:00Z",
     type="user",
     mention="johnny",
     initials="JD",
     _links={'self': {'href': 'https://api.helpscout.net/v2/users/12391'}})
> users[1].id
9320

Hitting the API directly to get all mailboxes

> from helpscout.client import HelpScout
> hs = HelpScout(app_id='laknsdo', app_secret='12haosd9')
> for mailbox in hs.hit('mailboxes', 'get'):
>      print(mailbox)
{'mailboxes': [
   {'id': 1930,
    'name': 'Fake Support',
    'slug': '0912301u',
    'email': 'support@fake.com',
    'createdAt': '2018-12-20T20:00:00Z',
    'updatedAt': '2019-05-01T16:00:00Z',
    '_links': {
      'fields': {'href': 'https://api.helpscout.net/v2/mailboxes/1930/fields/'},
      'folders': {'href': 'https://api.helpscout.net/v2/mailboxes/1930/folders/'},
      'self': {'href': 'https://api.helpscout.net/v2/mailboxes/1930'}
    }
   }
 ]
}

Hitting the API directly to get all mailboxes but handling requests with pagination as iteration goes on

> from helpscout.client import HelpScout
> hs = HelpScout(app_id='laknsdo', app_secret='12haosd9')
> for mailbox in hs.hit_('mailboxes', 'get'):
>      print(mailbox)
{'mailboxes': [
   {'id': 1930,
    'name': 'Fake Support',
    'slug': '0912301u',
    'email': 'support@fake.com',
    'createdAt': '2018-12-20T20:00:00Z',
    'updatedAt': '2019-05-01T16:00:00Z',
    '_links': {
      'fields': {'href': 'https://api.helpscout.net/v2/mailboxes/1930/fields/'},
      'folders': {'href': 'https://api.helpscout.net/v2/mailboxes/1930/folders/'},
      'self': {'href': 'https://api.helpscout.net/v2/mailboxes/1930'}
    }
   }
 ]
}

Hitting the API directly to get a specific mailbox

> from helpscout.client import HelpScout
> hs = HelpScout(app_id='laknsdo', app_secret='12haosd9')
> for mailbox in hs.hit('mailboxes', 'get', resource_id=1930):
>      print(mailbox)
{'id': 1930,
 'name': 'Fake Support',
 'slug': '0912301u',
 'email': 'support@fake.com',
 'createdAt': '2018-12-20T20:00:00Z',
 'updatedAt': '2019-05-01T16:00:00Z',
 '_links': {
   'fields': {'href': 'https://api.helpscout.net/v2/mailboxes/1930/fields/'},
   'folders': {'href': 'https://api.helpscout.net/v2/mailboxes/1930/folders/'},
   'self': {'href': 'https://api.helpscout.net/v2/mailboxes/1930'}
 }
}

Hitting the API directly to get a specific mailbox dictionary style

In this case, you will have to select the first element of the list yourself, as it is not quite clear if one or more elements should be expected from the api depending on the endpoint.

> from helpscout.client import HelpScout
> hs = HelpScout(app_id='laknsdo', app_secret='12haosd9')
> print(hs.mailboxes[1930].get())
Mailbox(
 id=1930,
 name='Fake Support',
 slug='0912301u',
 email='support@fake.com',
 createdAt='2018-12-20T20:00:00Z',
 updatedAt='2019-05-01T16:00:00Z',
 _links={
   'fields': {'href': 'https://api.helpscout.net/v2/mailboxes/1930/fields/'},
   'folders': {'href': 'https://api.helpscout.net/v2/mailboxes/1930/folders/'},
   'self': {'href': 'https://api.helpscout.net/v2/mailboxes/1930'}
 }
)

Listing conversations using a dictionary parameters

> from helpscout.client import HelpScout
> hs = HelpScout(app_id='asd12', app_secret='onas912')
> params = {'status': 'active'}
> conversations = hs.conversations.get(params=params)

Listing conversations using a string with parameters

> from helpscout.client import HelpScout
> hs = HelpScout(app_id='asdon123', app_secret='asdoin1')
> params = 'query=(createdAt:[2019-06-20T00:00:00Z TO 2019-06-22T23:59:59Z])'
> conversations = hs.conversations.get(params=params)

Deleting a conversation

> from helpscout.client import HelpScout
> hs = HelpScout(app_id='asdon123', app_secret='asdoin1')
> conversation_id = 10
> hs.conversations.delete(resource_id=conversation_id)

Requesting a pre-made report

> from helpscout.client import HelpScout
> hs = HelpScout(app_id='asdon123', app_secret='asdoin1')
> report_url = 'reports/happiness?start=2019-06-01T00:00:00Z&end=2019-06-15:00:00Z'
> next(hs.hit_(report_url, 'get'))
...

or

> from helpscout.client import HelpScout
> hs = HelpScout(app_id='asdon123', app_secret='asdoin1')
> report_url = 'reports/happiness?start=2019-06-01T00:00:00Z&end=2019-06-15:00:00Z'
> hs.hit(report_url, 'get')
...

Adding tags to a conversation

> from helpscout import HelpScout
> helpscout_client = HelpScout(app_id='ax0912n', app_secret='axon129')
> conversation_id = 999
> endpoint = 'conversations/%s/tags' % conversation_id
> data = {'tags': conversation_tags}
> helpscout_client.hit(endpoint, 'put', data=data)

or

> from helpscout import HelpScout
> helpscout_client = HelpScout(app_id='ax0912n', app_secret='axon129')
> conversation_id = 999
> endpoint = 'conversations/%s/tags' % conversation_id
> data = {'tags': conversation_tags}
> next(helpscout_client.hit_(endpoint, 'put', data=data))

or

> from helpscout import HelpScout
> helpscout_client = HelpScout(app_id='ax0912n', app_secret='axon129')
> conversation_id = 999
> data = {'tags': conversation_tags}
> helpscout_client.conversations[999].tags.put(data=data)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_helpscout-2.0.2.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_helpscout-2.0.2-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file python_helpscout-2.0.2.tar.gz.

File metadata

  • Download URL: python_helpscout-2.0.2.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for python_helpscout-2.0.2.tar.gz
Algorithm Hash digest
SHA256 a4fa7222edbdc29531a471852e16942fa040b2bf21a93dac9ff1aa8facf95e65
MD5 4e71b3279dbbf4fcab5db1739295ff50
BLAKE2b-256 6164b5e8cd76da17162dfa3bdcb32e64a727b7caa46e10678a2bd0452ec8c415

See more details on using hashes here.

File details

Details for the file python_helpscout-2.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for python_helpscout-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a7b35311c271ae926f2bb991085050402d1cb4ca3ccaa963517e0d0884638713
MD5 dd3e304f8866f9136d18a917fa3e4092
BLAKE2b-256 fe107814730eea08994ade6082337c4a810271ed3c331e010cfb6f52d2015d00

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 files

2.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page