Overview¶
Note
These v4 APIs are now frozen. See the API versions available for details of the different API versions available.
This describes the details of the requests and responses you can expect from the addons.mozilla.org API.
Requests¶
All requests should be made with the header:
Content-type: application/json
Responses¶
Status Codes¶
There are some common API responses that you can expect to receive at times.
- GET /api/v4/...¶
- Status Codes:
200 OK – Success.
201 Created – Creation successful.
202 Accepted – The request has been accepted for processing. This usually means one or more asyncronous tasks is being executed in the background so results aren’t immediately visible.
204 No Content – Success (no content is returned).
400 Bad Request – There was a problem with the parameters sent with this request.
401 Unauthorized – Authentication is required or failed.
403 Forbidden – You are not permitted to perform this action.
404 Not Found – The requested resource could not be found.
451 Unavailable For Legal Reasons – The requested resource is not available for legal reasons.
500 Internal Server Error – An unknown error occurred.
503 Service Unavailable – The site is in maintenance mode at this current time and the operation can not be performed.
Bad Requests¶
When returning a HTTP 400 Bad Request response, the API will try to return
some information about the error(s) in the body of the response, as a JSON
object. The keys of that object indicate the field(s) that caused an error, and
for each, a list of messages will be provided (often only one message will be
present, but sometimes more). If the error is not attached to a specific field
the key non_field_errors will be used instead.
Example:
{ "username": ["This field is required."], "non_field_errors": ["Error not linked to a specific field."] }
Maintainance Mode¶
When returning HTTP 503 Service Unavailable responses the API may be in
read-only mode. This means that for a short period of time we do not allow any
write requests, this includes POST, PATCH, PUT and DELETE requests.
In case we are in read-only mode, the following behavior can be observed:
GETrequests behave normally
POST,PUT,PATCH, andDELETErequests return 503 with a json response that contains a localized error message
The response when returning HTTP 503 Service Unavailable in case of read-only mode looks like this:
{
"error": "Some features are temporarily disabled while we perform websi…"
}
In case we are not in read-only mode everything should be back working as normal. To check if the site is in read-only mode before submitting a response, the site status api can be called.
Pagination¶
By default, all endpoints returning a list of results are paginated. The default number of items per page is 25 and clients can use the page_size query parameter to change it to any value between 1 and 50. Exceptions to those rules are possible but will be noted in the corresponding documentation for affected endpoints.
The following properties will be available in paginated responses:
next: the URL for the next page in the pagination.
previous: the URL for the previous page in the pagination.
page_size: The number of items per page in the pagination.
page_count: The number of pages available in the pagination. It may be lower than count / page_size for elasticsearch based paginations that go beyond our max_result_window configuration.
count: the total number of records.
results: the array containing the results for this page.
Translated Fields¶
Fields that can be translated by users (typically name, description) have a special behaviour. They are returned as an object, by default, with languages as keys and translations as values, and by default all languages are returned:
{
"name": {
"en-US": "Games",
"fr": "Jeux",
"kn": "ಆಟಗಳು"
}
}
However, for performance, if you pass the lang parameter to a GET
request, then only the most relevant translation (the specified language or the
fallback, depending on whether a translation is available in the requested
language) will be returned.
Default API behavior¶
In API version 3 or 4 the response, if the lang parameter is passed, is a single string.
{
"name": "Games"
}
This behaviour also applies to POST, PATCH and PUT requests: you
can either submit an object containing several translations, or just a string.
If only a string is supplied, it will only be used to translate the field in
the current language.
Outgoing Links¶
How outgoing links are treated has changed in v5 API.
Default v3/v4 API behavior¶
If the wrap_outgoing_links query parameter is present, any external links
returned for properties such as support_url or homepage will be wrapped
through outgoing.prod.mozaws.net. Fields supporting some HTML, such as
add-on description or summary, always do this regardless of whether or
not the query parameter is present.
v5 API behavior¶
All fields that can have external links that would be presented to the user,
such as support_url or homepage, are returned as a object both containing the
original url (url), and wrapped through outgoing.prod.mozaws.net (outgoing).
{
"contributions": {
"url": "https://paypal.me/xxx",
"outgoing": "https://outgoing.prod.mozaws.net/123456"
}
}
Note, if the field is also a translated field then the url and outgoing
values could be an object rather than a string
(See translated fields <v4-api-overview-translations> for translated field represenations).
Fields supporting some HTML, such as add-on description or summary,
always wrap any links directly inside the content (the original url is not available).
Cross Origin¶
All APIs are available with Cross-Origin Resource Sharing unless otherwise specified.
Site Status¶
This special endpoint returns if the site is in read only mode, and if there is a site notice currently in effect. See maintainance mode for more details of when the site is read only and how requests are affected.
- GET /api/v4/site/¶
- Response JSON Object:
read_only (boolean) – Whether the site in read-only mode.
notice (string|null) – A site-wide notice about any current known difficulties or restrictions. If this API is being consumed by a tool/frontend it should be displayed to the user.
v4 API changelog¶
2018-05-18: renamed /reviews/ endpoint to /ratings/ https://github.com/mozilla/addons-server/issues/6849
2018-05-25: renamed
rating.ratingproperty torating.scorehttps://github.com/mozilla/addons-server/pull/83322018-06-05: dropped
rating.titleproperty https://github.com/mozilla/addons-server/issues/81442018-07-12: added
typeproperty to autocomplete API. This change was also backported to the v3 API. https://github.com/mozilla/addons-server/issues/88032018-07-19: localised field values are always returned as objects, even if only a single language is requested. Setting a localised value with a string is removed too - it must always be an object of one or more translations. https://github.com/mozilla/addons-server/issues/8794
2018-07-18: added
previewsproperty to discovery APIaddonsobject. This change was also backported to the v3 API. https://github.com/mozilla/addons-server/issues/88632018-07-20: dropped
downloadsproperty from the collection add-ons results. https://github.com/mozilla/addons-server/issues/89442018-08-16: added
is_developer_replyproperty to ratings. This changed was also backported to the v3 API. https://github.com/mozilla/addons-server/issues/89932018-09-13: added
nameandicon_urlproperties to theaddonobject in ratings. This changed was also backported to the v3 API. https://github.com/mozilla/addons-server/issues/93572018-09-27: backed out “localised field values are always returned as objects” change from 2018-07-19 from v4 API. This is intended to be temporary change while addons-frontend upgrades. On addons-dev and addons stage enviroments the previous behavior is available as api/v4dev. The v4dev api is not available on AMO production server. https://github.com/mozilla/addons-server/issues/9467
2018-10-04: added
is_strict_compatibility_enabledto discovery APIaddons.current_versionobject. This change was also backported to the v3 API. https://github.com/mozilla/addons-server/issues/95202018-10-04: added
is_deletedto the ratings API. This change was also backported to the v3 API. https://github.com/mozilla/addons-server/issues/93712018-10-04: added
exclude_ratingsparameter to ratings API. This change was also backported to the v3 API. https://github.com/mozilla/addons-server/issues/94242018-10-11: removed
locale_disambiguationfrom the Language Tools API.2018-10-11: added
createdto the addons API.2018-10-18: added
_scoreto the addons search API.2018-10-25: changed
authorparameter on addons search API to accept user ids as well as usernames. This change was also backported to the v3 API. https://github.com/mozilla/addons-server/issues/89012018-10-25: added
fxa_edit_email_urlparameter on accounts API to return the full URL for editing the user’s email on FxA. https://github.com/mozilla/addons-server/issues/86742018-10-31: added
idto discovery APIaddons.current_versionobject. This change was also backported to the v3 API. https://github.com/mozilla/addons-server/issues/98552018-11-15: added
is_customto the license object in version detail output in the addons API.2018-11-22: added
flagsto the rating object in the ratings API whenshow_flags_forparameter supplied.2018-11-22: added
scoreparameter to the ratings API list endpoint.2019-01-10: added
release_notesandlicense(exceptlicense.text) to search API resultscurrent_versionobjects.2019-01-11: added new /reviewers/browse/ endpoint. https://github.com/mozilla/addons-server/issues/10322
2019-01-16: removed /api/{v3,v4,v5}/github api entirely. They have been marked as experimental. https://github.com/mozilla/addons-server/issues/10411
2019-02-21: added new /api/v4/reviewers/addon/(addon_id)/versions/ endpoint. https://github.com/mozilla/addons-server/issues/10432
2019-03-14: added new /reviewers/compare/ endpoint. https://github.com/mozilla/addons-server/issues/10323
2019-04-11: removed
id,usernameandurlfrom theuserobject in the activity review notes APIs. https://github.com/mozilla/addons-server/issues/110022019-04-18: added new optional parameters to abuse report endpoint
2019-05-09: added
is_recommendedto addons API. https://github.com/mozilla/addons-server/issues/112782019-05-16: added /reviewers/canned-responses/ endpoint. https://github.com/mozilla/addons-server/issues/11276
2019-05-23: added
is_recommendedto addons autocomplete API also. https://github.com/mozilla/addons-server/issues/114392019-05-23: changed the addons search API default sort when no query string is passed - now
sort=recommended,downloads. Also maderecommendedsort available generally to the addons search API. https://github.com/mozilla/addons-server/issues/114322019-06-27: removed
sortparameter from addon autocomplete API. https://github.com/mozilla/addons-server/issues/116642019-07-18: completely changed the 2019-05-16 added draft-comment related APIs. See #11380, #11379, #11378 and #11374
2019-07-25: added /hero/ endpoint to expose recommended addons and other content to frontend to allow customizable promos https://github.com/mozilla/addons-server/issues/11842.
2019-08-01: added alias
edition=MozillaOnlineforedition=chinain /discovery/ endpoint.2019-08-08: add support for externally hosted addons to /hero/ endpoints. https://github.com/mozilla/addons-server/issues/11882
2019-08-08: removed
heading_textproperty from discovery api. https://github.com/mozilla/addons-server/issues/118172019-08-08: add secondary shelf to /hero/ endpoint. https://github.com/mozilla/addons-server/issues/11779
2019-08-15: dropped support for LWT specific statuses.
2019-08-15: added promo modules to secondary hero shelves. https://github.com/mozilla/addons-server/issues/11780
2019-08-15: removed /addons/compat-override/ from v4 and above. Still exists in /v3/ but will always return an empty response. https://github.com/mozilla/addons-server/issues/12063
2019-08-22: added
canned_responseproperty to draft comment api. https://github.com/mozilla/addons-server/issues/118072019-09-19: added /site/ endpoint to expose read-only mode and any site notice. Also added the same response to the /accounts/account/ non-public response as a convenience for logged in users. https://github.com/mozilla/addons-server/issues/11493)
2019-10-17: moved /authenticate endpoint from api/v4/accounts/authenticate to version-less api/auth/authenticate-callback https://github.com/mozilla/addons-server/issues/10487
2019-11-14: removed
is_source_publicproperty from addons API https://github.com/mozilla/addons-server/issues/125142019-12-05: removed /addons/featured endpoint from v4+ and featured support from other addon api endpoints. https://github.com/mozilla/addons-server/issues/12937
2020-01-23: added /scanner/results (internal API endpoint).
2020-02-06: added /reviewers/addon/(int:addon_id)/allow_resubmission/ and /reviewers/addon/(int:addon_id)/deny_resubmission/. https://github.com/mozilla/addons-server/issues/13409
2020-02-20: added
addon_install_source_urlto abuse report endpoint2020-03-19: added /blocklist/block endpoint to expose add-on blocks https://github.com/mozilla/addons-server/issues/13706.
2020-03-26: added
addon_nameto blocklist/block api https://github.com/mozilla/addons-server/issues/137572020-08-13: added
applicationsinternal API to create new application versions https://github.com/mozilla/addons-server/issues/146492020-09-03: added
promotedfilter to addons search api https://github.com/mozilla/addons-server/issues/15272.2020-09-17: dropped
is_recommendedfrom addons api - usepromotedpropety instead. https://github.com/mozilla/addons-server/issues/152712020-09-17: dropped
recommended=truefilter from addons api - usepromoted=recommendedfilter instead. https://github.com/mozilla/addons-server/issues/154672020-09-17: added
?promoted=badgedsearch filter to addons api. https://github.com/mozilla/addons-server/issues/154682020-10-08: added channel-specific reviewer submission subscriptions endpoints. https://github.com/mozilla/addons-server/issues/15605
2020-10-15: moved hero shelves documentation to /shelves from /hero.
2020-10-15: added /shelves/sponsored/ endpoint https://github.com/mozilla/addons-server/issues/15617
2020-10-15: added /shelves/sponsored/impression and /shelves/sponsored/click endpoints https://github.com/mozilla/addons-server/issues/15618 and https://github.com/mozilla/addons-server/issues/15619
2020-10-22: added
promotedto primary hero shelf addon object. https://github.com/mozilla/addons-server/issues/157412020-10-22: added /shelves/sponsored/event endpoint for conversions, and to replace click endpoint https://github.com/mozilla/addons-server/issues/15718
2020-11-05: dropped heading and description from discovery API https://github.com/mozilla/addons-server/issues/11272
2020-11-05: added endpoint to receive Stripe events. https://github.com/mozilla/addons-server/issues/15879
2021-01-28: removed the /shelves/ endpoints from /v4/. They are only useful internally within AMO and are still under rapid development making them unsuitable for a frozen API.