The WebExtensions bookmarks
API lets an extension interact with and manipulate the browser's bookmarking system. You can use it to bookmark pages, retrieve existing bookmarks, and edit, remove, and organize bookmarks.
To use this API, an extension must request the "bookmarks" permission in its manifest.json
file.
Types
bookmarks.BookmarkTreeNodeUnmodifiable
- A
String
enum which specifies why a bookmark or folder is unmodifiable. bookmarks.BookmarkTreeNode
- Represents a bookmark or folder in the bookmarks tree.
bookmarks.CreateDetails
- Contains information which is passed to the
bookmarks.create()
function when creating a new bookmark.
Functions
bookmarks.create()
- Creates a bookmark or folder.
bookmarks.get()
- Retrieves one or more
BookmarkTreeNode
s, given a bookmark's ID or an array of bookmark IDs. bookmarks.getChildren()
- Retrieves the children of the specified
BookmarkTreeNode
. bookmarks.getRecent()
- Retrieves a requested number of recently added bookmarks.
bookmarks.getSubTree()
- Retrieves part of the bookmarks tree, starting at the specified node.
bookmarks.getTree()
- Retrieves the entire bookmarks tree into an array of
BookmarkTreeNode
objects. bookmarks.move()
- Moves the specified
BookmarkTreeNode
to a new location in the bookmark tree. bookmarks.remove()
- Removes a bookmark or an empty bookmark folder, given the node's ID.
bookmarks.removeTree()
- Recursively removes a bookmark folder; that is, given the ID of a folder node, removes that node and all its descendants.
bookmarks.search()
- Searches for
BookmarkTreeNode
s matching a specified set of criteria. bookmarks.update()
- Updates the title and/or URL of a bookmark, or the name of a bookmark folder, given the bookmark's ID.
Events
bookmarks.onCreated
- Fired when a bookmark or folder is created.
bookmarks.onRemoved
- Fired when a bookmark or folder is removed. When a folder is removed recursively, a single notification is fired for the folder, and none for its contents.
bookmarks.onChanged
- Fired when a bookmark or folder changes. Currently, only
title
andurl
changes trigger this. bookmarks.onMoved
- Fired when a bookmark or folder is moved to a different parent folder or to a new offset within its folder.
bookmarks.onChildrenReordered
- Fired when the user has sorted the children of a folder in the browser's UI. This is not called as a result of a
move()
. bookmarks.onImportBegan
- Fired when a bookmark import session is begun. Expensive observers should ignore
bookmarks.onCreated
updates untilbookmarks.onImportEnded
is fired. Observers should still handle other notifications immediately. bookmarks.onImportEnded
- Fired when a bookmark import session has finished.
Browser compatibility
Chrome | Edge | Firefox | Firefox for Android | Opera | |
---|---|---|---|---|---|
BookmarkTreeNode | Yes | No | 45 | No | Yes |
BookmarkTreeNodeUnmodifiable | Yes | No | 45 | No | Yes |
CreateDetails | Yes | No | 45 | No | Yes |
create | Yes | 15 | 45 | No | Yes |
get | Yes | No | 45 | No | Yes |
getChildren | Yes | No | 45 | No | Yes |
getRecent | Yes | No | 47 | No | Yes |
getSubTree | Yes | No | 45 | No | Yes |
getTree | Yes | 15 | 45 | No | Yes |
move | Yes | 15 | 45 | No | Yes |
onChanged | Yes | No | 52 | No | Yes |
onChildrenReordered | Yes | No | No | No | Yes |
onCreated | Yes | No | 52 | No | Yes |
onImportBegan | Yes | No | No | No | Yes |
onImportEnded | Yes | No | No | No | Yes |
onMoved | Yes | No | 52 | No | Yes |
onRemoved | Yes | No | 52 | No | Yes |
remove | Yes | 15 | 45 | No | Yes |
removeTree | Yes | 15 | 47 | No | Yes |
search | Yes | No | 47 | No | Yes |
update | Yes | 15 | 45 | No | Yes |
The "Chrome incompatibilities" section is included from https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities using the WebExtChromeCompat macro.
If you need to update this content, edit https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities, then shift-refresh this page to see your changes.
Edge incompatibilities
Promises are not supported in Edge. Use callbacks instead.
Chrome incompatibilities
None.
Example extensions
This API is based on Chromium's chrome.bookmarks
API. This documentation is derived from bookmarks.json
in the Chromium code.
Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.
// Copyright 2015 The Chromium Authors. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.