Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mogery/cohost.js
Unofficial API for cohost.org
https://github.com/mogery/cohost.js
cohost
Last synced: 11 days ago
JSON representation
Unofficial API for cohost.org
- Host: GitHub
- URL: https://github.com/mogery/cohost.js
- Owner: mogery
- License: mit
- Created: 2022-06-29T12:10:14.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-14T19:08:15.000Z (5 months ago)
- Last Synced: 2024-09-19T03:11:05.896Z (about 2 months ago)
- Topics: cohost
- Language: JavaScript
- Homepage:
- Size: 46.9 KB
- Stars: 25
- Watchers: 2
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cohost - cohost.js - Unofficial API for Cohost. (API Libraries)
README
# cohost.js
Unofficial API for cohost.org
## Install
```bash
npm i cohost
```## Usage
```js
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
let myPostID = await cohost.Post.create(project, {
postState: 1,
headline: "hello world from cohost.js",
adultContent: false,
blocks: [],
cws: [],
tags: []
});// Edit Post
await cohost.Post.update(project, myPostID, {
postState: 1,
headline: "Hello world from cohost.js!",
adultContent: false,
blocks: [],
cws: [],
tags: ["cohost.js"]
});// 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
- Editing a postDoesn't work:
- 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