This is a python 3.6 (or later) library for controlling and querying information from an Apple TV. It is built upon asyncio and supports most of the commands that the regular Apple Remote app does and more!
To install, use
pip install pyatv
This library is licensed under the MIT license.
Where to start?
As pyatv is a library, it is mainly aimed for developers creating applications that can interact with Apple TVs. However, pyatv ships with a powerful command line application that is useful for normal users as well.
So, head over to Getting started to get going!
If you need help or have questions, check out the Support page instead.
In case you have developed for pyatv 0.3.x before, there’s a short migration guide here that will help you port your code to 0.4.x or later.
Here is the feature list by protocol (DMAP = devices not running tvOS, MRP and Companiom = Apple TV 4 and later, RAOP = AirPlay compatible devices):
|Automatic discovery of devices (zeroconf/Bonjour)||Yes||Yes||Yes||Yes||Concept, Doc, pyatv.scan|
|Device Metadata (e.g. operating system and version)||Yes*||Yes*||No||No||Concept, Doc, interface.DeviceInfo|
|Push updates||Yes||Yes||No||No||Concept, Doc, interface.PushUpdater|
|Remote control pairing||Yes||Yes||Yes||No||Concept, Doc, interface.PairingHandler|
|List supported features||Yes**||Yes||Yes||Yes||Concept, Doc, interface.Features|
|AirPlay stream URL (including local files)||Yes||Yes||No||Yes||Doc, interface.Stream|
|Playback controls (play, pause, next, stop, etc.)||Yes||Yes||No||No||Doc, interface.RemoteControl|
|Navigation controls (select, menu, top_menu, arrow keys)||Yes||Yes||No||No||Doc, interface.RemoteControl|
|Different input actions (tap, double tap, hold)||No||Yes||No||No||Doc, interface.RemoteControl|
|Fetch artwork||Yes||Yes||No||No||Doc, interface.Metadata.artwork|
|Currently playing (e.g. title, artist, album, total time, etc.)||Yes||Yes||No||No||Doc, interface.Metadata|
|App used for playback||No||Yes||No||No||Doc, interface.App|
|Media type and play state||Yes||Yes||No||No||Doc, interface.Metadata|
|Change media position||Yes||Yes||No||No||Doc, interface.Metadata.set_position|
|Shuffle and repeat||Yes||Yes||No||No||Doc, interface.Metadata.set_shuffle, interface.Metadata.set_repeat|
|Volume Controls||Yes||Yes||No||No||Doc, interface.RemoteControl|
|Power management||No||Yes||No||No||Doc, interface.Power|
|Deep Sleep Detection||Yes***||Yes***||No||No||Concept, Doc, pyatv.scan|
|Launch application||No||No||Yes||No||Doc, interface.Apps|
|List installed apps||No||No||Yes||No||Doc, interface.Apps|
* Some restrictions apply, see section “Device Metadata” here page.
** Limited support due to restrictions in protocol.
*** Experimental feature (not fully tested)
This list might be a bit misleading regarding what is supported or not. A better summary is under development. A No in the table does not necessarily mean that a feature is not available for a certain protocol. It either means it’s not, or that it’s just not implemented yet (you can’t tell which it is from the list however).
There are also few utility scripts bundled with
pyatv that makes it easy to try the library
out. Check out atvremote, atvproxy,
atvscript and atvscript.
Who is making this?
I, Pierre Ståhl, is the lead developer and maintainer of this library. It is a hobby project that I put a few hours in every now and then to maintain. If you find it useful, please consider to sponsor me!
Of course, this is an open source project which means I couldn’t do it all by myself. I have created dedicated page for acknowledgements!