forked from jorrit-stack/Raycast-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken-snippet.sh
More file actions
executable file
·47 lines (36 loc) · 1.21 KB
/
token-snippet.sh
File metadata and controls
executable file
·47 lines (36 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Show Rate Limits
# @raycast.mode fullOutput
# Optional parameters:
# @raycast.icon 📝
# @raycast.argument1 { "type": "text", "placeholder": "UserID" }
# @raycast.argument2 { "type": "text", "placeholder": "Mode: pretty or browser", "optional": true }
# Documentation:
# @raycast.description Show or open rate limits for a user
# @raycast.author Jorrit Harmamny
USERID="$1"
MODE="$2"
URL="https://bolt.new/api/rate-limits/$USERID"
if [[ "$MODE" == "browser" ]]; then
open "$URL"
exit 0
fi
if ! command -v jq &> /dev/null; then
echo "jq is required for pretty-printing JSON. Install with: brew install jq"
exit 1
fi
echo "Fetching rate limits for UserID: $USERID"
JSON=$(curl -s "$URL")
if [[ -z "$JSON" ]]; then
echo "No data returned. Check UserID or network."
exit 1
fi
echo "$JSON" | jq .
# Optionally, extract some key stats:
echo ""
echo "Token usage today: $(echo "$JSON" | jq '.tokenStats.totalToday')"
echo "Token usage this month: $(echo "$JSON" | jq '.tokenStats.totalThisMonth')"
echo "Max per day: $(echo "$JSON" | jq '.tokenStats.maxPerDay')"
echo "Max per month: $(echo "$JSON" | jq '.tokenStats.maxPerMonth')"