Package: cohost
Cohost.pyA python library for Cohost!Hyperstartpip install cohostQuickstartpip install cohostfromcohost.models.userimportUserfromcohost.models.blockimportAttachmentBlock,MarkdownBlockcookie='yourCookie'user=User.loginWithCookie(cookie)# Alternatively: use a username/password combo# import os# user = User.login(os.getenv("COHOST_USER"), os.getenv("COHOST_PASS"))forprojectinuser.editedProjects:print(project)# Print all pages you have edit permissions forproject=user.getProject('vallerie')# will retrieve the page I have edit writes for with handle @vallerieblocks=[AttachmentBlock('pybug.png'),# References image file pybug.pngMarkdownBlock('**Hello from Python!**')# Example of markdown / text block]newPost=project.post('Title of python post!',blocks,tags=['cohost.py','python'])print('Check out your post at{}'.format(newPost.url))Getting startedHave an activated Cohost.org account. This entire library will probably explode if you use it with an unactivated account, and it defo isn't some bypass.Install library withpip install cohostLog in with a cookie or a username/passwordImport data models you require, and go from there!TerminologySome things are different on the API, and on the UI, and for the most part this library will match the API's terminology. Some key concepts:A user is minimal - it will contain authentication, email, and some other key details but not much elseAll the pages you can edit are referred to as "projects"Each post is made up content "Blocks"Retrieving your cookieOne way to login is to use an authentication token for Cohost. This can be retrieved by:Open Developer Tools in your browserGo to "Storage"Find the "Cookies" entryCopy the data for "connect.sid".Use this in the libraryWhat's working? (allegedly)Logging in as a user (using either a cookie or a username/password)Retrieving projects of a user (and of other people when you got a post to go with it)Retrieving posts of a pagePosting to a pageAttaching images to a post (with alt-text support!)Editing postsRetrieving notifications with paginationWhat's not done but needs to be done?Retrieving single posts - currently have to read entire projectsRetrieving a project's draftsRetrieving a projects of others without a post inbetweenSharing posts (with comment)Editing profilesDeleting postsLikely a whole bunch of other things I haven't thought aboutBetter docsWhat's not implemented intentionally?Some features I intend not to add. These features aren't impossible to build, but, they could be detrimental to the Cohost experience for other users, send mass notifications without an account being activated, or pose security issues. This is designed to deter low effort malicious bots, to reduce the workload on Cohost's staff.These include:Editing a user's passwordAccepting follow requestsSharing a post without a commentCreating new projectsIf you implement these features, please keep themprivatefor your projects.
If you think one of these should be implemented, please file a GitHub issue with your case as to why.Support CohostBuy Cohost PLUSFollow me on Cohost!hello is meThankscohost.js- provided a good point to start looking at how to go about this, and how cohost works in fundamental aspects. also has a working login thing which i need to properly understand at some pointcohost.org- home of eggbugrequests- i would be lost in python if it weren't for requests, my belovedthe random tumblr anon who sent me an activation link - thanks