doc: audit pass — fix env= bug, params, pagination, missing wrappers, broken examples

- env= -> environment= across all docs (Pydantic silently ignores env=)
- Remove __version__ check (doesn't exist in module)
- Fix APIClient(debug=True) missing required client_id/secret
- Fix post.listremoved usage (takes no postId, just lists removed posts)
- Fix JS true/false -> Python True/False in code blocks
- Fix parameter names: branchName->branch_slug, username->user_slug, postId->post_id
- Add missing lastEvaluatedKey param docs for list jobs
- Note post.listpublic as unauthenticated endpoint
- Fix pagination examples (LastEvaluatedKey, not ExclusiveStartKey dict)
- Remove non-existent headers param from make_request example
- Fix branch.listbyname example (takes no name arg)
- Add 4 missing wrapper docs: follow, react, trust, votecast
- Fix broken internal links (case-sensitive filenames)
- Fix <environment>_handle_token template artifact
- Add CODE_BUGS.md documenting 4 code bugs found during audit
This commit is contained in:
BarnacleBoy 2026-04-18 22:58:33 +00:00
parent c8611a7b88
commit a223bcb27a
9 changed files with 552 additions and 247 deletions

View file

@ -31,7 +31,7 @@ import os
API = trustcafeapiwrapper.APIClient(
client_id=os.getenv("TRUSTCAFE_CLIENT_ID"),
client_secret=os.getenv("TRUSTCAFE_CLIENT_SECRET"),
env="alpha", # or "production"
environment="alpha", # or "production"
debug=False
)
@ -159,7 +159,8 @@ Lists all posts.
posts = API.run_job('post.listall')
```
**Parameters:** None
**Parameters:**
- `lastEvaluatedKey` (dict, optional): Pagination key for next page
**Returns:** dict - List of all posts
@ -173,13 +174,14 @@ print(f"Total posts: {len(all_posts.get('Items', []))}")
### post.listpublic()
Lists public posts only.
Lists public posts only. This endpoint does not require authentication.
```python
public_posts = API.run_job('post.listpublic')
```
**Parameters:** None
**Parameters:**
- `lastEvaluatedKey` (dict, optional): Pagination key for next page
**Returns:** dict - List of public posts
@ -197,11 +199,12 @@ for post in public_posts.get('Items', []):
Lists posts in a specific branch.
```python
branch_posts = API.run_job('post.listbybranch', branch_name)
branch_posts = API.run_job('post.listbybranch', branch_slug)
```
**Parameters:**
- `branchName` (str): The branch identifier
- `branch_slug` (str): The branch/subwiki slug identifier
- `lastEvaluatedKey` (dict, optional): Pagination key for next page
**Returns:** dict - List of posts in the branch
@ -217,11 +220,12 @@ music_posts = API.run_job('post.listbybranch', "music")
Lists posts by a specific user profile.
```python
user_posts = API.run_job('post.listbyuserprofile', username)
user_posts = API.run_job('post.listbyuserprofile', user_slug)
```
**Parameters:**
- `username` (str): The username of the user
- `user_slug` (str): The user profile slug
- `lastEvaluatedKey` (dict, optional): Pagination key for next page
**Returns:** dict - List of posts by user
@ -237,17 +241,19 @@ journals = API.run_job('post.listbyuserprofile', "philosopher-jon")
Lists removed/deleted posts.
```python
removed = API.run_job('post.listremoved', post_id)
removed = API.run_job('post.listremoved')
```
**Parameters:**
- `postId` (str): The post identifier
- `lastEvaluatedKey` (dict, optional): Pagination key for next page
**Returns:** dict - Removed post data
**Returns:** dict - List of removed posts
**Example:**
```python
removed_post = API.run_job('post.listremoved', "deleted-post-id")
removed_posts = API.run_job('post.listremoved')
for post in removed_posts.get('Items', []):
print(post.get('pk'))
```
---
@ -295,7 +301,7 @@ comments = API.run_job('comment.listtbypostid', post_id)
```
**Parameters:**
- `postId` (str): The post ID
- `post_id` (str): The post ID
**Returns:** dict - List of comments
@ -360,7 +366,7 @@ result = API.run_job('follow.follow', payload)
```python
# Follow a user
followed = API.run_job('follow.follow', {
"isFollowing": true,
"isFollowing": True,
"parent": {
"pk": "userprofile#philosopher-jon",
"sk": "userprofile#philosopher-jon"
@ -368,9 +374,9 @@ followed = API.run_job('follow.follow', {
"followType": "userprofile",
"parentSlug": "philosopher-jon",
"preferences": {
"notification": true,
"emailNew": false,
"emailDigest": true
"notification": True,
"emailNew": False,
"emailDigest": True
}
})
```
@ -796,20 +802,20 @@ For large result sets, results may include pagination:
```python
def get_all_posts():
posts = []
paginator = None
last_key = None
while True:
response = API.run_job('post.listpublic', params)
if last_key:
response = API.run_job('post.listpublic', last_key)
else:
response = API.run_job('post.listpublic')
posts.extend(response.get('Items', []))
has_more = 'LastEvaluatedKey' in response
if not has_more:
break
# Set params for next page
params = {
'ExclusiveStartKey': response['LastEvaluatedKey']
}
last_key = response['LastEvaluatedKey']
return posts
```
@ -877,6 +883,6 @@ Implement rate limiting for production use (see main README for example).
## Next Steps
- [Wrappers Guide](wrappers.md) - High-level wrappers for common tasks
- [Custom Requests Guide](custom_requests.md) - Making advanced API calls
- [Troubleshooting Guide](troubleshooting.md) - Common issues and solutions
- [Wrappers Guide](WRAPPERS.md) - High-level wrappers for common tasks
- [Custom Requests Guide](CUSTOM_REQUESTS.md) - Making advanced API calls
- [Troubleshooting Guide](TROUBLESHOOTING.md) - Common issues and solutions