--- layout: template title: API - pyatv permalink: /api// link_group: api ---

# Module `pyatv`

Main routines for interacting with an Apple TV.

Browse git

## Sub-modules

`pyatv.conf`

  Configuration used when connecting to a device …

`pyatv.const`

  Constants used in the public API.

`pyatv.convert`

  Various types of extraction and conversion functions.

`pyatv.exceptions`

  Local exceptions used by library.

`pyatv.helpers`

  Various helper methods.

`pyatv.interface`

  Public interface exposed by library …

`pyatv.settings`

  Settings for configuring pyatv.

`pyatv.storage`

  Storage module.

## Functions

`async def connect(config: BaseConfig, loop: asyncio.events.AbstractEventLoop, protocol: Optional[Protocol] = None, session: Optional[aiohttp.client.ClientSession] = None, storage: Optional[Storage] = None) -> AppleTV`

  Connect to a device based on a configuration.

  Browse git
`async def pair(config: BaseConfig, protocol: Protocol, loop: asyncio.events.AbstractEventLoop, session: aiohttp.client.ClientSession = None, storage: Optional[Storage] = None, **kwargs) -> PairingHandler`

  Pair a protocol for an Apple TV.

  Browse git
`async def scan(loop: asyncio.events.AbstractEventLoop, timeout: int = 5, identifier: Union[str, Set[str], None] = None, protocol: Union[Protocol, Set[Protocol], None] = None, hosts: Optional[List[str]] = None, aiozc: Optional[zeroconf.asyncio.AsyncZeroconf] = None, storage: Optional[Storage] = None) -> List[BaseConfig]`

  Scan for Apple TVs on network and return their configurations.

  When passing in an aiozc instance, a ServiceBrowser must be running for all the types in the protocols that being scanned for.

  Browse git