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

cohost-api

v0.0.9

Published

An unofficial tRPC-based wrapper API for Cohost.org

Downloads

25

Readme

cohost-api

An unofficial API wrapper for cohost.org that uses tRPC.

cohost-api is in very early development!

Usage

npm install cohost-api

import { Client, PostBuilder } from "cohost-api";

const client = new Client();

async function demo() {
  // Log in to Cohost
  let user = await client.login("EMAIL_ADDRESS", "YOUR_PASSWORD");
  // Get the first project
  let project = user?.projects[0];

  if (!project) {
    console.log("Couldn't log in :(");
    return;
  }

  // Switch to the project (not always necessary, but good practice as some endpoints require it)
  user?.switchProject(project);

  // Create new post
  let post = new PostBuilder();
    .addMarkdownBlock("hello from cohost-api!")
    .build();

  // Send to Cohost
  project.createDraft(post); // or use .createPost() to publish it immediately

  // Attach a file
  // This must be done after the post is created/drafted due to how the Cohost API works
  project.addAttachment(post, "file.png");
}

demo(); // Check your Cohost page!

API Reference

The API reference can be found in this document.

What works, and what doesn't

Working

  • Getting your projects' profile information
  • Creating posts & post drafts
  • Uploading attachments
  • Editing existing posts & post drafts
  • Liking and unliking posts
  • Getting a list of a project's posts
  • Getting a list of followers for a project
  • Getting a list of projects followed by your project

Not working

  • Editing a project's profile information
  • Sharing other users' posts to your project (i.e. reblogging)
  • Getting a project's notifications
  • Anything else not explicitly mentioned

Glossary

| Term | Definition | | ------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | Project | A page viewable as a Cohost profile with an @handle. | | User | A Cohost account with an email address and password. Users can have multiple projects, the same way a Tumblr account can have multiple blogs. | | Draft | A post which has not been published, but still belongs to a project, and can be viewed via a direct link. |

Reasons not to use this (yet)

  • The Cohost tRPC API is undocumented and not meant for public use.
  • The Cohost tRPC API can change at any time and break this package.
  • This package is in flux and breaking changes will happen all the time until it is stable.
  • The documentation for this package is incomplete, so using it might be confusing.