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

shotty-api

v0.0.14

Published

Shotty API helper

Downloads

22

Readme

Shotty API helper — JS

Install:

$ npm i shotty-api --save

Object types:

  • users
  • chats
  • tasks
  • todos
  • versions
  • shots
  • projects
  • lists
  • notifications

Require and initialize:

const shotty = require('shotty-api')('shotty.local', 'your-secret-key');

Connect:

shotty.connect().then(connectData => ...).catch(error => ...)

Changes feed:

shotty.changes(type, {onConnect: () => ...})
.onInit(items => ...)
.onAdd((newItem, allItems) => ...)
.onRemove((removedItem, allItems) => ...)
.onUpdate((newItem, oldItem, allItems) => ...)
.onDisconnect(() => ...);

allItems is an array in which shotty object holds all actual items of the type.

One-time requests:

shotty.get.user(id).then(item => ...).catch(error => ...)
shotty.get.users().then(items => ...).catch(error => ...)

shotty.get.chat(id).then(item => ...).catch(error => ...)
shotty.get.chats(projectId, shotId).then(items => ...).catch(error => ...)

shotty.get.task(id).then(item => ...).catch(error => ...)
shotty.get.tasks(projectId, shotId).then(items => ...).catch(error => ...)

shotty.get.todo(id).then(item => ...).catch(error => ...)
shotty.get.todos(projectId, shotId, versionId).then(items => ...).catch(error => ...)

shotty.get.version(id).then(item => ...).catch(error => ...)
shotty.get.versions(projectId, shotId).then(items => ...).catch(error => ...)

shotty.get.shot(id).then(item => ...).catch(error => ...)
shotty.get.shots(projectId, shotId).then(items => ...).catch(error => ...)

shotty.get.project(id).then(item => ...).catch(error => ...)
shotty.get.projects().then(items => ...).catch(error => ...)

shotty.get.list(id).then(item => ...).catch(error => ...)
shotty.get.lists(projectId).then(items => ...).catch(error => ...)

shotty.get.notification(id).then(item => ...).catch(error => ...)
shotty.get.notifications(userId).then(items => ...).catch(error => ...)

shotty.get.settings().then(items => ...).catch(error => ...)

id is required.

projectId, shotId and versionId are optional.

Writing changes

Creating

shotty.create(type, object)

Editing

shotty.edit(type, id, changes)
shotty.edit(type, {id: objectId, ...changes})

Deleting

shotty.delete(type, id)

All three functions return promises. type can be any of the available types except users.

Object schemes are here.

Uploading versions

shotty.upload(type, file, data)
  • type — the type of uploading file, possible types: avatar, poster, file (chats), version
  • file — path to the file
  • data — file description fields

See example for versions. More examples are coming soon.


Examples

Feeds and one-time requests

const shotty = require('shotty-api')('shotty.local', 'your-secret-key');

shotty.connect()
.then(async result => { // async is only for `await`
	// feeds
	shotty.changes('shots', {onConnect: () => console.info('socket connected')})
	.onInit(items => console.info('got init data', items.length))
	.onAdd((item, all) => console.info('got new item', item, all.length))
	.onRemove((item, all) => console.info('an item was removed', item, all.length))
	.onUpdate((newItem, oldItem, all) => console.info('an item has been updated', oldItem, newItem, all.length))
	.onDisconnect((...args) => console.info('changes feed disconnected', ...args))

	// one-time get request for versions of project `test` and shot `3cd7c189-fda3-46c8-bb0c-742e6aa24efe`
	shotty.get.versions('test', '3cd7c189-fda3-46c8-bb0c-742e6aa24efe')
	.then(items => console.log('got versions', items))
	.catch(error => console.error(error));

	// you can use async/await syntax with the .get functions
	let users = await shotty.get.users();
})
.catch(error => console.error(error));

Writing with promises

const timeout = f => setTimeout(f, 1000);

shotty.connect()
.then(() =>
	shotty.create('shot', {projectId: 'demo', sequence: 'api', code: '001', creatorId: null})
	.then(shot => {
		console.log('created shot', shot.id);

		timeout(() =>
			shotty.edit('shot', shot.id, {description: 'test'})
			.then(editedShot => {
				console.log('edited shot', editedShot.id);

				timeout(() =>
					shotty.edit('shot', {id: shot.id, description: 'test2'})
					.then(editedShot => {
						console.log('edited shot again', editedShot.id);

						timeout(() =>
							shotty.delete('shot', editedShot.id)
							.then(result => console.log('deleted shot', result))
							.catch(error => console.error('cannot delete shot', error))
						);
					})
					.catch(error => console.error('cannot edit shot second time', error))
				);
			})
			.catch(error => console.error('cannot edit shot', error))
		);
	})
	.catch(error => console.error('cannot create shot', error))
);

Writing with async/await functions

// don't forget to wrap promises with try/catch blocks
const timeout = f => setTimeout(f, 1000);

shotty.connect()
.then(async () => {
	let shot = await shotty.create('shot', {projectId: 'demo', sequence: 'api', code: '001', creatorId: null});
	console.log('created shot', shot.id);

	timeout(async () => {
		let editedShot = await shotty.edit('shot', shot.id, {description: 'test'});
		console.log('edited shot', editedShot.id);

		timeout(async () => {
			let editedShot = await shotty.edit('shot', {id: shot.id, description: 'test 2'});
			console.log('edited shot again', editedShot.id);

			timeout(async () => {
				let count = await shotty.delete('shot', editedShot.id);
				console.log('deleted shot', count);
			});
		});
	});
});