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 🙏

© 2024 – Pkg Stats / Ryan Hefner

dat-nexus-api

v4.0.0

Published

API for interacting with Dat Nexus profiles.

Downloads

2

Readme

Dat Nexus API

An API for reading and writing-to profile archives in the Dat Nexus App. A "Profile Site" is a dat-site which

  1. represents a user (identity),
  2. broadcasts information (media feed), and
  3. and follows other profiles (social relationships).

Nexus Profile Sites are used to identify users and create social feeds.

var NexusAPI = require('dat-nexus-api')

// create a db instance
var db = await NexusAPI.open(/* cache session */)
var db = await NexusAPI.open(mainUserArchive) // mainUserArchive is a DatArchive instance

// profile data
// =

await db.getProfile() // => {name:, bio:, avatar:}
await db.setProfile({name:, bio:, avatar:})

// management
// =

await db.close(destroy: Boolean) // close db instance, optionally delete its data

await db.addArchive(archive) // add archive to the db
await db.addArchives(archives) // add archives to the db
await db.removeArchive(archive) // remove archive from the db
db.listArchives() // list archives in the db
await db.pruneUnfollowedArchives(mainUserArchive) // remove archives from the db that arent followed by mainUserArchive

// social relationships
// =

await db.follow(userArchive, targetUser, targetUserName?)
await db.unfollow(userArchive, targetUser)

db.getFollowersQuery(userArchive) // get InjestRecordSet for a followers query
await db.listFollowers(userArchive) // list users in db that follow the user
await db.countFollowers(userArchive) // count users in db that follow the user
await db.listFriends(userArchive) // list users in db that mutually follow the user
await db.countFriends(userArchive) // count users in db that mutually follow the user

await db.isFollowing(archiveA, archiveB) // => true
await db.isFriendsWith(archiveA, archiveB) // => true

// posting to the feed
// =

await db.broadcast(userArchive, {
  text: 'Hello, world!',
})

// posting a reply
await db.broadcast(userArchive, {
  text: 'Hello, world!',
  threadParent: parent._url, // url of message replying to
  threadRoot: top._url // url of topmost ancestor message - defaults to threadParent's value
})

// reading the feed
// =

// get InjestRecordSet for a broadcasts query
db.getBroadcastsQuery({
  author: url | DatArchive,
  after: timestamp,
  before: timestamp,
  offset: number,
  limit: number,
  reverse: boolean
})

// get broadcast records
await db.listBroadcasts({
  // all opts from getBroadcastsQuery, plus:
  fetchAuthor: boolean,
  fetchReplies: boolean,
  countVotes: boolean
})

await db.countBroadcasts(/* same opts for getBroadcastsQuery */)
await db.getBroadcast(url)

// votes
// =

await db.vote (userArchive, {vote, subject})
// vote should be -1, 0, or 1
// subject should be a dat url

db.getVotesQuery(subject)
await db.listVotes(subject)

// this returns {up: number, down: number, value: number, upVoters: array of urls, currentUsersVote: number}
async db.countVotes(subject)