npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

linkding-api

v1.0.0

Published

Linkding REST API

Readme

linkding-api

Linkding API

Setup

Get the user token from the Linkding instance

Settings -> Admin -> Token -> Add Token

Get the token for your respective user and make sure you give necessary permissions

Usage

Initializing Linkding Instance

import { Linkding } from "linkding-api"

const serverUrl = "http://linkding.dale"
const adminToken = "94b13a59b9ecf002db1a85XXXXXXXXXXX"
let linkding = new Linkding(serverUrl, adminToken)

Bundle

// Bundle
let bundleInstance = linkding.getBundleInstance();

// Get single bundle
let bundle = await bundleInstance.getBundle(257)
console.log(bundle)

// Get all bundles
let bundles = await bundleInstance.getBundles()
console.log(bundles)

// Get bundles with options
let bundleOptions = {
    limit: 3, // Limits the max. number of results. Default is 100.
    // offset, // Index from which to start returning results
}
let bundlesWithOptions = await bundleInstance.getBundles(bundleOptions)
console.log(bundlesWithOptions)

// Create bundle
let bundleDataCreate = {
    "name": `Exten ${Math.random()}`,
    "search": "search terms",
    "any_tags": "tag1 tag2",
    "all_tags": "required-tag",
    "excluded_tags": "excluded-tag",
    "order": 7
}
let createBundle = await bundleInstance.createBundle(bundleDataCreate)
console.log(createBundle)

// Update bundle with full options
let bundleDataUpdateWithFullOptions = {
    "name": `Exten ${Math.random()}`,
    "search": "search terms",
    "any_tags": "tag1 tag2",
    "all_tags": "required-tag",
    "excluded_tags": "excluded-tag",
    "order": 5
}
let updateBundleWithFullOptions = await bundleInstance.updateBundle(260, bundleDataUpdateWithFullOptions)
console.log(updateBundleWithFullOptions)

// Update bundle with partial options
let bundleDataWithPartialOptions = {
    "name": `Exten ${Math.random()}`,
    "search": "search terms",
    "order": 7
}
let updateBundleWithPartialOptions = await bundleInstance.updateBundle(260, bundleDataWithPartialOptions)
console.log(updateBundleWithPartialOptions)

// Delete bundle
let deleteBundle = await bundleInstance.deleteBundle(260)
console.log(deleteBundle)

Tag

// Get Tag Instance
let tagInstance = linkding.getTagInstance()

// Get single tag
let tag = await tagInstance.getTag(1)
console.log(tag)

// Get tags
let tags = await tagInstance.getTags()
console.log(tags)

// Create tag
let tagData = {
    name: `Tag ${Math.random()}`
}
let createTag = await tagInstance.createTag(tagData)
console.log(createTag)

User

// Get user instance
let userInstance = linkding.getUserInstance()

// Get user profile
let user = await userInstance.getUser()
console.log(user)

Bookmark

// Get bookmark instance
let bookmarkInstance = linkding.getBookmarkInstance()

// Get bookmark
let bookmark = await bookmarkInstance.getBookmark(182)
console.log(bookmark)

// Get bookmarks
let bookmarks = await bookmarkInstance.getBookmarks()
console.log(bookmarks)

// Create bookmark
let bookmarkDataCreate = {
  "url": "https://example.com",
  "title": `Example title ${Math.random()}`,
  "description": `Example description ${Math.random()}`,
  "notes": "Example notes",
  "is_archived": false,
  "unread": false,
  "shared": false,
  "tag_names": [
    "tag1",
    "tag2"
  ]
}
let bookmarkCreate = await bookmarkInstance.createBookmark(bookmarkDataCreate)
console.log(bookmarkCreate)

// Update bookmark with full options
let bookmarkDataUpdateWithFullOptions = {
  "url": "https://example.com",
  "title": `Example title ${Math.random()}`,
  "description": `Example description ${Math.random()}`,
  "notes": `Example notes ${Math.random()}`,
  "is_archived": false,
  "unread": false,
  "shared": false,
  "tag_names": [
    "tag1",
    "tag2",
    "tag3"
  ]
}
let bookmarkUpdateWithFullOptions = await bookmarkInstance.updateBookmark(182, bookmarkDataUpdateWithFullOptions)
console.log(bookmarkUpdateWithFullOptions)

// Update bookmark with partial options
let bookmarkDataUpdateWithPartialOptions = {
  "url": "https://example.com",
  "title": `Example title ${Math.random()}`,
  "description": `Example description ${Math.random()}`,
  "notes": `Example notes ${Math.random()}`
}
let bookmarkUpdateWithPartialOptions = await bookmarkInstance.updateBookmark(182, bookmarkDataUpdateWithPartialOptions)
console.log(bookmarkUpdateWithPartialOptions)

// Get archived bookmarks
let bookmarksArchived = await bookmarkInstance.getArchivedBookmarks()
console.log(bookmarksArchived)

// Archive bookmark
let bookmarkArchive = await bookmarkInstance.archiveBookmark(182)
console.log(bookmarkArchive)

// Unarchive bookmark
let bookmarkUnarchive = await bookmarkInstance.unarchiveBookmark(182)
console.log(bookmarkUnarchive)

// Check bookmark
let bookmarkDataCheck = {
    url: "https://example.com"
}
let bookmarkCheck = await bookmarkInstance.checkBookmark(bookmarkDataCheck)
console.log(bookmarkCheck)

// Delete bookmark
let bookmarkDelete = await bookmarkInstance.deleteBookmark(182)
console.log(bookmarkDelete)

Bookmark Asset

// Get bookmark asset instance
let bookmarkAssetInstance = linkding.getBookmarkAssetsInstance()

// Get bookmark asset
let bookmarkAsset = await bookmarkAssetInstance.getBookmarkAsset(183, 1)
console.log(bookmarkAsset)

// Get bookmark assets
let bookmarkAssets = await bookmarkAssetInstance.getBookmarkAssets(183)
console.log(bookmarkAssets)

// Upload bookmark asset 
let formData = new FormData();
const filePath = "/home/<user>/Pictures/Screenshot_2018-08-11-05-45-23.png"
const mimeType = mime.getType(filePath)
const fileName = path.parse(filePath).base;

// using readFileSync (blocking sync)
const file = new Blob([fs.readFileSync(filePath)], { type: mimeType });
formData.append("file", file, fileName);
let bookmarkAssetUploadUsingReafFileSync = await bookmarkAssetInstance.uploadBookmarkAsset(183, formData)
console.log(bookmarkAssetUploadUsingReafFileSync)

// Upload bookmark asset using fs.createReadStream
const readableStream = fs.createReadStream(filePath);
const fileChunks = [];
readableStream.on('error', function (error) {
    console.log(`error: ${error.message}`);
})
readableStream.on('data', async (chunk) => {
    fileChunks.push(chunk)
})
readableStream.on('end', async () => {
    const file = new Blob(fileChunks, { type: mimeType });
    formData.append("file", file, fileName);
    let bookmarkAssetUploadUsingCreateReadStream = await bookmarkAssetInstance.uploadBookmarkAsset(183, formData)
    console.log(bookmarkAssetUploadUsingCreateReadStream)
})

// Download bookmark asset
let bookmarkAssetDownload = await bookmarkAssetInstance.downloadBookmarkAsset(183, 11)
bookmarkAssetDownload.data.pipe(fs.createWriteStream("./Screenshot_2018-08-11-05-45-23.png"));

// Delete bookmark asset
let bookmarkAssetDelete = await bookmarkAssetInstance.deleteBookmarkAsset(183, 1)
console.log(bookmarkAssetDelete)