Skip to content

Commit

Permalink
adds get_publication_subscriber_count (#21)
Browse files Browse the repository at this point in the history
* adds get_publication_subscriber_count

* adds get_publication_subscriber_count
  • Loading branch information
dacx authored Nov 14, 2023
1 parent a960ebd commit 9f2762d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions examples/get_subscriber_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os

from dotenv import load_dotenv

from substack import Api

load_dotenv()

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

subscriberCount: int = api.get_publication_subscriber_count()
print(f"Subscriber count: {subscriberCount}")
12 changes: 12 additions & 0 deletions substack/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ def get_publication_users(self):

return Api._handle_response(response=response)

def get_publication_subscriber_count(self):

"""
Get subscriber count.
Returns:
"""
response = self._session.get(f"{self.publication_url}/publication_launch_checklist")

return Api._handle_response(response=response)['subscriberCount']

def get_posts(self) -> dict:
"""
Expand Down

0 comments on commit 9f2762d

Please sign in to comment.