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

substack-sdk

v1.1.0

Published

substack unofficial SDK

Downloads

12

Readme

18jCAY-LogoMakr Substack SDK

npm GitHub license Maintenance

Motivation

Provide an typescript async promise based unofficial sdk for substack platform.

Installation

add it to your project using npm install substack-sdk --save or yarn add substack-sdk

Usage

this sdk provide functions realated to various substack objects

Authorization

Before any use you will require to initialize this SDK by copying the cookie to initialize any type of transaction.

import substack from "substack-sdk"

const cookie = "your substack cookie"
const domain = "your substack domain" // optional in most cases, but required for things like subscribers
substack.init(cookie, options)

Images

Upload

to upload an image you need to pass the base64 representation of it to the image.upload method. As seen on the next example:

import substack from "substack-sdk"

const imageString = `base64 representation of the image
ex: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAk0AAAJUCAIAAACHQYVcAAAACXBIWXMAAAsTAAALEwEAmpwYAAAgAElEQVR4nOy9WXMc130+fLpn3/...`

const uploadImageRespose = await substack.image.upload(imageString)

Attachemnts

add

Attachments are used as references to files (uploaded) and links that will be referenced in other objects we will se further on in this library.

The first parameter will be the type of the attachment (image or link), that will be the url passed in the secont parameter.

import substack from "substack-sdk"

const attachmentResponse = await substack.attachment.create("image",uploadImageRespose.url)
const attachmentResponse2 = await substack.attachment.create("link","https://www.alvarolorente.dev/blog/2024/02/14/leaders-build-trust-managers-take-control-the-path-to-empowering-teams")

Notes

Add

This is the simplest type of user interactive object, where you can use the attachments defined in the previous section.

The first parameter is an array of contents of the next types:

type Text = {
    message: string
}

type Link = {
    url: string
    text: string
}


type Content = Link | Text

The second parameter and will be an array of the attachment ids that whant to be link in this Note


import substack from "substack-sdk"

const createNoteRespose = await substack.note.create([
    { message: "Hello World" },
    { 
        text: "awesome post",
        url: "https://www.alvarolorente.dev/blog/2024/02/14/leaders-build-trust-managers-take-control-the-path-to-empowering-teams"
    }
], [attachmentResponse.id, attachmentResponse2.id])

Subscribers

This provides you access to the paginated set of your subscribers. This will require you to initialize the api with the correct domain of your newsletter.

This endpoint is paginated so you will need to pass the number of records to retrieve and the offset as second parameter.

import substack from "substack-sdk"

await substack.subscribers.retrieve(50,0)

Roadmap

  • [x] Images
  • [x] Notes
  • [x] Attachments
  • [ ] Threads
  • [x] Subscribers
  • [ ] Articles
  • ...
Logo created using logomkr. Check out the new logo that I created on LogoMakr.com https://logomakr.com/7cJ0NM