The Bandwagon API

  • Revision slug: addons.mozilla.org_(AMO)_API_Developers'_Guide/The_Bandwagon_API
  • Revision title: The Bandwagon API
  • Revision id: 23040
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment one or more formatting changes

Revision Content

Implementation Notes  

Use URLs as resource identifiers

This API spec uses the REST pattern of including resource URLs in responses, rather than database IDs or other identifiers. This allows the server to control its own namespace - so please use the URLs found in href attributes to access the API, rather than constructing them on the client side from templates.

The only URL that should be hardcoded (or preferably kept in a user preference) in the client application is the URL to the service document. This will not only make it easier to switch between production, staging, and dev instances of the API, it will also make the client resilient to other more granular changes in the server URL space. 

Use xml:base to resolve relative URLs

The URLs in response data may be supplied as relative paths, or relative with respect an URL indicated by an xml:base attribute, usually supplied by the root node of the response document.

Use conditional GET

For GET requests, be sure to retain the value of the Last-Modified header in responses and include it as If-Modified-Since in requests. This enables conditional GET and may result in 304 Not Modified responses that indicate the resource has not changed since the last fetch. This can save in both CPU consumption and bandwidth in preparing and sending the response data.

HTTP Method Override Hack

This API uses the HTTP methods GET, POST, PUT, DELETE, and OPTIONS. Some incomplete HTTP clients support only GET and POST methods. So, this API supports the use of POST as a stand-in for any method other than GET, with the actual desired HTTP method supplied via one of the following conventions:

  • A URL query parameter named _method
  • A POST parameter named _method
  • The value of a header named X-HTTP-Method-Override

Authentication

All API access requires authentication.

AMOv3 cookie session ID

If a Cookie: header is sent with the value of an AMOv3 login session ID, that value will be validated first in authenticating the user.

Example header, with the AMOv3 cookie among other cookies:

   Cookie: foo=bar; AMOv3=865ikpjmn6bqh897msr3o5hv12; baz=quux

The primary use-case for this means of authentication is in a browser extension with access to the user's cookie jar and the ability to extract the same cookie used for website login.

HTTP basic auth with email/pass

If no AMOv3 cookie header is found, or if it is invalid, an attempt to authenticate the user with HTTP basic auth will be made. The username is expected to be an email address registered with AMO and the correct password for that account must be supplied.

An example use case for this authentication method is for simpler testing without the need to perform a website login and get a cookie.

Authorization

In general, the client will not be given the URLs of resources to which the authenticated user does not have at least some access (ie. GET-only).

Attempts to manipulate resources to which the authenticated user does not have any permission do to so will receive a response with a 403 Forbidden status code.

Attempts to manipulate resources for which the user has some permission will receive responses with a 405 Method Not Allowed status code, and the Allow: header will list which methods are allowed.

Resources

The following is a catalog of the kinds of resources made available by the API. The URL paths used as headers are conceptual examples, not intended for literal use as templates in the client application.

Also note that not all HTTP methods are avalable for every resource.

Service Document - /api/sharing/

This service document is the main entry point URL for the API. Polling it periodically, with proper attention to Last-Modified and If-Modified-Since headers, should offer a relatively efficient way to track collection subscriptions and what subscriptions are writable.

Beyond collections, the service document will supply URLs leading into the rest of the API. (eg. email sharing)

Concrete examples of this URL might look something like the following:

http://localhost/~lorchard/addons/api.php?action=service_doc
http://dev.addons.mozilla.com/en-US/firefox/api/1.3/sharing
https://preview.addons.mozilla.org/en-US/firefox/api/1.3/sharing
https://addons.mozilla.org/en-US/firefox/api/1.3/sharing
GET - Fetch the service document
  • Response
    • Status: 200 OK
    • Content-Type: #Service Document
    • Response body varies according to authenticated user's context

Collections List - /api/sharing/collections/

This resource represents the set of all shared collections. A concrete URL for this resource can be acquired from the #Service Document.

Note that the GET method is not currently implemented, because the service doc and individual collection docs provide the information that would conceivably be made available. Someday, this could be an interface on the public collection directory.

POST - Create a new collection
  • Request
    • Content-Type: application/x-www-form-urlencoded
    • Parameters:
      • name - human readable name for the collection
      • description - human readable longer description for the collection
      • nickname - unique nickname for collection usable in URLs
      • listed - whether the collection should be listed in the directory (1) or not (0)
  • Response
    • Status: 201 Created
    • Content-Type: #Addon Collection
    • Response body will contain the data for the freshly created collection.
    • Location header points to the URL of new collection.

Collection - /api/sharing/collections/{uuid}

This resource represents a single collection of shared addons. A concrete URL for this kind of resource can be acquired from the #Service Document.

GET - Fetch contents of a collection
PUT - Update collection details

Note that this update is limited to collection-specific details, and cannot modify any of the other data that makes up an addon document.

  • Request
    • Content-Type: application/x-www-form-urlencoded
    • Parameters:
      • name - human readable name for the collection
      • description - human readable longer description for the collection
      • nickname - unique nickname for collection usable in URLs
      • listed - whether the collection should be listed in the directory (1) or not (0)
  • Response (on success)
    • Status: 200 OK
    • Content-Type: #Addon Collection
    • Response content reflects changes to collection
DELETE - Delete a collection
  • Response (on success)
    • Status: 410 Gone

List of Addons in a Collection - /api/sharing/collections/{uuid}/addons/

This resource represents addons in a collection. A concrete URL for this kind of resource can be acquired from the #Service Document.

Note that the GET method is not currently implemented, because the parent collection doc provides the information that would conceivably be made available.

POST - Add an addon to a collection
  • Request
    • Content-Type: application/x-www-form-urlencoded
    • Parameters:
      • guid - GUID of addon to add to list
      • comments - (optional) human readable comments about the addon
  • Response (on success)
    • Status: 201 Created
    • Content-Type: #Addon
    • Response body will contain the data for the freshly added addon.
    • Location header points to the URL of the addon resource in the collection.
  • Response (if addon already present in collection)

Addon in a Collection - /api/sharing/collections/{uuid}/addons/{addon guid}

This resource represents a single addon shared in a collection. A concrete URL for this kind of resource can be acquired from an #Addon Collection.

GET - Fetch details on an addon
  • Response (on success)
    • Status: 200 OK
    • Content-Type: #Addon
PUT - Update addon details

Note that this update is limited to collection-specific details, and cannot modify any of the other data that makes up an addon document.

  • Request
    • Content-Type: application/x-www-form-urlencoded
    • Parameters:
      • comments - human readable comments about the addon
  • Response (on success)
    • Status: 200 OK
    • Content-Type: #Addon
    • Response content reflects changes to addon in collection
DELETE - Remove an addon from a collection
  • Response (on success)
    • Status: 303 See Other
    • Content-Type: #Addon Collection
    • Response body will reflect the change to the collection with addon added or updated.
    • Location header points to the URL of collection, which will reflect the addition or update of the addon.

Email Sharing - /api/sharing/email

This resource offers a general-purpose interface to notification functionality for sharing addons via email messages. A concrete URL for this of resource can be acquired from the #Service Document.

POST - Request an email sharing notification
  • Request
    • Content-Type: application/x-www-form-urlencoded
    • Parameters:
      • to - comma-separated list of email addresses for notification
      • guid - GUID of addon to share
      • comments - human readable personal comments to be included in notification
  • Response (on success)
    • Content-Type: empty body
    • Status: 202 Accepted

Status Codes

Based on HTTP/1.1 Status Code Definitions.

  • 200 OK - Request OK, response body follows.
  • 201 Created - New resource created, response body follows with new content, watch for Location: header containing new resource URL
  • 202 Accepted - The request has been accepted for processing, but the processing has not been completed. Expect an empty response body.
  • 302 Found - The desired resource is more appropriately found at URL supplied by Location: header.
  • 303 See Other - The response reflecting results of this request is found at URL supplied by Location: header.
  • 304 Not Modified - The resource has not changed with respect to the given If-Modified-Since header in the request.
  • 400 Bad Request - The request is bad, usually due to invalid fields.
  • 401 Unauthorized - Authentication details not accepted.
  • 403 Forbidden - Authentication details accepted, but request not allowed.
  • 404 Not Found - Resource not found.
  • 405 Method Not Allowed - The method specified is not applicable to the resource.
  • 409 Conflict - The request conflicts with the state of the resource.
  • 410 Gone - Usually the status of a successful DELETE request.
  • 415 Unsupported Media Type - Request type not supported - generally only application/x-www-form-urlencoded is accepted.
  • 500 Internal Server Error - Something unexpected went wrong.

Representations

Error Document

Most errors will be indicated by an HTTP Status in the 400s or 500s, and will be accompanied by further details in an XML document like the following:

   <?xml version="1.0" encoding="utf-8" ?>
   <error xmlns="http://addons.mozilla.org/" 
       reason="some_reason_for_error"
       details="further details for error" />

Reason values to expect include:

  • invalid_parameters
  • collection_unknown
  • not_collection_owner
  • unknown_addon_guid
  • addon_already_in_collection
  • addon_not_in_collection
  • {GET,POST,DELETE,PUT}_not_allowed
  • unauthorized
  • not_writable

Service Document

The service document is the main entry point, or "front door" to the API, providing links to other resources exposed by the API and offering an overview of what particular resources are made available to the authenticated user.

   <?xml version="1.0" encoding="utf-8" ?>
   <sharing xmlns="http://addons.mozilla.org/" 
           xml:base="http://addons.mozilla.org/api/1.3/sharing/">
       <email href="email" />
       <collections href="collections">
           <collection 
               href="collections/98404f20-f2e0-11dd-9121-3307c31c9566" 
               name="My Laptop Addons"
               description="Longer description yay"
               creator="lorchard@mozilla.com"
               writable="yes" subscribed="yes" 
               lastmodified="2009-01-04T00:10:00Z">
                   <addons href="collections/98404f20-f2e0-11dd-9121-3307c31c9566/addons/" />
           </collection>
           <collection 
               href="collections/9f534614-f2e5-11dd-a55a-2bd072fc4ff4"
               name="Joe's Blogging Addons"
               description="Longer description yay"
               creator="joe@example.com"
               writable="no" subscribed="yes" 
               lastmodified="2009-01-04T00:10:00Z">
                   <addons href="collections/9f534614-f2e5-11dd-a55a-2bd072fc4ff4/addons/" />
           </collection>
           <collection 
               href="collections/9f534614-f2e5-11dd-a55a-2bd072fc4ff4"
               name="Invisible Addon Collection"
               description="Longer description yay"
               creator="lorchard@mozilla.com"
               writable="yes" subscribed="no" 
               lastmodified="2009-01-04T00:10:00Z">
                   <addons href="collections/9f534614-f2e5-11dd-a55a-2bd072fc4ff4/addons/" />
           </collection>
       </collections>
   </sharing>

Addon Collection

   <?xml version="1.0" encoding="utf-8" ?>
   <collection xmlns="http://addons.mozilla.org/" 
           xml:base="http://addons.mozilla.org/api/1.3/sharing/collections/98404f20-f2e0-11dd-9121-3307c31c9566/">
           href="collections/98404f20-f2e0-11dd-9121-3307c31c9566" 
           name="My Laptop Addons"
           description="Longer description yay"
           writable="yes" subscribed="yes" 
           lastmodified="2009-01-04T00:10:00Z">
       <addons href="addons/">
           <addon href="addons/AE93811A-5C9A-4d34-8462-F7B864FC4696">
               <meta>
                   <added>2009-01-04T00:00:12Z</added>
                   <comments>Here are my nifty comments</comments>
                   <addedby>Les Orchard</addedby>
               </meta>
               <name>StumbleUpon</name>
               <type id="1">Extension</type>
               <guid>{AE93811A-5C9A-4d34-8462-F7B864FC4696}</guid>
               <version>50706</version>
               <status id="4">Public</status>
               <authors>
                   <author>StumbleUpon </author>
               </authors>      
               <summary>
                   StumbleUpon discovers web sites based on your interests, learns
                   what you like and brings you more.
               </summary>
               <description>
                   With StumbleUpon you can also connect with friends and share
                   your discoveries, meet people that have similar interests, and
                   check out what other people are discovering.
               </description>
               <icon>https://addons.mozilla.org/en-US/firefox/images/addon_icon/138/1216845032</icon>
               <thumbnail>https://addons.mozilla.org/en-US/firefox/images/t/23099/1215517056</thumbnail>
               <rating>5</rating>
               <learnmore>https://addons.mozilla.org/addon/138</learnmore>
           </addon>
           <addon>
               <meta>
                   <added>2009-01-02T00:00:12Z</added>
                   <addedby>Nick Nguyen</addedby>
                   <comments>You should really use this.</comments>
               </meta>
               <name>FoxyTunes</name>
               <type id="1">Extension</type>
               <guid>{463F6CA5-EE3C-4be1-B7E6-7FEE11953374}</guid>
               <version>50845</version>
               <status id="4">Public</status>
               <authors>
                   <author>Alex Sirota</author>
                   <author>Yahoo! Inc. </author>
               </authors>      
               <summary>
                   Do you listen to Music while surfing the Web?^M^MFoxyTunes lets
                   you control almost any media player and find lyrics, covers,
                   videos, bios and much more with a click right from your
                   browser.
               </summary>
               <description>
                   Do you listen to Music while surfing the Web?FoxyTunes lets
                   you control almost any media player and find lyrics, covers,
                   videos, bios and much more with a click right from your
                   browser.Supports WinAmp, iTunes, Yahoo Music Engine,
                   Pandora, foobar2000, Windows Media Player, Xbox Media Center,
                   Musicmatch, Quintessential, J. River, jetAudio, XMPlay,
                   MediaMonkey, Media Player Classic, Sonique, wxMusik, Real
                   Player, XMMS, Noatun, Juk, Amarok, Music Player Daemon,
                   Rhythmbox and many other players.Just click on the orange
                   note and select your player.CNET Editor's Rating: 5/5
                   starsPC Magazine: Top 15 Firefox ExtensionsPC World: Top
                   Download Picks 
               </description>
               <icon>https://addons.mozilla.org/en-US/firefox/images/addon_icon/219/1226633195</icon>
               <thumbnail>https://addons.mozilla.org/en-US/firefox/images/t/20256/1209472104</thumbnail>
               <rating>5</rating>
               <learnmore>https://addons.mozilla.org/addon/219</learnmore>
           </addon>
       </addons>
   </collection>

Addon

   <?xml version="1.0" encoding="utf-8" ?>
   <addon xml:base="http://addons.mozilla.org/api/1.3/sharing/collections/98404f20-f2e0-11dd-9121-3307c31c9566/addons/AE93811A-5C9A-4d34-8462-F7B864FC4696">
       <meta>
           <added>2009-01-04T00:00:12Z</added>
           <addedby>Les Orchard</addedby>
           <comments>Here are my nifty comments</comments>
           <collection href=".." />
       </meta>
       <categories>
           <category id="1">Feeds, News & Blogging</category>
           <category id="13">Search Tools</category>
           <category id="22">Bookmarks</category>
           <category id="71">Social & Communication</category>
           <category id="92">Toolbars</category>
       </categories>
       <name>StumbleUpon</name>
       <type id="1">Extension</type>
       <guid>{AE93811A-5C9A-4d34-8462-F7B864FC4696}</guid>
       <version>50706</version>
       <status id="4">Public</status>
       <authors>
           <author>StumbleUpon </author>
       </authors>      
       <summary>
           StumbleUpon discovers web sites based on your interests, learns
           what you like and brings you more.
       </summary>
       <description>
           With StumbleUpon you can also connect with friends and share
           your discoveries, meet people that have similar interests, and
           check out what other people are discovering.
       </description>
       <icon>https://addons.mozilla.org/en-US/firefox/images/addon_icon/138/1216845032</icon>
       <compatible_applications>
           <application>
               <name>Firefox</name>
               <application_id>1</application_id>
               <min_version>1.0</min_version>
               <max_version>3.1a2pre</max_version>
               <appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
           </application>
           <application>
               <name>SeaMonkey</name>
               <application_id>59</application_id>
               <min_version>1.0</min_version>
               <max_version>2.0a1</max_version>
               <appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
           </application>
       </compatible_applications>      
       <all_compatible_os>
           <os>ALL</os>
       </all_compatible_os>
       <eula></eula>
       <thumbnail>https://addons.mozilla.org/en-US/firefox/images/t/23099/1215517056</thumbnail>
       <rating>5</rating>
       <learnmore>https://addons.mozilla.org/addon/138</learnmore>
       <install hash="sha256:2e69bcd3db46521e83eb2d5fdf37724c2af33bb1742f86d0e2cbd938c9bcfae4" 
           os="ALL">https://addons.mozilla.org/downloads/file/34258/stumbleupon-3.26-fx+mz+sm.xpi</install>          
   </addon>

Examples / Walkthrough

This API can be exercised using cURL at a command line.

The service URL used in all these examples is:

   http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/

However, this URL will change depending on the actual AMO instance used.

Using Cookie Auth

You can use session cookie auth with cURL, though it's a little painful. You'll need an extension like Firebug paired with FireCookie to check cookies and headers in your browser.

Once you have those, try logging into an AMO install. You should get a cookie named "AMOv3". Copy the value of that cookie and assign it to a variable in your shell like so:

   $ AUTH_COOKIE=6735160d21d97131f34d86bb1fa5c096

The User-Agent header is another important component, since AMO invalidates session cookies from a user agent that differs from the one used to login. This shouldn't be an issue in extension development, but it can cause destroyed sessions (ie. the user is logged out) when using cURL.

So, check the request header for your User-Agent and assign it to another shell variable:

   $ USER_AGENT="Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.6) Gecko/2009011912 Firefox/3.0.6 FirePHP/0.2.4"

Then, you can make your first request to fetch the service document:

   $ curl -sD - -A "$USER_AGENT" -H "Cookie: AMOv3=${AUTH_COOKIE};" -XGET \
       'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/'

You should see a response like the following:

   HTTP/1.1 200 OK
   Date: Thu, 19 Feb 2009 21:49:07 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
   Cache-Control: public, max-age=3600
   Last-modified: Thu, 19 Feb 2009 21:49:07 GMT
   Expires: Thu, 19 Feb 2009 22:49:07 GMT
   Content-Length: 273
   Content-Type: text/xml
   
   <?xml version="1.0" encoding="utf-8" ?>
   <sharing xmlns="http://addons.mozilla.org/" xml:base="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/">
       <email href="email" />
       <collections href="collections/">
           
       </collections>
   </sharing>

Using HTTP Basic Auth

When trying out the API with cURL, HTTP Basic Auth is a much easier way to go. You can fetch the service document like so:

   $ USER="nobody@mozilla.org"
   $ PASSWD="test"
   $ curl -sD - -u "$USER:$PASSWD" -XGET \
       'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/'

Creating a new collection

To create a new collection, first fetch the service doc:

   $ curl -sD - -u "$USER:$PASSWD" -XGET \
       'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/'
   
   HTTP/1.1 200 OK
   Date: Thu, 19 Feb 2009 21:51:30 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Cache-Control: public, max-age=3600
   Last-modified: Thu, 19 Feb 2009 21:51:31 GMT
   Expires: Thu, 19 Feb 2009 22:51:31 GMT
   Content-Length: 273
   Content-Type: text/xml
   
   <?xml version="1.0" encoding="utf-8" ?>
   <sharing xmlns="http://addons.mozilla.org/" 
           xml:base="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/">
       <email href="email" />
       <collections href="collections/">
           
       </collections>
   </sharing>
   

Note the xml:base attribute on sharing and the href attribute on collections. Use those together to resolve an absolute URL, and that's the collections resource URL:

   http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/

Now, you can POST to that URL to create a new collection, like so:

   $ curl -sD - -u "$USER:$PASSWD" -XPOST \
       -d 'nickname=foobar&name=Foo+Bar&description=collection+of+foobar+addons&listed=1' \
       'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/'
   
   HTTP/1.1 201 Created
   Date: Thu, 19 Feb 2009 22:02:36 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Location: http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/
   Content-Length: 0
   Content-Type: text/html

The creation of the collection was successful. Note the URL in the Location: header. That's the URL to the newly created collection resource.

Try fetching it:

   $ curl -sD - -u "$USER:$PASSWD" -XGET \
       'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109'
   
   HTTP/1.1 200 OK
   Date: Thu, 19 Feb 2009 22:04:19 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Cache-Control: public, max-age=3600
   Last-modified: Thu, 19 Feb 2009 22:04:19 GMT
   Expires: Thu, 19 Feb 2009 23:04:19 GMT
   Content-Length: 396
   Content-Type: text/xml
   
   <?xml version="1.0" encoding="utf-8" ?>
   <collection xmlns="http://addons.mozilla.org/" 
       xml:base="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/"
       name="Foo Bar"
       description="collection of foobar addons"
       creator="Sancus"
       listed="yes" writable="yes" subscribed="no" 
       lastmodified="2009-02-19T19:05:55-05:00">
   
       <addons href="addons/">
           
       </addons>
   
   </collection>
   

Adding an addon to a collection

Notice that the new collection offers an addon element with an href attribute. Once resolved using xml:base, you can POST to this URL to add an addon:

   $ curl -sD - -u "$USER:$PASSWD" -XPOST \
       -d 'guid=farming%40microfarmer.org&comments=I+really+like+this+addon' \
       'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/'
   
   HTTP/1.1 201 Created
   Date: Thu, 19 Feb 2009 22:10:50 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Location: http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org
   Content-Length: 0
   Content-Type: text/html

And you can GET the URL in the Location: header:

   $ curl -sD - -u "$USER:$PASSWD" -XGET \
       'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org'
   
   HTTP/1.1 200 OK
   Date: Thu, 19 Feb 2009 22:12:15 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Cache-Control: public, max-age=3600
   Last-modified: Thu, 19 Feb 2009 22:12:15 GMT
   Expires: Thu, 19 Feb 2009 23:12:15 GMT
   Transfer-Encoding: chunked
   Content-Type: text/xml
       
   <?xml version="1.0" encoding="utf-8" ?>
   <addon xml:base="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org">
       <meta>
           <added>2009-02-19T17:10:50-05:00</added>
           <addedby>Sancus</addedby>
           <comments>I really like this addon</comments>
           <collection href=".." />    
       </meta>
       <categories>
           <category id="12">Organizer</category>
           <category id="13">Web Data</category>
       </categories>
       <name>MicroFarmer</name>
       <type id='1'>Extension</type>
       <guid>farming@microfarmer.org</guid>
       <version>9</version>
   </addon>

A GET request to the collection will show that the addon has been added:

   $ curl -sD - -u "$USER:$PASSWD" -XGET \
       'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/'
   
   HTTP/1.1 200 OK
   Date: Thu, 19 Feb 2009 22:12:15 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Cache-Control: public, max-age=3600
   Last-modified: Thu, 19 Feb 2009 22:12:15 GMT
   Expires: Thu, 19 Feb 2009 23:12:15 GMT
   Transfer-Encoding: chunked
   Content-Type: text/xml
       
   <?xml version="1.0" encoding="utf-8" ?>
   <collection xmlns="http://addons.mozilla.org/" 
       xml:base="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/"
       name="Foo Bar"
       description="collection of foobar addons"
       creator="Sancus"
       listed="yes" writable="yes" subscribed="no" 
       lastmodified="2009-02-19T19:05:55-05:00">
   
       <addons href="addons/">
   
           <addon href="addons/farming%40microfarmer.org">
               <meta>
                   <added>2009-02-19T17:10:50-05:00</added>
                   <addedby>Sancus</addedby>
                   <comments>I really like this addon</comments>
               </meta>
               <categories>
                   <category id="12">Organizer</category>
                   <category id="13">Web Data</category>
               </categories>
               <name>MicroFarmer</name>
               <type id='1'>Extension</type>
               <guid>farming@microfarmer.org</guid>
               <version>9</version>
           </addon>
           
       </addons>
   
   </collection>

Updating an addon in a collection

Later, if you want to make an update to this addon in the collection, you can make a PUT request to the addon URL:

   $ curl -sD - -u "$USER:$PASSWD" -XPUT \
       -d 'comments=This+addon+is+really+swell' \
       'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org'
   
   HTTP/1.1 200 OK
   Date: Fri, 20 Feb 2009 00:10:32 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Cache-Control: public, max-age=3600
   Last-modified: Fri, 20 Feb 2009 00:10:32 GMT
   Expires: Fri, 20 Feb 2009 01:10:32 GMT
   Transfer-Encoding: chunked
   Content-Type: text/xml
       
   <?xml version="1.0" encoding="utf-8" ?>
   <addon xml:base="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org">
       <meta>
           <added>2009-02-19T17:10:50-05:00</added>
           <addedby>Sancus</addedby>
           <comments>This addon is really swell</comments>
           <collection href=".." />    
       </meta>
       <categories>
           <category id="12">Organizer</category>
           <category id="13">Web Data</category>
       </categories>
       <name>MicroFarmer</name>
       <type id='1'>Extension</type>
       <guid>farming@microfarmer.org</guid>
       <version>9</version>
   </addon>

Deleting an addon from a collection

Finally, if you want to remove this addon from the collection, make a DELETE request to the addon URL:

   $ curl -sD - -u "$USER:$PASSWD" -XDELETE \
       'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/129/addons/farming%40microfarmer.org'
   
   HTTP/1.1 410 Gone
   Date: Fri, 20 Feb 2009 00:12:18 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Content-Length: 0
   Content-Type: text/html
   

The addon URL can no longer be found:

   $ curl -sD - -u "$USER:$PASSWD" -XGET \
       'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org'
   
   HTTP/1.1 404 Not Found
   Date: Fri, 20 Feb 2009 00:12:57 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Cache-Control: public, max-age=3600
   Last-modified: Fri, 20 Feb 2009 00:12:58 GMT
   Expires: Fri, 20 Feb 2009 01:12:58 GMT
   Content-Length: 120
   Content-Type: text/xml
   
   <?xml version="1.0" encoding="utf-8" ?>
   <error xmlns="http://addons.mozilla.org/" reason="addon_not_in_collection" />

And, the addon no longer appears in the collection:

   $ curl -sD - -u "$USER:$PASSWD" -XGET \
       'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/'
   
   HTTP/1.1 200 OK
   Date: Fri, 20 Feb 2009 00:13:55 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Cache-Control: public, max-age=3600
   Last-modified: Fri, 20 Feb 2009 00:13:55 GMT
   Expires: Fri, 20 Feb 2009 01:13:55 GMT
   Content-Length: 440
   Content-Type: text/xml
   
   <?xml version="1.0" encoding="utf-8" ?>
   <collection xmlns="http://addons.mozilla.org/" 
       xml:base="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/"
       name="Foo Bar"
       description="collection of foobar addons"
       creator="Sancus"
       listed="yes" writable="yes" subscribed="no" 
       lastmodified="2009-02-19T19:05:55-05:00">
   
       <addons href="addons/">
           
       </addons>
   
   </collection>

Revision Source

<h3><span class="mw-headline">Implementation Notes </span> </h3>
<h4><span class="mw-headline">Use URLs as resource identifiers </span></h4>
<p>This API spec uses the <a class="external text" href="http://www.google.com/search?q=hypermedia+as+the+engine+of+application+state" rel="nofollow" title="http://www.google.com/search?q=hypermedia+as+the+engine+of+application+state">REST pattern of including resource URLs in responses</a>, rather than database IDs or other identifiers. This allows the server to control its own namespace - so please use the URLs found in <code>href</code> attributes to access the API, rather than constructing them on the client side from templates.</p>
<p>The only URL that should be hardcoded (or preferably kept in a user preference) in the client application is the URL to the <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#.2Fapi.2Fsharing.2F" title="">service document</a>. This will not only make it easier to switch between production, staging, and dev instances of the API, it will also make the client resilient to other more granular changes in the server URL space. </p>
<h4><span class="mw-headline"> Use xml:base to resolve relative URLs </span></h4>
<p>The URLs in response data may be supplied as relative paths, or relative with respect an URL indicated by an <a class="external text" href="http://www.w3.org/TR/2001/REC-xmlbase-20010627/#syntax" rel="nofollow" title="http://www.w3.org/TR/2001/REC-xmlbase-20010627/#syntax">xml:base attribute</a>, usually supplied by the root node of the response document.</p>
<h4><span class="mw-headline"> Use conditional GET </span></h4>
<p>For <code>GET</code> requests, be sure to retain the value of the <code>Last-Modified</code> header in responses and include it as <code>If-Modified-Since</code> in requests. This enables <a class="external text" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.3" rel="nofollow" title="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.3">conditional GET</a> and may result in <a href="/en/HTTP/HTTP_response_codes#304" title="https://developer.mozilla.org/en/HTTP/HTTP_response_codes#304"><code>304 Not Modified</code></a> responses that indicate the resource has not changed since the last fetch. This can save in both CPU consumption and bandwidth in preparing and sending the response data.</p><h4><span class="mw-headline">HTTP Method Override Hack </span></h4>
<p>This API uses the HTTP methods GET, POST, PUT, DELETE, and OPTIONS. Some incomplete HTTP clients support only GET and POST methods. So, this API supports the use of POST as a stand-in for any method other than GET, with the actual desired HTTP method supplied via one of the following conventions:</p>
<ul> <li>A URL query parameter named <code>_method</code></li> <li>A POST parameter named <code>_method</code></li> <li>The value of a header named <code>X-HTTP-Method-Override</code></li>
</ul>
<h3><span class="mw-headline">Authentication </span></h3>
<p>All API access requires authentication.</p>
<h4><span class="mw-headline">AMOv3 cookie session ID </span></h4>
<p>If a <code>Cookie:</code> header is sent with the value of an <code>AMOv3</code> login session ID, that value will be validated first in authenticating the user.</p>
<p>Example header, with the <code>AMOv3</code> cookie among other cookies:</p>
<pre>   Cookie: foo=bar; AMOv3=865ikpjmn6bqh897msr3o5hv12; baz=quux
</pre>
<p>The primary use-case for this means of authentication is in a browser extension with access to the user's cookie jar and the ability to extract the same cookie used for website login.</p>
<h4><span class="mw-headline">HTTP basic auth with email/pass </span></h4>
<p>If no <code>AMOv3</code> cookie header is found, or if it is invalid, an attempt to authenticate the user with HTTP basic auth will be made. The username is expected to be an email address registered with AMO and the correct password for that account must be supplied.</p>
<p>An example use case for this authentication method is for simpler testing without the need to perform a website login and get a cookie.</p><h3><span class="mw-headline">Authorization </span></h3>
<p>In general, the client will not be given the URLs of resources to which the authenticated user does not have at least some access (ie. GET-only).</p>
<p>Attempts to manipulate resources to which the authenticated user does not have any permission do to so will receive a response with a <code>403 Forbidden</code> status code.</p>
<p>Attempts to manipulate resources for which the user has <em>some</em> permission will receive responses with a <code>405 Method Not Allowed</code> status code, and the <code>Allow:</code> header will list which methods <em>are</em> allowed.</p><h3><span class="mw-headline">Resources </span></h3>
<p>The following is a catalog of the kinds of resources made available by the API. The URL paths used as headers are conceptual examples, not intended for literal use as templates in the client application.</p>
<p>Also note that not all HTTP methods are avalable for every resource.</p>
<h4><span class="mw-headline">Service Document - /api/sharing/ </span></h4>
<p>This <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#Service_Document" title="">service document</a> is the main entry point URL for the API. Polling it periodically, with proper attention to Last-Modified and If-Modified-Since headers, should offer a relatively efficient way to track collection subscriptions and what subscriptions are writable.</p>
<p>Beyond collections, the <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#Service_Document" title="">service document</a> will supply URLs leading into the rest of the API. (eg. <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#.2Fapi.2Fsharing.2Femail" title="">email sharing</a>)</p>
<p>Concrete examples of this URL might look something like the following:</p>
<pre><a class="external free" href="http://localhost/~lorchard/addons/api.php?action=service_doc" rel="nofollow" title="http://localhost/~lorchard/addons/api.php?action=service_doc"><span class="plain">http://localhost/~lorchard/addons/api.php?action=service_doc</span></a>
<a class="external free" href="http://dev.addons.mozilla.com/en-US/firefox/api/1.3/sharing" rel="nofollow" title="http://dev.addons.mozilla.com/en-US/firefox/api/1.3/sharing"><span class="plain">http://dev.addons.mozilla.com/en-US/firefox/api/1.3/sharing</span></a>
<a class="external free" href="https://preview.addons.mozilla.org/en-US/firefox/api/1.3/sharing" rel="nofollow" title="https://preview.addons.mozilla.org/en-US/firefox/api/1.3/sharing"><span class="plain">https://preview.addons.mozilla.org/en-US/firefox/api/1.3/sharing</span></a>
<a class="external free" href="https://addons.mozilla.org/en-US/firefox/api/1.3/sharing" rel="nofollow" title="https://addons.mozilla.org/en-US/firefox/api/1.3/sharing"><span class="plain">https://addons.mozilla.org/en-US/firefox/api/1.3/sharing</span></a>
</pre>
<h5><span class="mw-headline">GET - Fetch the service document </span></h5>
<ul> <li>Response <ul> <li>Status: <code>200 OK</code></li> <li>Content-Type: <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#Service_Document" title="">#Service Document</a></li> <li>Response body varies according to authenticated user's context</li> </ul> </li>
</ul><h4><span class="mw-headline">Collections List - /api/sharing/collections/ </span></h4>
<p>This resource represents the set of all shared collections. A concrete URL for this resource can be acquired from the <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#Service_Document" title="">#Service Document</a>.</p>
<p>Note that the GET method is not currently implemented, because the service doc and individual collection docs provide the information that would conceivably be made available. Someday, this could be an interface on the public collection directory.</p>
<h5><span class="mw-headline"> POST - Create a new collection </span></h5>
<ul> <li>Request <ul> <li>Content-Type: <code>application/x-www-form-urlencoded</code></li> <li>Parameters: <ul> <li><code>name</code> - human readable name for the collection</li> <li><code>description</code> - human readable longer description for the collection</li> <li><code>nickname</code> - unique nickname for collection usable in URLs</li> <li><code>listed</code> - whether the collection should be listed in the directory (<code>1</code>) or not (<code>0</code>)</li> </ul> </li> </ul> </li>
</ul>
<ul> <li>Response <ul> <li>Status: <code>201 Created</code></li> <li>Content-Type: <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#Addon_Collection" title="">#Addon Collection</a></li> <li>Response body will contain the data for the freshly created collection.</li> <li>Location header points to the URL of new collection.</li> </ul> </li>
</ul>
<p><a id="Collection_-_.2Fapi.2Fsharing.2Fcollections.2F.7Buuid.7D" name="Collection_-_.2Fapi.2Fsharing.2Fcollections.2F.7Buuid.7D"></a></p><a id="Collection_-_.2Fapi.2Fsharing.2Fcollections.2F.7Buuid.7D" name="Collection_-_.2Fapi.2Fsharing.2Fcollections.2F.7Buuid.7D">
<h4><span class="mw-headline">Collection - /api/sharing/collections/{uuid} </span></h4>
</a><p><a id="Collection_-_.2Fapi.2Fsharing.2Fcollections.2F.7Buuid.7D" name="Collection_-_.2Fapi.2Fsharing.2Fcollections.2F.7Buuid.7D">This resource represents a single collection of shared addons. A concrete URL for this kind of resource can be acquired from the </a><a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#Service_Document" title="">#Service Document</a>.</p>
<h5><span class="mw-headline">GET - Fetch contents of a collection </span></h5>
<ul> <li>Response <ul> <li>Status: <code>200 OK</code></li> <li>Content-Type: <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#Addon_Collection" title="">#Addon Collection</a></li> </ul> </li>
</ul>
<h5><span class="mw-headline"> PUT - Update collection details </span></h5>
<p>Note that this update is limited to collection-specific details, and cannot modify any of the other data that makes up an addon document.</p>
<ul> <li>Request <ul> <li>Content-Type: <code>application/x-www-form-urlencoded</code></li> <li>Parameters: <ul> <li><code>name</code> - human readable name for the collection</li> <li><code>description</code> - human readable longer description for the collection</li> <li><code>nickname</code> - unique nickname for collection usable in URLs</li> <li><code>listed</code> - whether the collection should be listed in the directory (<code>1</code>) or not (<code>0</code>)</li> </ul> </li> </ul> </li>
</ul>
<ul> <li>Response (on success) <ul> <li>Status: <code>200 OK</code></li> <li>Content-Type: <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#Addon_Collection" title="">#Addon Collection</a></li> <li>Response content reflects changes to collection</li> </ul> </li>
</ul>
<h5><span class="mw-headline">DELETE - Delete a collection </span></h5>
<ul> <li>Response (on success) <ul> <li>Status: <code>410 Gone</code></li> </ul> </li>
</ul><h4><span class="mw-headline"> List of Addons in a Collection - /api/sharing/collections/{uuid}/addons/ </span></h4>
<p>This resource represents addons in a collection. A concrete URL for this kind of resource can be acquired from the <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#Service_Document" title="">#Service Document</a>.</p>
<p>Note that the GET method is not currently implemented, because the parent collection doc provides the information that would conceivably be made available.</p>
<h5><span class="mw-headline"> POST - Add an addon to a collection </span></h5>
<ul> <li>Request <ul> <li>Content-Type: <code>application/x-www-form-urlencoded</code></li> <li>Parameters: <ul> <li><code>guid</code> - GUID of addon to add to list</li> <li><code>comments</code> - (optional) human readable comments about the addon</li> </ul> </li> </ul> </li>
</ul>
<ul> <li>Response (on success) <ul> <li>Status: <code>201 Created</code></li> <li>Content-Type: <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#Addon" title="">#Addon</a></li> <li>Response body will contain the data for the freshly added addon.</li> <li>Location header points to the URL of the addon resource in the collection.</li> </ul> </li>
</ul>
<ul> <li>Response (if addon already present in collection) <ul> <li>Status: 409 Conflict</li> <li>Content-Type: <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#Error_Document" title="">#Error Document</a></li> </ul> </li>
</ul><h4><span class="mw-headline">Addon in a Collection - /api/sharing/collections/{uuid}/addons/{addon guid} </span></h4>
<p>This resource represents a single addon shared in a collection. A concrete URL for this kind of resource can be acquired from an <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#Addon_Collection" title="">#Addon Collection</a>.</p>
<h5><span class="mw-headline">GET - Fetch details on an addon </span></h5>
<ul> <li>Response (on success) <ul> <li>Status: <code>200 OK</code></li> <li>Content-Type: <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#Addon" title="">#Addon</a></li> </ul> </li>
</ul>
<h5><span class="mw-headline">PUT - Update addon details </span></h5>
<p>Note that this update is limited to collection-specific details, and cannot modify any of the other data that makes up an addon document.</p>
<ul> <li>Request <ul> <li>Content-Type: <code>application/x-www-form-urlencoded</code></li> <li>Parameters: <ul> <li><code>comments</code> - human readable comments about the addon</li> </ul> </li> </ul> </li>
</ul>
<ul> <li>Response (on success) <ul> <li>Status: <code>200 OK</code></li> <li>Content-Type: <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#Addon" title="">#Addon</a></li> <li>Response content reflects changes to addon in collection</li> </ul> </li>
</ul>
<h5><span class="mw-headline">DELETE - Remove an addon from a collection </span></h5>
<ul> <li>Response (on success) <ul> <li>Status: <code>303 See Other</code></li> <li>Content-Type: <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#Addon_Collection" title="">#Addon Collection</a></li> <li>Response body will reflect the change to the collection with addon added or updated.</li> <li>Location header points to the URL of collection, which will reflect the addition or update of the addon.</li> </ul> </li>
</ul><h4><span class="mw-headline"> Email Sharing - /api/sharing/email </span></h4>
<p>This resource offers a general-purpose interface to notification functionality for sharing addons via email messages. A concrete URL for this of resource can be acquired from the <a class=" link-https" href="https://wiki.mozilla.org/User:LesOrchard/BandwagonAPI#Service_Document" title="">#Service Document</a>.</p>
<h5><span class="mw-headline">POST - Request an email sharing notification </span></h5>
<ul> <li>Request <ul> <li>Content-Type: <code>application/x-www-form-urlencoded</code></li> <li>Parameters: <ul> <li><code>to</code> - comma-separated list of email addresses for notification</li> <li><code>guid</code> - GUID of addon to share</li> <li><code>comments</code> - human readable personal comments to be included in notification</li> </ul> </li> </ul> </li>
</ul>
<ul> <li>Response (on success) <ul> <li>Content-Type: empty body</li> <li>Status: <code>202 Accepted</code></li> </ul> </li>
</ul><h3><span class="mw-headline">Status Codes </span></h3>
<p>Based on <a class="external text" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html" rel="nofollow" title="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">HTTP/1.1 Status Code Definitions</a>.</p>
<ul> <li><code>200 OK</code> - Request OK, response body follows.</li> <li><code>201 Created</code> - New resource created, response body follows with new content, watch for <code>Location:</code> header containing new resource URL</li> <li><code>202 Accepted</code> - The request has been accepted for processing, but the processing has not been completed. Expect an empty response body.</li> <li><code>302 Found</code> - The desired resource is more appropriately found at URL supplied by <code>Location:</code> header.</li> <li><code>303 See Other</code> - The response reflecting results of this request is found at URL supplied by <code>Location:</code> header.</li> <li><code>304 Not Modified</code> - The resource has not changed with respect to the given <code>If-Modified-Since</code> header in the request.</li> <li><code>400 Bad Request</code> - The request is bad, usually due to invalid fields.</li> <li><code>401 Unauthorized</code> - Authentication details not accepted.</li> <li><code>403 Forbidden</code> - Authentication details accepted, but request not allowed.</li> <li><code>404 Not Found</code> - Resource not found.</li> <li><code>405 Method Not Allowed</code> - The method specified is not applicable to the resource.</li> <li><code>409 Conflict</code> - The request conflicts with the state of the resource.</li> <li><code>410 Gone</code> - Usually the status of a successful DELETE request.</li> <li><code>415 Unsupported Media Type</code> - Request type not supported - generally only <code>application/x-www-form-urlencoded</code> is accepted.</li> <li><code>500 Internal Server Error</code> - Something unexpected went wrong.</li>
</ul><h3><span class="mw-headline"> Representations </span></h3>
<h4><span class="mw-headline">Error Document </span></h4>
<p>Most errors will be indicated by an HTTP Status in the 400s or 500s, and will be accompanied by further details in an XML document like the following:</p>
<pre>   &lt;?xml version="1.0" encoding="utf-8" ?&gt;
   &lt;error <span class="plain">xmlns="</span><a class="external free" href="http://addons.mozilla.org/" rel="nofollow" title="http://addons.mozilla.org/"><span class="plain">http://addons.mozilla.org/</span></a><span class="plain">"</span> 
       reason="some_reason_for_error"
       details="further details for error" /&gt;
</pre>
<p>Reason values to expect include:</p>
<ul> <li><code>invalid_parameters</code></li> <li><code>collection_unknown</code></li> <li><code>not_collection_owner</code></li> <li><code>unknown_addon_guid</code></li> <li><code>addon_already_in_collection</code></li> <li><code>addon_not_in_collection</code></li> <li><code>{GET,POST,DELETE,PUT}_not_allowed</code></li> <li><code>unauthorized</code></li> <li><code>not_writable</code></li>
</ul><h4><span class="mw-headline">Service Document </span></h4>
<p>The service document is the main entry point, or "front door" to the API, providing links to other resources exposed by the API and offering an overview of what particular resources are made available to the authenticated user.</p>
<pre>   &lt;?xml version="1.0" encoding="utf-8" ?&gt;
   &lt;sharing xmlns="<a class="external free" href="http://addons.mozilla.org/" rel="nofollow" title="http://addons.mozilla.org/">http://addons.mozilla.org/</a>" 
           xml:base="<a class="external free" href="http://addons.mozilla.org/api/1.3/sharing/" rel="nofollow" title="http://addons.mozilla.org/api/1.3/sharing/">http://addons.mozilla.org/api/1.3/sharing/</a>"&gt;
       &lt;email href="email" /&gt;
       &lt;collections href="collections"&gt;
           &lt;collection 
               href="collections/98404f20-f2e0-11dd-9121-3307c31c9566" 
               name="My Laptop Addons"
               description="Longer description yay"
               creator="lorchard@mozilla.com"
               writable="yes" subscribed="yes" 
               lastmodified="2009-01-04T00:10:00Z"&gt;
                   &lt;addons href="collections/98404f20-f2e0-11dd-9121-3307c31c9566/addons/" /&gt;
           &lt;/collection&gt;
           &lt;collection 
               href="collections/9f534614-f2e5-11dd-a55a-2bd072fc4ff4"
               name="Joe's Blogging Addons"
               description="Longer description yay"
               creator="joe@example.com"
               writable="no" subscribed="yes" 
               lastmodified="2009-01-04T00:10:00Z"&gt;
                   &lt;addons href="collections/9f534614-f2e5-11dd-a55a-2bd072fc4ff4/addons/" /&gt;
           &lt;/collection&gt;
           &lt;collection 
               href="collections/9f534614-f2e5-11dd-a55a-2bd072fc4ff4"
               name="Invisible Addon Collection"
               description="Longer description yay"
               creator="lorchard@mozilla.com"
               writable="yes" subscribed="no" 
               lastmodified="2009-01-04T00:10:00Z"&gt;
                   &lt;addons href="collections/9f534614-f2e5-11dd-a55a-2bd072fc4ff4/addons/" /&gt;
           &lt;/collection&gt;
       &lt;/collections&gt;
   &lt;/sharing&gt;
</pre>
<h4><span class="mw-headline"> Addon Collection </span></h4>
<pre>   &lt;?xml version="1.0" encoding="utf-8" ?&gt;
   &lt;collection xmlns="<a class="external free" href="http://addons.mozilla.org/" rel="nofollow" title="http://addons.mozilla.org/">http://addons.mozilla.org/</a>" 
           xml:base="<a class="external free" href="http://addons.mozilla.org/api/1.3/sharing/collections/98404f20-f2e0-11dd-9121-3307c31c9566/" rel="nofollow" title="http://addons.mozilla.org/api/1.3/sharing/collections/98404f20-f2e0-11dd-9121-3307c31c9566/">http://addons.mozilla.org/api/1.3/sharing/collections/98404f20-f2e0-11dd-9121-3307c31c9566/</a>"&gt;
           href="collections/98404f20-f2e0-11dd-9121-3307c31c9566" 
           name="My Laptop Addons"
           description="Longer description yay"
           writable="yes" subscribed="yes" 
           lastmodified="2009-01-04T00:10:00Z"&gt;
       &lt;addons href="addons/"&gt;
           &lt;addon href="addons/AE93811A-5C9A-4d34-8462-F7B864FC4696"&gt;
               &lt;meta&gt;
                   &lt;added&gt;2009-01-04T00:00:12Z&lt;/added&gt;
                   &lt;comments&gt;Here are my nifty comments&lt;/comments&gt;
                   &lt;addedby&gt;Les Orchard&lt;/addedby&gt;
               &lt;/meta&gt;
               &lt;name&gt;StumbleUpon&lt;/name&gt;
               &lt;type id="1"&gt;Extension&lt;/type&gt;
               &lt;guid&gt;{AE93811A-5C9A-4d34-8462-F7B864FC4696}&lt;/guid&gt;
               &lt;version&gt;50706&lt;/version&gt;
               &lt;status id="4"&gt;Public&lt;/status&gt;
               &lt;authors&gt;
                   &lt;author&gt;StumbleUpon &lt;/author&gt;
               &lt;/authors&gt;      
               &lt;summary&gt;
                   StumbleUpon discovers web sites based on your interests, learns
                   what you like and brings you more.
               &lt;/summary&gt;
               &lt;description&gt;
                   With StumbleUpon you can also connect with friends and share
                   your discoveries, meet people that have similar interests, and
                   check out what other people are discovering.
               &lt;/description&gt;
               &lt;icon&gt;<a class="external free" href="https://addons.mozilla.org/en-US/firefox/images/addon_icon/138/1216845032" rel="nofollow" title="https://addons.mozilla.org/en-US/firefox/images/addon_icon/138/1216845032">https://addons.mozilla.org/en-US/firefox/images/addon_icon/138/1216845032</a>&lt;/icon&gt;
               &lt;thumbnail&gt;<a class="external free" href="https://addons.mozilla.org/en-US/firefox/images/t/23099/1215517056" rel="nofollow" title="https://addons.mozilla.org/en-US/firefox/images/t/23099/1215517056">https://addons.mozilla.org/en-US/firefox/images/t/23099/1215517056</a>&lt;/thumbnail&gt;
               &lt;rating&gt;5&lt;/rating&gt;
               &lt;learnmore&gt;<a class="external free" href="https://addons.mozilla.org/addon/138" rel="nofollow" title="https://addons.mozilla.org/addon/138">https://addons.mozilla.org/addon/138</a>&lt;/learnmore&gt;
           &lt;/addon&gt;
           &lt;addon&gt;
               &lt;meta&gt;
                   &lt;added&gt;2009-01-02T00:00:12Z&lt;/added&gt;
                   &lt;addedby&gt;Nick Nguyen&lt;/addedby&gt;
                   &lt;comments&gt;You should really use this.&lt;/comments&gt;
               &lt;/meta&gt;
               &lt;name&gt;FoxyTunes&lt;/name&gt;
               &lt;type id="1"&gt;Extension&lt;/type&gt;
               &lt;guid&gt;{463F6CA5-EE3C-4be1-B7E6-7FEE11953374}&lt;/guid&gt;
               &lt;version&gt;50845&lt;/version&gt;
               &lt;status id="4"&gt;Public&lt;/status&gt;
               &lt;authors&gt;
                   &lt;author&gt;Alex Sirota&lt;/author&gt;
                   &lt;author&gt;Yahoo! Inc. &lt;/author&gt;
               &lt;/authors&gt;      
               &lt;summary&gt;
                   Do you listen to Music while surfing the Web?^M^MFoxyTunes lets
                   you control almost any media player and find lyrics, covers,
                   videos, bios and much more with a click right from your
                   browser.
               &lt;/summary&gt;
               &lt;description&gt;
                   Do you listen to Music while surfing the Web?FoxyTunes lets
                   you control almost any media player and find lyrics, covers,
                   videos, bios and much more with a click right from your
                   browser.Supports WinAmp, iTunes, Yahoo Music Engine,
                   Pandora, foobar2000, Windows Media Player, Xbox Media Center,
                   Musicmatch, Quintessential, J. River, jetAudio, XMPlay,
                   MediaMonkey, Media Player Classic, Sonique, wxMusik, Real
                   Player, XMMS, Noatun, Juk, Amarok, Music Player Daemon,
                   Rhythmbox and many other players.Just click on the orange
                   note and select your player.CNET Editor's Rating: 5/5
                   starsPC Magazine: Top 15 Firefox ExtensionsPC World: Top
                   Download Picks 
               &lt;/description&gt;
               &lt;icon&gt;<a class="external free" href="https://addons.mozilla.org/en-US/firefox/images/addon_icon/219/1226633195" rel="nofollow" title="https://addons.mozilla.org/en-US/firefox/images/addon_icon/219/1226633195">https://addons.mozilla.org/en-US/firefox/images/addon_icon/219/1226633195</a>&lt;/icon&gt;
               &lt;thumbnail&gt;<a class="external free" href="https://addons.mozilla.org/en-US/firefox/images/t/20256/1209472104" rel="nofollow" title="https://addons.mozilla.org/en-US/firefox/images/t/20256/1209472104">https://addons.mozilla.org/en-US/firefox/images/t/20256/1209472104</a>&lt;/thumbnail&gt;
               &lt;rating&gt;5&lt;/rating&gt;
               &lt;learnmore&gt;<a class="external free" href="https://addons.mozilla.org/addon/219" rel="nofollow" title="https://addons.mozilla.org/addon/219">https://addons.mozilla.org/addon/219</a>&lt;/learnmore&gt;
           &lt;/addon&gt;
       &lt;/addons&gt;
   &lt;/collection&gt;
</pre>
<h4><span class="mw-headline">Addon </span></h4>
<pre>   &lt;?xml version="1.0" encoding="utf-8" ?&gt;
   &lt;addon xml:base="<a class="external free" href="http://addons.mozilla.org/api/1.3/sharing/collections/98404f20-f2e0-11dd-9121-3307c31c9566/addons/AE93811A-5C9A-4d34-8462-F7B864FC4696" rel="nofollow" title="http://addons.mozilla.org/api/1.3/sharing/collections/98404f20-f2e0-11dd-9121-3307c31c9566/addons/AE93811A-5C9A-4d34-8462-F7B864FC4696">http://addons.mozilla.org/api/1.3/sharing/collections/98404f20-f2e0-11dd-9121-3307c31c9566/addons/AE93811A-5C9A-4d34-8462-F7B864FC4696</a>"&gt;
       &lt;meta&gt;
           &lt;added&gt;2009-01-04T00:00:12Z&lt;/added&gt;
           &lt;addedby&gt;Les Orchard&lt;/addedby&gt;
           &lt;comments&gt;Here are my nifty comments&lt;/comments&gt;
           &lt;collection href=".." /&gt;
       &lt;/meta&gt;
       &lt;categories&gt;
           &lt;category id="1"&gt;Feeds, News &amp; Blogging&lt;/category&gt;
           &lt;category id="13"&gt;Search Tools&lt;/category&gt;
           &lt;category id="22"&gt;Bookmarks&lt;/category&gt;
           &lt;category id="71"&gt;Social &amp; Communication&lt;/category&gt;
           &lt;category id="92"&gt;Toolbars&lt;/category&gt;
       &lt;/categories&gt;
       &lt;name&gt;StumbleUpon&lt;/name&gt;
       &lt;type id="1"&gt;Extension&lt;/type&gt;
       &lt;guid&gt;{AE93811A-5C9A-4d34-8462-F7B864FC4696}&lt;/guid&gt;
       &lt;version&gt;50706&lt;/version&gt;
       &lt;status id="4"&gt;Public&lt;/status&gt;
       &lt;authors&gt;
           &lt;author&gt;StumbleUpon &lt;/author&gt;
       &lt;/authors&gt;      
       &lt;summary&gt;
           StumbleUpon discovers web sites based on your interests, learns
           what you like and brings you more.
       &lt;/summary&gt;
       &lt;description&gt;
           With StumbleUpon you can also connect with friends and share
           your discoveries, meet people that have similar interests, and
           check out what other people are discovering.
       &lt;/description&gt;
       &lt;icon&gt;<a class="external free" href="https://addons.mozilla.org/en-US/firefox/images/addon_icon/138/1216845032" rel="nofollow" title="https://addons.mozilla.org/en-US/firefox/images/addon_icon/138/1216845032">https://addons.mozilla.org/en-US/firefox/images/addon_icon/138/1216845032</a>&lt;/icon&gt;
       &lt;compatible_applications&gt;
           &lt;application&gt;
               &lt;name&gt;Firefox&lt;/name&gt;
               &lt;application_id&gt;1&lt;/application_id&gt;
               &lt;min_version&gt;1.0&lt;/min_version&gt;
               &lt;max_version&gt;3.1a2pre&lt;/max_version&gt;
               &lt;appID&gt;{ec8030f7-c20a-464f-9b0e-13a3a9e97384}&lt;/appID&gt;
           &lt;/application&gt;
           &lt;application&gt;
               &lt;name&gt;SeaMonkey&lt;/name&gt;
               &lt;application_id&gt;59&lt;/application_id&gt;
               &lt;min_version&gt;1.0&lt;/min_version&gt;
               &lt;max_version&gt;2.0a1&lt;/max_version&gt;
               &lt;appID&gt;{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}&lt;/appID&gt;
           &lt;/application&gt;
       &lt;/compatible_applications&gt;      
       &lt;all_compatible_os&gt;
           &lt;os&gt;ALL&lt;/os&gt;
       &lt;/all_compatible_os&gt;
       &lt;eula&gt;&lt;/eula&gt;
       &lt;thumbnail&gt;<a class="external free" href="https://addons.mozilla.org/en-US/firefox/images/t/23099/1215517056" rel="nofollow" title="https://addons.mozilla.org/en-US/firefox/images/t/23099/1215517056">https://addons.mozilla.org/en-US/firefox/images/t/23099/1215517056</a>&lt;/thumbnail&gt;
       &lt;rating&gt;5&lt;/rating&gt;
       &lt;learnmore&gt;<a class="external free" href="https://addons.mozilla.org/addon/138" rel="nofollow" title="https://addons.mozilla.org/addon/138">https://addons.mozilla.org/addon/138</a>&lt;/learnmore&gt;
       &lt;install hash="sha256:2e69bcd3db46521e83eb2d5fdf37724c2af33bb1742f86d0e2cbd938c9bcfae4" 
           os="ALL"&gt;<a class="external free" href="https://addons.mozilla.org/downloads/file/34258/stumbleupon-3.26-fx+mz+sm.xpi" rel="nofollow" title="https://addons.mozilla.org/downloads/file/34258/stumbleupon-3.26-fx+mz+sm.xpi">https://addons.mozilla.org/downloads/file/34258/stumbleupon-3.26-fx+mz+sm.xpi</a>&lt;/install&gt;          
   &lt;/addon&gt;
</pre>
<h3><span class="mw-headline"> Examples / Walkthrough </span></h3>
<p>This API can be exercised using <a class="external text" href="http://curl.haxx.se/" rel="nofollow" title="http://curl.haxx.se/">cURL</a> at a command line.</p>
<p>The service URL used in all these examples is:</p>
<pre>   <a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/</a>
</pre>
<p>However, this URL will change depending on the actual AMO instance used.</p>
<h4><span class="mw-headline">Using Cookie Auth </span></h4>
<p>You can use session cookie auth with cURL, though it's a little painful. You'll need an extension like Firebug paired with FireCookie to check cookies and headers in your browser.</p>
<p>Once you have those, try logging into an AMO install. You should get a cookie named "AMOv3". Copy the value of that cookie and assign it to a variable in your shell like so:</p>
<pre>   $ AUTH_COOKIE=6735160d21d97131f34d86bb1fa5c096
</pre>
<p>The User-Agent header is another important component, since AMO invalidates session cookies from a user agent that differs from the one used to login. This shouldn't be an issue in extension development, but it can cause destroyed sessions (ie. the user is logged out) when using cURL.</p>
<p>So, check the request header for your User-Agent and assign it to another shell variable:</p>
<pre>   $ USER_AGENT="Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.6) Gecko/2009011912 Firefox/3.0.6 FirePHP/0.2.4"
</pre>
<p>Then, you can make your first request to fetch the service document:</p>
<pre>   $ curl -sD - -A "$USER_AGENT" -H "Cookie: AMOv3=${AUTH_COOKIE};" -XGET \
       '<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/'" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/'">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/'</a>
</pre>
<p>You should see a response like the following:</p>
<pre>   HTTP/1.1 200 OK
   Date: Thu, 19 Feb 2009 21:49:07 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
   Cache-Control: public, max-age=3600
   Last-modified: Thu, 19 Feb 2009 21:49:07 GMT
   Expires: Thu, 19 Feb 2009 22:49:07 GMT
   Content-Length: 273
   Content-Type: text/xml
   
   &lt;?xml version="1.0" encoding="utf-8" ?&gt;
   &lt;sharing xmlns="<a class="external free" href="http://addons.mozilla.org/" rel="nofollow" title="http://addons.mozilla.org/">http://addons.mozilla.org/</a>" xml:base="<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/</a>"&gt;
       &lt;email href="email" /&gt;
       &lt;collections href="collections/"&gt;
           
       &lt;/collections&gt;
   &lt;/sharing&gt;
</pre>
<h4><span class="mw-headline">Using HTTP Basic Auth </span></h4>
<p>When trying out the API with cURL, HTTP Basic Auth is a much easier way to go. You can fetch the service document like so:</p>
<pre>   $ USER="nobody@mozilla.org"
   $ PASSWD="test"
   $ curl -sD - -u "$USER:$PASSWD" -XGET \
       '<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/'" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/'">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/'</a>
</pre>
<h4><span class="mw-headline">Creating a new collection </span></h4>
<p>To create a new collection, first fetch the service doc:</p>
<pre>   $ curl -sD - -u "$USER:$PASSWD" -XGET \
       '<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/'" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/'">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/'</a>
   
   HTTP/1.1 200 OK
   Date: Thu, 19 Feb 2009 21:51:30 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Cache-Control: public, max-age=3600
   Last-modified: Thu, 19 Feb 2009 21:51:31 GMT
   Expires: Thu, 19 Feb 2009 22:51:31 GMT
   Content-Length: 273
   Content-Type: text/xml
   
   &lt;?xml version="1.0" encoding="utf-8" ?&gt;
   &lt;sharing xmlns="<a class="external free" href="http://addons.mozilla.org/" rel="nofollow" title="http://addons.mozilla.org/">http://addons.mozilla.org/</a>" 
           xml:base="<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/</a>"&gt;
       &lt;email href="email" /&gt;
       &lt;collections href="collections/"&gt;
           
       &lt;/collections&gt;
   &lt;/sharing&gt;
   
</pre>
<p>Note the <code>xml:base</code> attribute on <code>sharing</code> and the <code>href</code> attribute on <code>collections</code>. Use those together to resolve an absolute URL, and that's the collections resource URL:</p>
<pre>   <a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/</a>
</pre>
<p>Now, you can POST to that URL to create a new collection, like so:</p>
<pre>   $ curl -sD - -u "$USER:$PASSWD" -XPOST \
       -d 'nickname=foobar&amp;name=Foo+Bar&amp;description=collection+of+foobar+addons&amp;listed=1' \
       '<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/'" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/'">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/'</a>
   
   HTTP/1.1 201 Created
   Date: Thu, 19 Feb 2009 22:02:36 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Location: <a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/</a>
   Content-Length: 0
   Content-Type: text/html
</pre>
<p>The creation of the collection was successful. Note the URL in the <code>Location:</code> header. That's the URL to the newly created collection resource.</p>
<p>Try fetching it:</p>
<pre>   $ curl -sD - -u "$USER:$PASSWD" -XGET \
       '<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109'" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109'">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109'</a>
   
   HTTP/1.1 200 OK
   Date: Thu, 19 Feb 2009 22:04:19 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Cache-Control: public, max-age=3600
   Last-modified: Thu, 19 Feb 2009 22:04:19 GMT
   Expires: Thu, 19 Feb 2009 23:04:19 GMT
   Content-Length: 396
   Content-Type: text/xml
   
   &lt;?xml version="1.0" encoding="utf-8" ?&gt;
   &lt;collection xmlns="<a class="external free" href="http://addons.mozilla.org/" rel="nofollow" title="http://addons.mozilla.org/">http://addons.mozilla.org/</a>" 
       xml:base="<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/</a>"
       name="Foo Bar"
       description="collection of foobar addons"
       creator="Sancus"
       listed="yes" writable="yes" subscribed="no" 
       lastmodified="2009-02-19T19:05:55-05:00"&gt;
   
       &lt;addons href="addons/"&gt;
           
       &lt;/addons&gt;
   
   &lt;/collection&gt;
   
</pre>
<h4><span class="mw-headline">Adding an addon to a collection </span></h4>
<p>Notice that the new collection offers an <code>addon</code> element with an <code>href</code> attribute. Once resolved using <code>xml:base</code>, you can POST to this URL to add an addon:</p>
<pre>   $ curl -sD - -u "$USER:$PASSWD" -XPOST \
       -d 'guid=farming%40microfarmer.org&amp;comments=I+really+like+this+addon' \
       '<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/'" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/'">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/'</a>
   
   HTTP/1.1 201 Created
   Date: Thu, 19 Feb 2009 22:10:50 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Location: <a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming@microfarmer.org" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org</a>
   Content-Length: 0
   Content-Type: text/html
</pre>
<p>And you can GET the URL in the <code>Location:</code> header:</p>
<pre>   $ curl -sD - -u "$USER:$PASSWD" -XGET \
       '<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming@microfarmer.org'" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org'">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org'</a>
   
   HTTP/1.1 200 OK
   Date: Thu, 19 Feb 2009 22:12:15 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Cache-Control: public, max-age=3600
   Last-modified: Thu, 19 Feb 2009 22:12:15 GMT
   Expires: Thu, 19 Feb 2009 23:12:15 GMT
   Transfer-Encoding: chunked
   Content-Type: text/xml
       
   &lt;?xml version="1.0" encoding="utf-8" ?&gt;
   &lt;addon xml:base="<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming@microfarmer.org" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org</a>"&gt;
       &lt;meta&gt;
           &lt;added&gt;2009-02-19T17:10:50-05:00&lt;/added&gt;
           &lt;addedby&gt;Sancus&lt;/addedby&gt;
           &lt;comments&gt;I really like this addon&lt;/comments&gt;
           &lt;collection href=".." /&gt;    
       &lt;/meta&gt;
       &lt;categories&gt;
           &lt;category id="12"&gt;Organizer&lt;/category&gt;
           &lt;category id="13"&gt;Web Data&lt;/category&gt;
       &lt;/categories&gt;
       &lt;name&gt;MicroFarmer&lt;/name&gt;
       &lt;type id='1'&gt;Extension&lt;/type&gt;
       &lt;guid&gt;farming@microfarmer.org&lt;/guid&gt;
       &lt;version&gt;9&lt;/version&gt;
   &lt;/addon&gt;
</pre>
<p>A GET request to the collection will show that the addon has been added:</p>
<pre>   $ curl -sD - -u "$USER:$PASSWD" -XGET \
       '<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/'" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/'">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/'</a>
   
   HTTP/1.1 200 OK
   Date: Thu, 19 Feb 2009 22:12:15 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Cache-Control: public, max-age=3600
   Last-modified: Thu, 19 Feb 2009 22:12:15 GMT
   Expires: Thu, 19 Feb 2009 23:12:15 GMT
   Transfer-Encoding: chunked
   Content-Type: text/xml
       
   &lt;?xml version="1.0" encoding="utf-8" ?&gt;
   &lt;collection xmlns="<a class="external free" href="http://addons.mozilla.org/" rel="nofollow" title="http://addons.mozilla.org/">http://addons.mozilla.org/</a>" 
       xml:base="<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/</a>"
       name="Foo Bar"
       description="collection of foobar addons"
       creator="Sancus"
       listed="yes" writable="yes" subscribed="no" 
       lastmodified="2009-02-19T19:05:55-05:00"&gt;
   
       &lt;addons href="addons/"&gt;
   
           &lt;addon href="addons/farming%40microfarmer.org"&gt;
               &lt;meta&gt;
                   &lt;added&gt;2009-02-19T17:10:50-05:00&lt;/added&gt;
                   &lt;addedby&gt;Sancus&lt;/addedby&gt;
                   &lt;comments&gt;I really like this addon&lt;/comments&gt;
               &lt;/meta&gt;
               &lt;categories&gt;
                   &lt;category id="12"&gt;Organizer&lt;/category&gt;
                   &lt;category id="13"&gt;Web Data&lt;/category&gt;
               &lt;/categories&gt;
               &lt;name&gt;MicroFarmer&lt;/name&gt;
               &lt;type id='1'&gt;Extension&lt;/type&gt;
               &lt;guid&gt;farming@microfarmer.org&lt;/guid&gt;
               &lt;version&gt;9&lt;/version&gt;
           &lt;/addon&gt;
           
       &lt;/addons&gt;
   
   &lt;/collection&gt;
</pre>
<h4><span class="mw-headline"> Updating an addon in a collection </span></h4>
<p>Later, if you want to make an update to this addon in the collection, you can make a PUT request to the addon URL:</p>
<pre>   $ curl -sD - -u "$USER:$PASSWD" -XPUT \
       -d 'comments=This+addon+is+really+swell' \
       '<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming@microfarmer.org'" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org'">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org'</a>
   
   HTTP/1.1 200 OK
   Date: Fri, 20 Feb 2009 00:10:32 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Cache-Control: public, max-age=3600
   Last-modified: Fri, 20 Feb 2009 00:10:32 GMT
   Expires: Fri, 20 Feb 2009 01:10:32 GMT
   Transfer-Encoding: chunked
   Content-Type: text/xml
       
   &lt;?xml version="1.0" encoding="utf-8" ?&gt;
   &lt;addon xml:base="<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming@microfarmer.org" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org</a>"&gt;
       &lt;meta&gt;
           &lt;added&gt;2009-02-19T17:10:50-05:00&lt;/added&gt;
           &lt;addedby&gt;Sancus&lt;/addedby&gt;
           &lt;comments&gt;This addon is really swell&lt;/comments&gt;
           &lt;collection href=".." /&gt;    
       &lt;/meta&gt;
       &lt;categories&gt;
           &lt;category id="12"&gt;Organizer&lt;/category&gt;
           &lt;category id="13"&gt;Web Data&lt;/category&gt;
       &lt;/categories&gt;
       &lt;name&gt;MicroFarmer&lt;/name&gt;
       &lt;type id='1'&gt;Extension&lt;/type&gt;
       &lt;guid&gt;farming@microfarmer.org&lt;/guid&gt;
       &lt;version&gt;9&lt;/version&gt;
   &lt;/addon&gt;
</pre>
<h4><span class="mw-headline">Deleting an addon from a collection </span></h4>
<p>Finally, if you want to remove this addon from the collection, make a DELETE request to the addon URL:</p>
<pre>   $ curl -sD - -u "$USER:$PASSWD" -XDELETE \
       '<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/129/addons/farming@microfarmer.org'" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/129/addons/farming%40microfarmer.org'">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/129/addons/farming%40microfarmer.org'</a>
   
   HTTP/1.1 410 Gone
   Date: Fri, 20 Feb 2009 00:12:18 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Content-Length: 0
   Content-Type: text/html
   
</pre>
<p>The addon URL can no longer be found:</p>
<pre>   $ curl -sD - -u "$USER:$PASSWD" -XGET \
       '<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming@microfarmer.org'" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org'">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org'</a>
   
   HTTP/1.1 404 Not Found
   Date: Fri, 20 Feb 2009 00:12:57 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Cache-Control: public, max-age=3600
   Last-modified: Fri, 20 Feb 2009 00:12:58 GMT
   Expires: Fri, 20 Feb 2009 01:12:58 GMT
   Content-Length: 120
   Content-Type: text/xml
   
   &lt;?xml version="1.0" encoding="utf-8" ?&gt;
   &lt;error xmlns="<a class="external free" href="http://addons.mozilla.org/" rel="nofollow" title="http://addons.mozilla.org/">http://addons.mozilla.org/</a>" reason="addon_not_in_collection" /&gt;
</pre>
<p>And, the addon no longer appears in the collection:</p>
<pre>   $ curl -sD - -u "$USER:$PASSWD" -XGET \
       '<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/'" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/'">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/'</a>
   
   HTTP/1.1 200 OK
   Date: Fri, 20 Feb 2009 00:13:55 GMT
   Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
   X-Powered-By: PHP/5.2.6
   X-AMO-ServedBy: quadshot-2.local
   Cache-Control: public, max-age=3600
   Last-modified: Fri, 20 Feb 2009 00:13:55 GMT
   Expires: Fri, 20 Feb 2009 01:13:55 GMT
   Content-Length: 440
   Content-Type: text/xml
   
   &lt;?xml version="1.0" encoding="utf-8" ?&gt;
   &lt;collection xmlns="<a class="external free" href="http://addons.mozilla.org/" rel="nofollow" title="http://addons.mozilla.org/">http://addons.mozilla.org/</a>" 
       xml:base="<a class="external free" href="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/" rel="nofollow" title="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/">http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/</a>"
       name="Foo Bar"
       description="collection of foobar addons"
       creator="Sancus"
       listed="yes" writable="yes" subscribed="no" 
       lastmodified="2009-02-19T19:05:55-05:00"&gt;
   
       &lt;addons href="addons/"&gt;
           
       &lt;/addons&gt;
   
   &lt;/collection&gt;
</pre>
<!--
NewPP limit report
Preprocessor node count: 41/1000000
Post-expand include size: 0/2097152 bytes
Template argument size: 0/2097152 bytes
Expensive parser function count: 0/100
--> <!-- Saved in parser cache with key wiki_mozorg10:pcache:idhash:26819-0!1!0!!en!2 and timestamp 20090823164023 --> <!-- end content --> <!-- end of MAINCONTENT div --> <!-- end of MBODY div -->
Revert to this revision