import typing


def check_apis(apis_string: str) -> typing.Set[str]:
    """
    Check the format for `Relevant API` section.

    :param apis_string: A multiline string containing all APIs.
    :return: A set of APIs. Throws if format is wrong.
    """
    stripped = apis_string.strip()
    apis = list(stripped.splitlines())
    if not apis:
        raise Exception('Empty Relevant APIs.')
    s = set()
    stripped_apis = []
    for api in apis:
        # Bullet is checked by the linter, no need to check here.
        a = api.lstrip('*- ').rstrip()
        s.add(a)
        stripped_apis.append(a)
        if '`' in a:
            raise Exception('API should not include backticks.')
    if '' in s:
        raise Exception('Empty line in APIs.')
    if len(apis) > len(s):
        raise Exception('Duplicate APIs.')
    if stripped_apis != sorted(stripped_apis, key=str.casefold):
        raise Exception('APIs are not sorted.')
    return s