zoom_api_helper package

Submodules

zoom_api_helper.constants module

Project-specific constant values.

zoom_api_helper.log module

zoom_api_helper.log.setup_logging(default_level: LevelType = 10, lib_level: LevelType = 10, urllib3_level: LevelType = 30)[source]

Sets up logging for application (user) code.

zoom_api_helper.models module

class zoom_api_helper.models.Meeting(value)[source]

Bases: Enum

The type of Zoom meeting.

INSTANT = 1
RECURRING = 3
RECURRING_WITH_TIME = 8
SCHEDULED = 2

zoom_api_helper.oauth module

zoom_api_helper.oauth.get_access_token(session: Session, account_id: str, client_id: str, client_secret: str) str[source]

Retrieve an access token, given credentials for a Server-to-Server OAuth app.

To use account credentials to get an access token for your app, call the Zoom OAuth token API with the account_credentials grant_type and your account_id.

The successful response will be the access token, which is a Bearer token type that expires in an hour, with the scopes that you chose in your app settings screen.

Ref:
Parameters
  • session – (Optional) Requests Session

  • account_id – Zoom Account ID

  • client_id – OAuth app Client ID

  • client_secret – OAuth app Client Secret

Returns

The access token for the app.

zoom_api_helper.utils module

class zoom_api_helper.utils.CustomEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: JSONEncoder

default(o: Any) Any[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
class zoom_api_helper.utils.cached_property(func: Callable[[Any], _T])[source]

Bases: object

Cached property implementation.

Transform a method of a class into a property whose value is computed once and then cached as a normal attribute for the life of the instance. Similar to property(), with the addition of caching. Useful for expensive computed properties of instances that are otherwise effectively immutable.

zoom_api_helper.utils.log_time(func: _F) _F[source]
zoom_api_helper.utils.read_json_file_if_exists(filename: str) dict | list | None[source]
zoom_api_helper.utils.save_json_file(filename: str, data: dict | list)[source]
zoom_api_helper.utils.write_to_csv(out_file: str, rows: list[dict])[source]

zoom_api_helper.v2 module

class zoom_api_helper.v2.ZoomAPI(client_id: str, client_secret: str, account_id: Optional[str] = None, local=False)[source]

Bases: object

Helper client to interact with the Zoom API v2

bulk_create_meetings(col_header_to_kwarg: dict[str, str] = None, *, rows: list[RowType] = None, excel_file: str | os.PathLike[str] = None, max_threads=10, process_row: ProcessRow = None, update_row: UpdateRow = None, out_file: str | os.PathLike[str] = None, default_timezone='UTC', dry_run=False)[source]

POST /users/{userId}/meetings: Use this API to bulk-create meetings, given a list of meetings to create.

If the rows containing meetings to create lives in an Excel (.xlsx) file, then excel_file must be passed in, and contain the filepath of the Excel file to retrieve the meeting details from; else, rows must be passed in with a list of meetings to create.

Note that to read from Excel, the sheet2dict library is required; this can be installed easily via:

$ pip install zoom-api-helper[excel]

col_header_to_kwarg is a mapping of column headers to keyword arguments, as accepted by the create_meeting() method. If the header names are all title-cased versions of the keyword arguments, then this argument does not need to be passed in. See also, constants.CREATE_MEETING_KWARGS for a full list of acceptable keywords for the Create Meeting API; note that these are specified as values in the key-value pairing.

process_row is an optional function or callable that will be called with a copy of each row, or individual meeting info. The function can modify the row in place as desired.

update_row is an optional function or callable that will be called with the HTTP response data from the Create Meetings API, and the associated row from the Excel file. The function can modify the row in place as desired.

If dry_run is enabled, then no API calls will be made, and this function will essentially be a no-op; however, useful logging output is printed for debugging purposes. Enable this parameter along with the setup_logging() helper function, in a debug environment.

How It Works

This function scans in a list of rows containing a list of meetings to create, either from a local file or from the rows parameter. Then, it calls process_row on each row, and also retrieves a mapping of column name to keyword argument via col_header_to_kwarg. Then, it concurrently creates a list of meetings via the Zoom Create Meetings API. Finally, it calls update_row on each response and row pair, and writes out the updated meeting info to an output CSV file named out_file, which defaults to {excel-file-name-without-ext}}.out.csv if an output filepath is not specified.

References

API documentation:

If a naive datetime object is provided for start_time or any other field (i.e. one with no timezone information) the value for timezone will determine which timezone to associate with the datetime object - defaults to UTC time if not specified.

For a list of supported timezones, please see:
create_meeting(*, session: requests.Session | None = None, host_id: str | None = None, host_email: str | None = None, topic: str = 'My Meeting', agenda: str = 'My Description', start_time: datetime | str | None = None, timezone: str | None = 'UTC', type: Meeting | None = None, **request_data) dict[str, Any][source]

POST /users/{userId}/meetings: Use this API to create a meeting for a user.

Ref:

If a naive datetime object is provided for start_time or any other field (i.e. one with no timezone information) the value for`timezone` will determine which timezone to associate with the datetime object - defaults to UTC time if not specified.

For a list of supported timezones, please see:
Returns

classmethod dummy_client()[source]

Create a dummy ZoomAPI client, for testing purposes.

list_users(status: str | None = 'active', page_size=300, page=1, all_pages=True)[source]

GET /users: Use this API to list your account’s users.

Ref:
Parameters
  • status – The user’s status, one of: active, inactive, pending

  • page_size – The number of records returned within a single API call.

  • page – The page number of the current page in the returned records.

  • all_pages – True to paginate and retrieve all records (pages).

Returns

A dict object, where the users key contains a list of users.

user_email_to_id(status: str | None = 'active', *, use_cache=False)[source]

Module contents

Zoom API Helper

Utilities to interact with the Zoom API v2

Sample Usage:

>>> import zoom_api_helper

For full documentation and more advanced usage, please see <https://zoom-api-helper.readthedocs.io>.

copyright
  1. 2022 by Ritvik Nag.

license

MIT, see LICENSE for more details.

class zoom_api_helper.ZoomAPI(client_id: str, client_secret: str, account_id: Optional[str] = None, local=False)[source]

Bases: object

Helper client to interact with the Zoom API v2

bulk_create_meetings(col_header_to_kwarg: dict[str, str] = None, *, rows: list[RowType] = None, excel_file: str | os.PathLike[str] = None, max_threads=10, process_row: ProcessRow = None, update_row: UpdateRow = None, out_file: str | os.PathLike[str] = None, default_timezone='UTC', dry_run=False)[source]

POST /users/{userId}/meetings: Use this API to bulk-create meetings, given a list of meetings to create.

If the rows containing meetings to create lives in an Excel (.xlsx) file, then excel_file must be passed in, and contain the filepath of the Excel file to retrieve the meeting details from; else, rows must be passed in with a list of meetings to create.

Note that to read from Excel, the sheet2dict library is required; this can be installed easily via:

$ pip install zoom-api-helper[excel]

col_header_to_kwarg is a mapping of column headers to keyword arguments, as accepted by the create_meeting() method. If the header names are all title-cased versions of the keyword arguments, then this argument does not need to be passed in. See also, constants.CREATE_MEETING_KWARGS for a full list of acceptable keywords for the Create Meeting API; note that these are specified as values in the key-value pairing.

process_row is an optional function or callable that will be called with a copy of each row, or individual meeting info. The function can modify the row in place as desired.

update_row is an optional function or callable that will be called with the HTTP response data from the Create Meetings API, and the associated row from the Excel file. The function can modify the row in place as desired.

If dry_run is enabled, then no API calls will be made, and this function will essentially be a no-op; however, useful logging output is printed for debugging purposes. Enable this parameter along with the setup_logging() helper function, in a debug environment.

How It Works

This function scans in a list of rows containing a list of meetings to create, either from a local file or from the rows parameter. Then, it calls process_row on each row, and also retrieves a mapping of column name to keyword argument via col_header_to_kwarg. Then, it concurrently creates a list of meetings via the Zoom Create Meetings API. Finally, it calls update_row on each response and row pair, and writes out the updated meeting info to an output CSV file named out_file, which defaults to {excel-file-name-without-ext}}.out.csv if an output filepath is not specified.

References

API documentation:

If a naive datetime object is provided for start_time or any other field (i.e. one with no timezone information) the value for timezone will determine which timezone to associate with the datetime object - defaults to UTC time if not specified.

For a list of supported timezones, please see:
create_meeting(*, session: requests.Session | None = None, host_id: str | None = None, host_email: str | None = None, topic: str = 'My Meeting', agenda: str = 'My Description', start_time: datetime | str | None = None, timezone: str | None = 'UTC', type: Meeting | None = None, **request_data) dict[str, Any][source]

POST /users/{userId}/meetings: Use this API to create a meeting for a user.

Ref:

If a naive datetime object is provided for start_time or any other field (i.e. one with no timezone information) the value for`timezone` will determine which timezone to associate with the datetime object - defaults to UTC time if not specified.

For a list of supported timezones, please see:
Returns

classmethod dummy_client()[source]

Create a dummy ZoomAPI client, for testing purposes.

list_users(status: str | None = 'active', page_size=300, page=1, all_pages=True)[source]

GET /users: Use this API to list your account’s users.

Ref:
Parameters
  • status – The user’s status, one of: active, inactive, pending

  • page_size – The number of records returned within a single API call.

  • page – The page number of the current page in the returned records.

  • all_pages – True to paginate and retrieve all records (pages).

Returns

A dict object, where the users key contains a list of users.

user_email_to_id(status: str | None = 'active', *, use_cache=False)[source]
zoom_api_helper.setup_logging(default_level: LevelType = 10, lib_level: LevelType = 10, urllib3_level: LevelType = 30)[source]

Sets up logging for application (user) code.