Skip to content

Commit 9f2762d

Browse files
authored
adds get_publication_subscriber_count (#21)
* adds get_publication_subscriber_count * adds get_publication_subscriber_count
1 parent a960ebd commit 9f2762d

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

examples/get_subscriber_count.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
3+
from dotenv import load_dotenv
4+
5+
from substack import Api
6+
7+
load_dotenv()
8+
9+
if __name__ == "__main__":
10+
api = Api(
11+
email=os.getenv("EMAIL"),
12+
password=os.getenv("PASSWORD"),
13+
publication_url=os.getenv("PUBLICATION_URL"),
14+
)
15+
16+
subscriberCount: int = api.get_publication_subscriber_count()
17+
print(f"Subscriber count: {subscriberCount}")

substack/api.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ def get_publication_users(self):
103103

104104
return Api._handle_response(response=response)
105105

106+
def get_publication_subscriber_count(self):
107+
108+
"""
109+
Get subscriber count.
110+
111+
Returns:
112+
113+
"""
114+
response = self._session.get(f"{self.publication_url}/publication_launch_checklist")
115+
116+
return Api._handle_response(response=response)['subscriberCount']
117+
106118
def get_posts(self) -> dict:
107119
"""
108120

0 commit comments

Comments
 (0)