Note: The legacy API is no longer supported for new sign-ups. Please use the new YouTube API instead.
First, you must have a developer ID. If you do not have one, you can request one by creating a developer profile.
As a sneak preview of the ease-of-use of the API, request the following URL in your web browser to request your own user profile:
http://www.youtube.com/api2_rest?method=youtube.users.get_profile&dev_id=YOUR_DEV_ID&user=YOUTUBE_USER_NAME
You should see results like the following:
<?xml version="1.0" encoding="utf-8"?>
<ut_response status="ok">
<user_profile>
<first_name>YouTube</first_name>
<last_name>User</last_name>
<about_me>YouTube rocks!!</about_me>
<age>30</age>
<video_upload_count>7</video_upload_count>
.... and more ....
</user_profile>
</ut_response>
All API calls return an XML document. Successful API calls return an XML document of the following form:
<ut_response status="ok">
... response XML document ...
<ut_response>
Failed API calls return an XML document as follows:
<ut_response status="fail">
<error>
<code>7</code>
<description>Missing dev_id parameter.</description>
</error>
</ut_response>
The code element provides the machine-friendly error code that your application can use to determine the error type and handle it appropriately. The description element provides you with a human-readable description of the error.
There are two styles of API calls that you can mix and match at your convenience, REST and XML-RPC.