YouTube Icon
PlaylistCalc
CalculatorCompareScheduleBlog
PlaylistCalc

The most accurate YouTube playlist length calculator. Free, fast, and privacy-first.

Headquarters:

somewhere in Earth,

Solar System, Milky Way andromeda

Tools

  • Playlist Calculator
  • Compare Playlists
  • Watch Schedule

Resources

  • Blog
  • About
  • Privacy Policy
  • Terms of Service
  • Contact Us
  • Editorial Policy

Supported

  • YouTube Playlists
  • YouTube Music
  • Unlisted Playlists

© 2026 PlaylistCalc. All rights reserved.

✓ 256-bit SSL Secure✓ Privacy Protected

Not affiliated with YouTube or Google LLC.

Back to Blog

Using the YouTube Data API to Get Playlist Duration (Developer Guide)

P

PlaylistCalc Team

Video Analytics Experts

Published May 5, 2026• 8 min read

Prerequisites


  • Google Cloud account
  • YouTube Data API v3 enabled
  • API key or OAuth 2.0 credentials

  • Step 1: Get the Playlist Items


    Use the `playlistItems.list` endpoint to fetch all video IDs in a playlist.


    ```

    GET https://www.googleapis.com/youtube/v3/playlistItems

    ?part=contentDetails

    &playlistId=YOUR_PLAYLIST_ID

    &maxResults=50

    &key=YOUR_API_KEY

    ```


    Step 2: Batch Fetch Video Durations


    Pass up to 50 video IDs at a time to the `videos.list` endpoint:


    ```

    GET https://www.googleapis.com/youtube/v3/videos

    ?part=contentDetails

    &id=VIDEO_ID_1,VIDEO_ID_2,...

    &key=YOUR_API_KEY

    ```


    Step 3: Parse ISO 8601 Duration


    YouTube returns durations in ISO 8601 format (e.g., `PT1H23M45S`). Parse this with a regex:


    PT1H23M45S = 1 hour, 23 minutes, 45 seconds = 5025 seconds


    Step 4: Handle Pagination


    Playlists with more than 50 videos require multiple API calls using the `nextPageToken` field.


    Step 5: Sum and Format


    Sum all durations in seconds, then format as HH:MM:SS.


    API Quota


    Each playlist item fetch costs 1 unit. Each video detail fetch costs 1 unit. Free tier gives 10,000 units/day — enough for ~100 large playlists.


    Ready to calculate your playlist?

    Try our free calculator and get instant results.

    Calculate Now