You must declare the 'downloads' permission in the extension manifest to use this API.
{ 'name': 'My extension', ... 'permissions': ['downloads'], ... }
You can find simple examples of using the downloads module in the examples/api/downloads directory. For other examples and for help in viewing the source code, see Samples.