Socket
Socket
Sign inDemoInstall

cohost

Package Overview
Dependencies
3
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cohost

Unofficial API for cohost.org


Version published
Maintainers
1
Install size
1.43 MB
Created

Readme

Source

cohost.js

Unofficial API for cohost.org

Install

npm i cohost

Usage

const cohost = require("cohost");

(async function () {
  // Create User and authenticate
  let user = new cohost.User();
  await user.login("YOUR_EMAIL", "YOUR_PASSWORD");

  // Get first Project of user
  let [project] = await user.getProjects();

  // Create Post
  await cohost.Post.create(project, {
    postState: 1,
    headline: "hello world from cohost.js",
    adultContent: false,
    blocks: [],
    cws: [],
    tags: []
  });

  // Get Posts of Project
  let posts = await project.getPosts();

  // Create a draft with attachments

  // 1. Create a draft
  const draftId = await cohost.Post.create(myProject, basePost);

  // 2. Upload the attachment
  const attachmentData = await myProject.uploadAttachment(
    draftId,
    path.resolve(__dirname, "./02-15_One_pr.png")
  );

  // 3. Add the attachment block to the draft and publish it
  await cohost.Post.update(myProject, draftId, {
    ...basePost,
    postState: 1,
    blocks: [
      ...basePost.blocks,
      { type: "attachment", attachment: { ...attachmentData } }
    ]
  });
})();

Features

Works:

  • Logging in
  • Getting the posts of a project
  • Creating a post

Doesn't work:

  • Editing a post: possible, haven't done it
  • Sharing a post: possible, haven't done it
  • Liking a post: possible, haven't done it
  • Getting notifications: possible, haven't done it
  • Getting the home feed: possible, haven't done it
  • Editing profiles: possible, haven't done it
  • Getting followers and following: possible, haven't done it
  • Getting bookmarks and bookmarking: possible, haven't done it
  • Getting a post by its ID: seems impossible? endpoint seems to be disabled
  • Getting posts from a tag: haven''t checked
  • ...everything else

Keywords

FAQs

Last updated on 09 Sep 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc