API Reference

General structure

The API endpoint is

http://IP_ADDRESS:PORT + [/HTTP_ROOT] + /api/v2?apikey=$apikey&cmd=$command

Example:

http://localhost:8181/api/v2?apikey=66198313a092496b8a725867d2223b5f&cmd=get_metadata&rating_key=153037

Response example (default json)

{
    "response": {
        "data": [
            {
                "loglevel": "INFO",
                "msg": "Signal 2 caught, saving and exiting...",
                "thread": "MainThread",
                "time": "22-sep-2015 01:42:56 "
            }
        ],
        "message": null,
        "result": "success"
    }
}
General optional parameters:

    out_type:   "json" or "xml"
    callback:   "pong"
    debug:      1

API methods

add_newsletter_config

Add a new notification agent.

Required parameters:
    agent_id (int):           The newsletter type to add

Optional parameters:
    None

Returns:
    None

add_notifier_config

Add a new notification agent.

Required parameters:
    agent_id (int):           The notification agent to add

Optional parameters:
    None

Returns:
    None

arnold

Get to the chopper!

backup_config

Create a manual backup of the config.ini file.

backup_db

Create a manual backup of the plexpy.db file.

delete_all_library_history

Delete all Tautulli history for a specific library.

Required parameters:
    server_id (str):        The Plex server identifier of the library section
    section_id (str):       The id of the Plex library section

Optional parameters:
    row_ids (str):          Comma separated row ids to delete, e.g. "2,3,8"

Returns:
    None

delete_all_user_history

Delete all Tautulli history for a specific user.

Required parameters:
    user_id (str):          The id of the Plex user

Optional parameters:
    row_ids (str):          Comma separated row ids to delete, e.g. "2,3,8"

Returns:
    None

delete_cache

Delete and recreate the cache directory.

delete_export

Delete exports from Tautulli.

Required parameters:
    export_id (int):          The row id of the exported file to delete

Optional parameters:
    delete_all (bool):        'true' to delete all exported files

Returns:
    None

delete_history

Delete history rows from Tautulli.

Required parameters:
    row_ids (str):          Comma separated row ids to delete, e.g. "65,110,2,3645"

Optional parameters:
    None

Returns:
    None

delete_hosted_images

Delete the images uploaded to image hosting services.

Required parameters:
    None

Optional parameters:
    rating_key (int):       1234
                            (Note: Must be the movie, show, season, artist, or album rating key)
    service (str):          'imgur' or 'cloudinary'
    delete_all (bool):      'true' to delete all images form the service

Returns:
    json:
        {"result": "success",
         "message": "Deleted hosted images from Imgur."}

delete_image_cache

Delete and recreate the image cache directory.

delete_library

Delete a library section from Tautulli. Also erases all history for the library.

Required parameters:
    server_id (str):        The Plex server identifier of the library section
    section_id (str):       The id of the Plex library section

Optional parameters:
    row_ids (str):          Comma separated row ids to delete, e.g. "2,3,8"

Returns:
    None

delete_login_log

Delete the Tautulli login logs.

Required paramters:
    None

Optional parameters:
    None

Returns:
    None

delete_lookup_info

Delete the 3rd party API lookup info.

Required parameters:
    None

Optional parameters:
    rating_key (int):       1234
                            (Note: Must be the movie, show, artist, album, or track rating key)
    service (str):          'themoviedb' or 'tvmaze' or 'musicbrainz'
    delete_all (bool):      'true' to delete all images form the service

Returns:
    json:
        {"result": "success",
         "message": "Deleted lookup info."}

delete_media_info_cache

Delete the media info table cache for a specific library.

Required parameters:
    section_id (str):       The id of the Plex library section

Optional parameters:
    None

Returns:
    None

delete_mobile_device

Remove a mobile device from the database.

Required parameters:
    mobile_device_id (int):        The mobile device database id to delete, OR
    device_id (str):               The unique device identifier for the mobile device

Optional parameters:
    None

Returns:
    None

delete_newsletter

Remove a newsletter from the database.

Required parameters:
    newsletter_id (int):        The newsletter to delete

Optional parameters:
    None

Returns:
    None

delete_newsletter_log

Delete the Tautulli newsletter logs.

Required paramters:
    None

Optional parameters:
    None

Returns:
    None

delete_notification_log

Delete the Tautulli notification logs.

Required paramters:
    None

Optional parameters:
    None

Returns:
    None

delete_notifier

Remove a notifier from the database.

Required parameters:
    notifier_id (int):        The notifier to delete

Optional parameters:
    None

Returns:
    None

delete_recently_added

Flush out all of the recently added items in the database.

delete_synced_item

Delete a synced item from a device.

Required parameters:
    client_id (str):        The client ID of the device to delete from
    sync_id (str):          The sync ID of the synced item

Optional parameters:
    None

Returns:
    None

delete_temp_sessions

Flush out all of the temporary sessions in the database.

delete_user

Delete a user from Tautulli. Also erases all history for the user.

Required parameters:
    user_id (str):          The id of the Plex user

Optional parameters:
    row_ids (str):          Comma separated row ids to delete, e.g. "2,3,8"

Returns:
    None

docs

Return the api docs as a dict where commands are keys, docstring are value.

docs_md

Return the api docs formatted with markdown.

download_config

Download the Tautulli configuration file.

download_database

Download the Tautulli database file.

download_export

Download an exported metadata file

Required parameters:
    export_id (int):          The row id of the exported file to download

Optional parameters:
    None

Returns:
    download

download_log

Download the Tautulli log file.

download_plex_log

Download the Plex log file.

edit_library

Update a library section on Tautulli.

Required parameters:
    section_id (str):           The id of the Plex library section
    custom_thumb (str):         The URL for the custom library thumbnail
    custom_art (str):           The URL for the custom library background art
    keep_history (int):         0 or 1

Optional parameters:
    None

Returns:
    None

edit_user

Update a user on Tautulli.

Required parameters:
    user_id (str):              The id of the Plex user
    friendly_name(str):         The friendly name of the user
    custom_thumb (str):         The URL for the custom user thumbnail
    keep_history (int):         0 or 1
    allow_guest (int):          0 or 1

Optional paramters:
    None

Returns:
    None

export_metadata

Export library or media metadata to a file

Required parameters:
    section_id (int):          The section id of the library items to export, OR
    user_id (int):             The user id of the playlist items to export, OR
    rating_key (int):          The rating key of the media item to export

Optional parameters:
    file_format (str):         csv (default), json, xml, or m3u8
    metadata_level (int):      The level of metadata to export (default 1)
    media_info_level (int):    The level of media info to export (default 1)
    thumb_level (int):         The level of poster/cover images to export (default 0)
    art_level (int):           The level of background artwork images to export (default 0)
    custom_fields (str):       Comma separated list of custom fields to export
                               in addition to the export level selected
    export_type (str):         'collection' or 'playlist' for library/user export,
                               otherwise default to all library items
    individual_files (bool):   Export each item as an individual file for library/user export.

Returns:
    json:
        {"result": "success",
         "message": "Metadata export has started."
         }

get_activity

Get the current activity on the PMS.

Required parameters:
    None

Optional parameters:
    session_key (int):    Session key for the session info to return, OR
    session_id (str):     Session ID for the session info to return

Returns:
    json:
        {"lan_bandwidth": 25318,
         "sessions": [
             {
                 "actors": [
                     "Kit Harington",
                     "Emilia Clarke",
                     "Isaac Hempstead-Wright",
                     "Maisie Williams",
                     "Liam Cunningham",
                 ],
                 "added_at": "1461572396",
                 "allow_guest": 1,
                 "art": "/library/metadata/1219/art/1503306930",
                 "aspect_ratio": "1.78",
                 "audience_rating": "",
                 "audience_rating_image": "rottentomatoes://image.rating.upright",
                 "audio_bitrate": "384",
                 "audio_bitrate_mode": "",
                 "audio_channel_layout": "5.1(side)",
                 "audio_channels": "6",
                 "audio_codec": "ac3",
                 "audio_decision": "direct play",
                 "audio_language": "",
                 "audio_language_code": "",
                 "audio_profile": "",
                 "audio_sample_rate": "48000",
                 "bandwidth": "25318",
                 "banner": "/library/metadata/1219/banner/1503306930",
                 "bif_thumb": "/library/parts/274169/indexes/sd/1000",
                 "bitrate": "10617",
                 "channel_call_sign": "",
                 "channel_identifier": "",
                 "channel_stream": 0,
                 "channel_thumb": "",
                 "children_count": "",
                 "collections": [],
                 "container": "mkv",
                 "container_decision": "direct play",
                 "content_rating": "TV-MA",
                 "deleted_user": 0,
                 "device": "Windows",
                 "directors": [
                     "Jeremy Podeswa"
                 ],
                 "do_notify": 0,
                 "duration": "2998272",
                 "email": "Jon.Snow.1337@CastleBlack.com",
                 "file": "/media/TV Shows/Game of Thrones/Season 06/Game of Thrones - S06E01 - The Red Woman.mkv",
                 "file_size": "3979115377",
                 "friendly_name": "Jon Snow",
                 "full_title": "Game of Thrones - The Red Woman",
                 "genres": [
                     "Adventure",
                     "Drama",
                     "Fantasy"
                 ],
                 "grandparent_guid": "com.plexapp.agents.thetvdb://121361?lang=en",
                 "grandparent_rating_key": "1219",
                 "grandparent_thumb": "/library/metadata/1219/thumb/1503306930",
                 "grandparent_title": "Game of Thrones",
                 "guid": "com.plexapp.agents.thetvdb://121361/6/1?lang=en",
                 "height": "1078",
                 "id": "",
                 "indexes": 1,
                 "ip_address": "10.10.10.1",
                 "ip_address_public": "64.123.23.111",
                 "is_admin": 1,
                 "is_allow_sync": 1,
                 "is_home_user": 1,
                 "is_restricted": 0,
                 "keep_history": 1,
                 "labels": [],
                 "last_viewed_at": "1462165717",
                 "library_name": "TV Shows",
                 "live": 0,
                 "live_uuid": "",
                 "local": "1",
                 "location": "lan",
                 "machine_id": "lmd93nkn12k29j2lnm",
                 "media_index": "1",
                 "media_type": "episode",
                 "optimized_version": 0,
                 "optimized_version_profile": "",
                 "optimized_version_title": "",
                 "original_title": "",
                 "originally_available_at": "2016-04-24",
                 "parent_guid": "com.plexapp.agents.thetvdb://121361/6?lang=en",
                 "parent_media_index": "6",
                 "parent_rating_key": "153036",
                 "parent_thumb": "/library/metadata/153036/thumb/1503889210",
                 "parent_title": "Season 6",
                 "platform": "Plex Media Player",
                 "platform_name": "plex",
                 "platform_version": "2.4.1.787-54a020cd",
                 "player": "Castle-PC",
                 "product": "Plex Media Player",
                 "product_version": "3.35.2",
                 "profile": "Konvergo",
                 "progress_percent": "0",
                 "quality_profile": "Original",
                 "rating": "7.8",
                 "rating_image": "rottentomatoes://image.rating.ripe",
                 "rating_key": "153037",
                 "relay": 0,
                 "section_id": "2",
                 "secure": 1,
                 "session_id": "helf15l3rxgw01xxe0jf3l3d",
                 "session_key": "27",
                 "shared_libraries": [
                     "10",
                     "1",
                     "4",
                     "5",
                     "15",
                     "20",
                     "2"
                 ],
                 "sort_title": "Red Woman",
                 "state": "playing",
                 "stream_aspect_ratio": "1.78",
                 "stream_audio_bitrate": "384",
                 "stream_audio_bitrate_mode": "",
                 "stream_audio_channel_layout": "5.1(side)",
                 "stream_audio_channel_layout_": "5.1(side)",
                 "stream_audio_channels": "6",
                 "stream_audio_codec": "ac3",
                 "stream_audio_decision": "direct play",
                 "stream_audio_language": "",
                 "stream_audio_language_code": "",
                 "stream_audio_sample_rate": "48000",
                 "stream_bitrate": "10617",
                 "stream_container": "mkv",
                 "stream_container_decision": "direct play",
                 "stream_duration": "2998272",
                 "stream_subtitle_codec": "",
                 "stream_subtitle_container": "",
                 "stream_subtitle_decision": "",
                 "stream_subtitle_forced": 0,
                 "stream_subtitle_format": "",
                 "stream_subtitle_language": "",
                 "stream_subtitle_language_code": "",
                 "stream_subtitle_location": "",
                 "stream_video_bit_depth": "8",
                 "stream_video_bitrate": "10233",
                 "stream_video_chroma_subsampling": "4:2:0",
                 "stream_video_codec": "h264",
                 "stream_video_codec_level": "41",
                 "stream_video_color_primaries": "",
                 "stream_video_color_range": "tv",
                 "stream_video_color_space": "bt709",
                 "stream_video_color_trc": "",
                 "stream_video_decision": "direct play",
                 "stream_video_dynamic_range": "SDR",
                 "stream_video_framerate": "24p",
                 "stream_video_full_resolution": "1080p",
                 "stream_video_height": "1078",
                 "stream_video_language": "",
                 "stream_video_language_code": "",
                 "stream_video_ref_frames": "4",
                 "stream_video_resolution": "1080",
                 "stream_video_scan_type": "progressive",
                 "stream_video_width": "1920",
                 "studio": "HBO",
                 "subtitle_codec": "",
                 "subtitle_container": "",
                 "subtitle_decision": "",
                 "subtitle_forced": 0,
                 "subtitle_format": "",
                 "subtitle_language": "",
                 "subtitle_language_code": "",
                 "subtitle_location": "",
                 "subtitles": 0,
                 "summary": "Jon Snow is dead. Daenerys meets a strong man. Cersei sees her daughter again.",
                 "synced_version": 0,
                 "synced_version_profile": "",
                 "tagline": "",
                 "throttled": "0",
                 "thumb": "/library/metadata/153037/thumb/1503889207",
                 "title": "The Red Woman",
                 "transcode_audio_channels": "",
                 "transcode_audio_codec": "",
                 "transcode_container": "",
                 "transcode_decision": "direct play",
                 "transcode_height": "",
                 "transcode_hw_decode": "",
                 "transcode_hw_decode_title": "",
                 "transcode_hw_decoding": 0,
                 "transcode_hw_encode": "",
                 "transcode_hw_encode_title": "",
                 "transcode_hw_encoding": 0,
                 "transcode_hw_full_pipeline": 0,
                 "transcode_hw_requested": 0,
                 "transcode_key": "",
                 "transcode_progress": 0,
                 "transcode_protocol": "",
                 "transcode_speed": "",
                 "transcode_throttled": 0,
                 "transcode_video_codec": "",
                 "transcode_width": "",
                 "type": "",
                 "updated_at": "1503889207",
                 "user": "LordCommanderSnow",
                 "user_id": 133788,
                 "user_rating": "",
                 "user_thumb": "https://plex.tv/users/k10w42309cynaopq/avatar",
                 "username": "LordCommanderSnow",
                 "video_bit_depth": "8",
                 "video_bitrate": "10233",
                 "video_chroma_subsampling": "4:2:0",
                 "video_codec": "h264",
                 "video_codec_level": "41",
                 "video_color_primaries": "",
                 "video_color_range": "tv",
                 "video_color_space": "bt709",
                 "video_color_trc": ",
                 "video_decision": "direct play",
                 "video_dynamic_range": "SDR",
                 "video_frame_rate": "23.976",
                 "video_framerate": "24p",
                 "video_full_resolution": "1080p",
                 "video_height": "1078",
                 "video_language": "",
                 "video_language_code": "",
                 "video_profile": "high",
                 "video_ref_frames": "4",
                 "video_resolution": "1080",
                 "video_scan_type": "progressive",
                 "video_width": "1920",
                 "view_offset": "1000",
                 "width": "1920",
                 "writers": [
                     "David Benioff",
                     "D. B. Weiss"
                 ],
                 "year": "2016"
             }
         ],
         "stream_count": "1",
         "stream_count_direct_play": 1,
         "stream_count_direct_stream": 0,
         "stream_count_transcode": 0,
         "total_bandwidth": 25318,
         "wan_bandwidth": 0
         }

get_apikey

Get the apikey. Username and password are required if auth is enabled. Makes and saves the apikey if it does not exist.

Required parameters:
    None

Optional parameters:
    username (str):     Your Tautulli username
    password (str):     Your Tautulli password

Returns:
    string:             "apikey"

get_children_metadata

Get the metadata for the children of a media item.

Required parameters:
    rating_key (str):       Rating key of the item
    media_type (str):       Media type of the item

Optional parameters:
    None

Returns:
    json:
        {"children_count": 9,
         "children_type": "season",
         "title": "Game of Thrones",
         "children_list": [
             {...},
             {"actors": [],
              "added_at": "1403553078",
              "art": "/library/metadata/1219/art/1562110346",
              "audience_rating": "",
              "audience_rating_image": "",
              "banner": "",
              "content_rating": "",
              "directors": [],
              "duration": "",
              "full_title": "Season 1"
              "genres": [],
              "grandparent_rating_key": "",
              "grandparent_thumb": "",
              "grandparent_title": "",
              "guid": "com.plexapp.agents.thetvdb://121361/1?lang=en",
              "labels": [],
              "last_viewed_at": "1589992348",
              "library_name": "TV Shows",
              "media_index": "1",
              "media_type": "season",
              "original_title": "",
              "originally_available_at": "",
              "parent_media_index": "1",
              "parent_rating_key": "1219",
              "parent_thumb": "/library/metadata/1219/thumb/1562110346",
              "parent_title": "Game of Thrones",
              "rating": "",
              "rating_image": "",
              "rating_key": "1220",
              "section_id": "2",
              "sort_title": "",
              "studio": "",
              "summary": "",
              "tagline": "",
              "thumb": "/library/metadata/1220/thumb/1602176313",
              "title": "Season 1",
              "updated_at": "1602176313",
              "user_rating": "",
              "writers": [],
              "year": ""
              },
              {...},
              {...}
             ]
         }

get_collections_table

Get the data on the Tautulli collections tables.

Required parameters:
    section_id (str):               The id of the Plex library section

Optional parameters:
    None

Returns:
    json:
        {"draw": 1,
         "recordsTotal": 5,
         "data":
            [...]
         }

get_date_formats

Get the date and time formats used by Tautulli.

Required parameters:
    None

Optional parameters:
    None

Returns:
    json:
        {"date_format": "YYYY-MM-DD",
         "time_format": "HH:mm",
         }

get_export_fields

Get a list of available custom export fields.

Required parameters:
    media_type (str):          The media type of the fields to return

Optional parameters:
    sub_media_type (str):      The child media type for
                               collections (movie, show, artist, album, photoalbum),
                               or playlists (video, audio, photo)

Returns:
    json:
        {"metadata_fields":
            [{"field": "addedAt", "level": 1},
             ...
             ],
         "media_info_fields":
            [{"field": "media.aspectRatio", "level": 1},
             ...
             ]
        }

get_exports_table

Get the data on the Tautulli export tables.

Required parameters:
    section_id (str):               The id of the Plex library section, OR
    user_id (str):                  The id of the Plex user, OR
    rating_key (str):               The rating key of the exported item

Optional parameters:
    order_column (str):             "added_at", "sort_title", "container", "bitrate", "video_codec",
                                    "video_resolution", "video_framerate", "audio_codec", "audio_channels",
                                    "file_size", "last_played", "play_count"
    order_dir (str):                "desc" or "asc"
    start (int):                    Row to start from, 0
    length (int):                   Number of items to return, 25
    search (str):                   A string to search for, "Thrones"

Returns:
    json:
        {"draw": 1,
         "recordsTotal": 10,
         "recordsFiltered": 3,
         "data":
            [{"timestamp": 1602823644,
              "art_level": 0,
              "complete": 1,
              "custom_fields": "",
              "exists": true,
              "export_id": 42,
              "exported_items": 28,
              "file_format": "json",
              "file_size": 57793562,
              "filename": null,
              "individual_files": 1,
              "media_info_level": 1,
              "media_type": "collection",
              "media_type_title": "Collection",
              "metadata_level": 1,
              "rating_key": null,
              "section_id": 1,
              "thumb_level": 2,
              "title": "Library - Movies - Collection [1]",
              "total_items": 28,
              "user_id": null
              },
             {...},
             {...}
             ]
         }

get_geoip_lookup

Get the geolocation info for an IP address.

Required parameters:
    ip_address

Optional parameters:
    None

Returns:
    json:
        {"code": 'US",
         "country": "United States",
         "region": "California",
         "city": "Mountain View",
         "postal_code": "94035",
         "timezone": "America/Los_Angeles",
         "latitude": 37.386,
         "longitude": -122.0838,
         "accuracy": 1000
         }

get_history

Get the Tautulli history.

Required parameters:
    None

Optional parameters:
    grouping (int):                 0 or 1
    include_activity (int):         0 or 1
    user (str):                     "Jon Snow"
    user_id (int):                  133788
    rating_key (int):               4348
    parent_rating_key (int):        544
    grandparent_rating_key (int):   351
    start_date (str):               "YYYY-MM-DD"
    section_id (int):               2
    media_type (str):               "movie", "episode", "track", "live"
    transcode_decision (str):       "direct play", "copy", "transcode",
    guid (str):                     Plex guid for an item, e.g. "com.plexapp.agents.thetvdb://121361/6/1"
    order_column (str):             "date", "friendly_name", "ip_address", "platform", "player",
                                    "full_title", "started", "paused_counter", "stopped", "duration"
    order_dir (str):                "desc" or "asc"
    start (int):                    Row to start from, 0
    length (int):                   Number of items to return, 25
    search (str):                   A string to search for, "Thrones"

Returns:
    json:
        {"draw": 1,
         "recordsTotal": 1000,
         "recordsFiltered": 250,
         "total_duration": "42 days 5 hrs 18 mins",
         "filter_duration": "10 hrs 12 mins",
         "data":
            [{"date": 1462687607,
              "duration": 263,
              "friendly_name": "Mother of Dragons",
              "full_title": "Game of Thrones - The Red Woman",
              "grandparent_rating_key": 351,
              "grandparent_title": "Game of Thrones",
              "original_title": "",
              "group_count": 1,
              "group_ids": "1124",
              "guid": "com.plexapp.agents.thetvdb://121361/6/1?lang=en",
              "ip_address": "xxx.xxx.xxx.xxx",
              "live": 0,
              "machine_id": "lmd93nkn12k29j2lnm",
              "media_index": 17,
              "media_type": "episode",
              "originally_available_at": "2016-04-24",
              "parent_media_index": 7,
              "parent_rating_key": 544,
              "parent_title": "",
              "paused_counter": 0,
              "percent_complete": 84,
              "platform": "Windows",
              "product": "Plex for Windows",
              "player": "Castle-PC",
              "rating_key": 4348,
              "reference_id": 1123,
              "row_id": 1124,
              "session_key": null,
              "started": 1462688107,
              "state": null,
              "stopped": 1462688370,
              "thumb": "/library/metadata/4348/thumb/1462414561",
              "title": "The Red Woman",
              "transcode_decision": "transcode",
              "user": "DanyKhaleesi69",
              "user_id": 8008135,
              "watched_status": 0,
              "year": 2016
              },
             {...},
             {...}
             ]
         }

get_home_stats

Get the homepage watch statistics.

Required parameters:
    None

Optional parameters:
    grouping (int):         0 or 1
    time_range (int):       The time range to calculate statistics, 30
    stats_type (str):       'plays' or 'duration'
    stats_start (int)       The row number of the stat item to start at, 0
    stats_count (int):      The number of stat items to return, 5
    stat_id (str):          A single stat to return, 'top_movies', 'popular_movies',
                            'top_tv', 'popular_tv', 'top_music', 'popular_music', 'top_libraries',
                            'top_users', 'top_platforms', 'last_watched', 'most_concurrent'

Returns:
    json:
        [{"stat_id": "top_movies",
          "stat_type": "total_plays",
          "rows": [{...}]
          },
         {"stat_id": "popular_movies",
          "rows": [{...}]
          },
         {"stat_id": "top_tv",
          "stat_type": "total_plays",
          "rows":
            [{"content_rating": "TV-MA",
              "friendly_name": "",
              "grandparent_thumb": "/library/metadata/1219/thumb/1462175063",
              "guid": "com.plexapp.agents.thetvdb://121361/6/1?lang=en",
              "labels": [],
              "last_play": 1462380698,
              "live": 0,
              "media_type": "episode",
              "platform": "",
              "platform_type": "",
              "rating_key": 1219,
              "row_id": 1116,
              "section_id": 2,
              "thumb": "",
              "title": "Game of Thrones",
              "total_duration": 213302,
              "total_plays": 69,
              "user": "",
              "users_watched": ""
              },
             {...},
             {...}
             ]
          },
         {"stat_id": "popular_tv",
          "rows": [{...}]
          },
         {"stat_id": "top_music",
          "stat_type": "total_plays",
          "rows": [{...}]
          },
         {"stat_id": "popular_music",
          "rows": [{...}]
          },
         {"stat_id": "last_watched",
          "rows": [{...}]
          },
         {"stat_id": "top_libraries",
          "stat_type": "total_plays",
          "rows": [{...}]
          },
         {"stat_id": "top_users",
          "stat_type": "total_plays",
          "rows": [{...}]
          },
         {"stat_id": "top_platforms",
          "stat_type": "total_plays",
          "rows": [{...}]
          },
         {"stat_id": "most_concurrent",
          "rows": [{...}]
          }
         ]

get_libraries

Get a list of all libraries on your server.

Required parameters:
    None

Optional parameters:
    None

Returns:
    json:
        [{"art": "/:/resources/show-fanart.jpg",
          "child_count": "3745",
          "count": "62",
          "is_active": 1,
          "parent_count": "240",
          "section_id": "2",
          "section_name": "TV Shows",
          "section_type": "show",
          "thumb": "/:/resources/show.png"
          },
         {...},
         {...}
         ]

get_libraries_table

Get the data on the Tautulli libraries table.

Required parameters:
    None

Optional parameters:
    grouping (int):                 0 or 1
    order_column (str):             "library_thumb", "section_name", "section_type", "count", "parent_count",
                                    "child_count", "last_accessed", "last_played", "plays", "duration"
    order_dir (str):                "desc" or "asc"
    start (int):                    Row to start from, 0
    length (int):                   Number of items to return, 25
    search (str):                   A string to search for, "Movies"

Returns:
    json:
        {"draw": 1,
         "recordsTotal": 10,
         "recordsFiltered": 10,
         "data":
            [{"child_count": 3745,
              "content_rating": "TV-MA",
              "count": 62,
              "do_notify": "Checked",
              "do_notify_created": "Checked",
              "duration": 1578037,
              "guid": "com.plexapp.agents.thetvdb://121361/6/1?lang=en",
              "histroy_row_id": 1128,
              "is_active": 1,
              "keep_history": "Checked",
              "labels": [],
              "last_accessed": 1462693216,
              "last_played": "Game of Thrones - The Red Woman",
              "library_art": "/:/resources/show-fanart.jpg",
              "library_thumb": "/:/resources/show.png",
              "live": 0,
              "media_index": 1,
              "media_type": "episode",
              "originally_available_at": "2016-04-24",
              "parent_count": 240,
              "parent_media_index": 6,
              "parent_title": "",
              "plays": 772,
              "rating_key": 153037,
              "row_id": 1,
              "section_id": 2,
              "section_name": "TV Shows",
              "section_type": "Show",
              "server_id": "ds48g4r354a8v9byrrtr697g3g79w",
              "thumb": "/library/metadata/153036/thumb/1462175062",
              "year": 2016
              },
             {...},
             {...}
             ]
         }

get_library

Get a library's details.

Required parameters:
    section_id (str):               The id of the Plex library section

Optional parameters:
    include_last_accessed (bool):   True to include the last_accessed value for the library.

Returns:
    json:
        {"child_count": null,
         "count": 887,
         "deleted_section": 0,
         "do_notify": 1,
         "do_notify_created": 1,
         "is_active": 1,
         "keep_history": 1,
         "last_accessed": 1462693216,
         "library_art": "/:/resources/movie-fanart.jpg",
         "library_thumb": "/:/resources/movie.png",
         "parent_count": null,
         "row_id": 1,
         "section_id": 1,
         "section_name": "Movies",
         "section_type": "movie",
         "server_id": "ds48g4r354a8v9byrrtr697g3g79w"
         }

get_library_media_info

Get the data on the Tautulli media info tables.

Required parameters:
    section_id (str):               The id of the Plex library section, OR
    rating_key (str):               The grandparent or parent rating key

Optional parameters:
    section_type (str):             "movie", "show", "artist", "photo"
    order_column (str):             "added_at", "sort_title", "container", "bitrate", "video_codec",
                                    "video_resolution", "video_framerate", "audio_codec", "audio_channels",
                                    "file_size", "last_played", "play_count"
    order_dir (str):                "desc" or "asc"
    start (int):                    Row to start from, 0
    length (int):                   Number of items to return, 25
    search (str):                   A string to search for, "Thrones"
    refresh (str):                  "true" to refresh the media info table

Returns:
    json:
        {"draw": 1,
         "recordsTotal": 82,
         "recordsFiltered": 82,
         "filtered_file_size": 2616760056742,
         "total_file_size": 2616760056742,
         "data":
            [{"added_at": "1403553078",
              "audio_channels": "",
              "audio_codec": "",
              "bitrate": "",
              "container": "",
              "file_size": 253660175293,
              "grandparent_rating_key": "",
              "last_played": 1462380698,
              "media_index": "1",
              "media_type": "show",
              "parent_media_index": "",
              "parent_rating_key": "",
              "play_count": 15,
              "rating_key": "1219",
              "section_id": 2,
              "section_type": "show",
              "sort_title": "Game of Thrones",
              "thumb": "/library/metadata/1219/thumb/1436265995",
              "title": "Game of Thrones",
              "video_codec": "",
              "video_framerate": "",
              "video_resolution": "",
              "year": "2011"
              },
             {...},
             {...}
             ]
         }

get_library_names

Get a list of library sections and ids on the PMS.

Required parameters:
    None

Optional parameters:
    None

Returns:
    json:
        [{"section_id": 1, "section_name": "Movies", "section_type": "movie"},
         {"section_id": 7, "section_name": "Music", "section_type": "artist"},
         {"section_id": 2, "section_name": "TV Shows", "section_type": "show"},
         {...}
         ]

get_library_user_stats

Get a library's user statistics.

Required parameters:
    section_id (str):               The id of the Plex library section

Optional parameters:
    grouping (int):         0 or 1

Returns:
    json:
        [{"friendly_name": "Jon Snow",
          "total_plays": 170,
          "user_id": 133788,
          "user_thumb": "https://plex.tv/users/k10w42309cynaopq/avatar",
          "username": "LordCommanderSnow"
          },
         {"friendly_name": "DanyKhaleesi69",
          "total_plays": 42,
          "user_id": 8008135,
          "user_thumb": "https://plex.tv/users/568gwwoib5t98a3a/avatar",
          "username: "DanyKhaleesi69"
          },
         {...},
         {...}
         ]

get_library_watch_time_stats

Get a library's watch time statistics.

Required parameters:
    section_id (str):       The id of the Plex library section

Optional parameters:
    grouping (int):         0 or 1
    query_days (str):       Comma separated days, e.g. "1,7,30,0"

Returns:
    json:
        [{"query_days": 1,
          "total_plays": 0,
          "total_time": 0
          },
         {"query_days": 7,
          "total_plays": 3,
          "total_time": 15694
          },
         {"query_days": 30,
          "total_plays": 35,
          "total_time": 63054
          },
         {"query_days": 0,
          "total_plays": 508,
          "total_time": 1183080
          }
         ]

get_logs

Get the Tautulli logs.

Required parameters:
    None

Optional parameters:
    sort (str):         "time", "thread", "msg", "loglevel"
    search (str):       A string to search for
    order (str):        "desc" or "asc"
    regex (str):        A regex string to search for
    start (int):        Row number to start from
    end (int):          Row number to end at

Returns:
    json:
        [{"loglevel": "DEBUG",
          "msg": "Latest version is 2d10b0748c7fa2ee4cf59960c3d3fffc6aa9512b",
          "thread": "MainThread",
          "time": "2016-05-08 09:36:51 "
          },
         {...},
         {...}
         ]

get_metadata

Get the metadata for a media item.

Required parameters:
    rating_key (str):       Rating key of the item, OR
    sync_id (str):          Sync ID of a synced item

Optional parameters:
    None

Returns:
    json:
        {"actors": [
            "Kit Harington",
            "Emilia Clarke",
            "Isaac Hempstead-Wright",
            "Maisie Williams",
            "Liam Cunningham",
         ],
         "added_at": "1461572396",
         "art": "/library/metadata/1219/art/1462175063",
         "audience_rating": "8",
         "audience_rating_image": "rottentomatoes://image.rating.upright",
         "banner": "/library/metadata/1219/banner/1462175063",
         "collections": [],
         "content_rating": "TV-MA",
         "directors": [
            "Jeremy Podeswa"
         ],
         "duration": "2998290",
         "full_title": "Game of Thrones - The Red Woman",
         "genres": [
            "Adventure",
            "Drama",
            "Fantasy"
         ],
         "grandparent_guid": "com.plexapp.agents.thetvdb://121361?lang=en",
         "grandparent_rating_key": "1219",
         "grandparent_thumb": "/library/metadata/1219/thumb/1462175063",
         "grandparent_title": "Game of Thrones",
         "guid": "com.plexapp.agents.thetvdb://121361/6/1?lang=en",
         "guids": [],
         "labels": [],
         "last_viewed_at": "1462165717",
         "library_name": "TV Shows",
         "live": 0,
         "media_index": "1",
         "media_info": [
             {
                 "aspect_ratio": "1.78",
                 "audio_channel_layout": "5.1",
                 "audio_channels": "6",
                 "audio_codec": "ac3",
                 "audio_profile": "",
                 "bitrate": "10617",
                 "channel_call_sign": "",
                 "channel_identifier": "",
                 "channel_thumb": "",
                 "container": "mkv",
                 "height": "1078",
                 "id": "257925",
                 "optimized_version": 0,
                 "parts": [
                     {
                         "file": "/media/TV Shows/Game of Thrones/Season 06/Game of Thrones - S06E01 - The Red Woman.mkv",
                         "file_size": "3979115377",
                         "id": "274169",
                         "indexes": 1,
                         "streams": [
                             {
                                 "id": "511663",
                                 "type": "1",
                                 "video_bit_depth": "8",
                                 "video_bitrate": "10233",
                                 "video_codec": "h264",
                                 "video_codec_level": "41",
                                 "video_color_primaries": "",
                                 "video_color_range": "tv",
                                 "video_color_space": "bt709",
                                 "video_color_trc": "",
                                 "video_frame_rate": "23.976",
                                 "video_height": "1078",
                                 "video_language": "",
                                 "video_language_code": "",
                                 "video_profile": "high",
                                 "video_ref_frames": "4",
                                 "video_scan_type": "progressive",