Skip to content

Commit 140712f

Browse files
mikipaletclaude
andcommitted
docs: fix README examples to match actual implementation
- Remove false claim about LATE_API_KEY env var auto-detection - api_key parameter is required, not optional - Fix analytics.get() example to use correct parameters (period, not post_id) - Fix error handling imports to use correct exception names (LateAPIError, LateRateLimitError, LateValidationError) - Fix async example to include required api_key - Update timeout default from 60.0 to 30.0 to match implementation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6f85f9a commit 140712f

1 file changed

Lines changed: 16 additions & 17 deletions

File tree

README.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pip install late-sdk
2828
```python
2929
from late import Late
3030

31-
late = Late() # Uses LATE_API_KEY env var
31+
late = Late(api_key="your-api-key")
3232

3333
# Publish to multiple platforms with one call
3434
post = late.posts.create(
@@ -48,9 +48,9 @@ print(f"Published to {len(post['post']['platforms'])} platforms!")
4848

4949
```python
5050
late = Late(
51-
api_key="your-api-key", # Defaults to os.environ["LATE_API_KEY"]
52-
base_url="https://getlate.dev/api",
53-
timeout=60.0,
51+
api_key="your-api-key", # Required
52+
base_url="https://getlate.dev/api", # Optional, this is the default
53+
timeout=30.0, # Optional, request timeout in seconds
5454
)
5555
```
5656

@@ -115,11 +115,9 @@ post = late.posts.create(
115115
### Get Analytics
116116

117117
```python
118-
data = late.analytics.get(post_id="post_xxx")
118+
data = late.analytics.get(period="30d")
119119

120-
print("Views:", data["analytics"]["views"])
121-
print("Likes:", data["analytics"]["likes"])
122-
print("Engagement Rate:", data["analytics"]["engagementRate"])
120+
print("Analytics:", data)
123121
```
124122

125123
### List Connected Accounts
@@ -138,7 +136,7 @@ import asyncio
138136
from late import Late
139137

140138
async def main():
141-
async with Late() as late:
139+
async with Late(api_key="your-api-key") as late:
142140
posts = await late.posts.alist(status="scheduled")
143141
print(f"Found {len(posts['posts'])} scheduled posts")
144142

@@ -148,17 +146,18 @@ asyncio.run(main())
148146
## Error Handling
149147

150148
```python
151-
from late import Late
152-
from late.exceptions import LateApiError, RateLimitError, ValidationError
149+
from late import Late, LateAPIError, LateRateLimitError, LateValidationError
150+
151+
late = Late(api_key="your-api-key")
153152

154153
try:
155154
late.posts.create(content="Hello!", platforms=[...])
156-
except RateLimitError as e:
157-
print(f"Rate limited. Retry in {e.retry_after}s")
158-
except ValidationError as e:
159-
print(f"Invalid request: {e.errors}")
160-
except LateApiError as e:
161-
print(f"Error {e.status_code}: {e.message}")
155+
except LateRateLimitError as e:
156+
print(f"Rate limited: {e}")
157+
except LateValidationError as e:
158+
print(f"Invalid request: {e}")
159+
except LateAPIError as e:
160+
print(f"API error: {e}")
162161
```
163162

164163
## SDK Reference

0 commit comments

Comments
 (0)