Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

I'm writing code to validate YouTube URLs. Is it guaranteed that the video ID, such as oHg5SJYRHA0, is always exactly 11 characters long, or can it sometimes be shorter or longer? Is there any official documentation about this?

share|improve this question

migrated from stackoverflow.com Mar 26 '11 at 10:36

This question came from our site for professional and enthusiast programmers.

    
At least until 5.20e+19 videos are made ;) –  Jason McCreary Mar 26 '11 at 2:17
    
@Jason damn you! what calculator are you using! –  Saad Mar 26 '11 at 2:23
add comment

2 Answers

up vote 10 down vote accepted

They'll probably stick to 11 chars for a long time. Each character has 64 possible values:

2*26 letters (lowercase and uppercase) + 10 for the digits, + 2 for "_" and "-" chars

2 * 26 + 10 + 2 = 64

Then 11 characters in total:

64^11 = 73786976294838210000 (or more or less "73,7e18")

Of course not all combination will be used, depending on their algorithm, but they are probably not going to change it anytime soon. Words from a YouTube developer state that they do not guarantee, though: http://osdir.com/ml/youtube-api-gdata/2009-10/msg00237.html

share|improve this answer
    
@Diego: If you're going to cite so many digits, you may as well show the last few: 64^11 = 2^66 = 73,786,976,294,838,206,464 With 0.5 rounding, the engineering form is 73.787e18 . –  Oahu Hawaii Feb 9 at 21:46
add comment

Yes, they always have 11 characters.

share|improve this answer
2  
Do you have any information to back that up? –  Al E. Jun 15 '12 at 13:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.