GithubHelp home page GithubHelp logo

dacx / python-substack Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ma2za/python-substack

0.0 0.0 0.0 165 KB

Substack API python implementation

Home Page: https://pypi.org/project/python-substack/

License: MIT License

Python 100.00%

python-substack's Introduction

Python Substack

This is an unofficial library providing a Python interface for Substack. I am in no way affiliated with Substack.

Python Downloads Release Build

Installation

You can install python-substack using:

$ pip install python-substack

Setup

Set the following environment variables by creating a .env file:

PUBLICATION_URL=https://ma2za.substack.com
EMAIL=
PASSWORD=
USER_ID=

To discover the USER_ID go to your public profile page, in the URL bar of the browser you find the substack address followed by your USER_ID and your username: https://substack.com/profile/[USER_ID]-[username]

The .env file will be ignored by git but always be careful.


Usage

Check out the examples folder for some examples ๐Ÿ˜ƒ ๐Ÿš€

import os

from substack import Api
from substack.post import Post

api = Api(
    email=os.getenv("EMAIL"),
    password=os.getenv("PASSWORD"),
    publication_url=os.getenv("PUBLICATION_URL"),
)

post = Post(
    title="How to publish a Substack post using the Python API",
    subtitle="This post was published using the Python API",
    user_id=os.getenv("USER_ID")
)

post.add({'type': 'paragraph', 'content': 'This is how you add a new paragraph to your post!'})

#bolden text
post.add({'type': "paragraph",'content':[{'content': "This is how you "},{'content': "bolden ",'marks':[{'type': "strong"}]},{'content': "a word."}]})

#add hyperlink to text
post.add({'type':'paragraph','content':[{'content': "View Link",'marks':[{'type': "link",'href':'https://whoraised.substack.com/'}]}]})

#add image
post.add({'type':'captionedImage','src': "https://media.tenor.com/7B4jMa-a7bsAAAAC/i-am-batman.gif"})

draft = api.post_draft(post.get_draft())

api.prepublish_draft(draft.get("id"))

api.publish_draft(draft.get("id"))

python-substack's People

Contributors

ma2za avatar dependabot[bot] avatar dacx avatar suhan1996 avatar shernshiou avatar ma00 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.