forked from bscott/subtrackr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-api.sh
More file actions
executable file
·64 lines (53 loc) · 1.67 KB
/
Copy pathtest-api.sh
File metadata and controls
executable file
·64 lines (53 loc) · 1.67 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# SubTrackr API Test Script
# This script demonstrates how to use the SubTrackr API with authentication
API_KEY="sk_your_api_key_here" # Replace with your actual API key
BASE_URL="http://localhost:8080"
echo "SubTrackr API Test Script"
echo "========================"
echo ""
echo "Make sure to:"
echo "1. Start the SubTrackr server (go run cmd/server/main.go)"
echo "2. Create an API key from the Settings page"
echo "3. Replace the API_KEY variable in this script with your actual key"
echo ""
echo "Press Enter to continue..."
read
# Test 1: Get all subscriptions
echo "Test 1: Getting all subscriptions..."
curl -s -H "Authorization: Bearer $API_KEY" \
"$BASE_URL/api/v1/subscriptions" | jq .
echo ""
echo "Press Enter to continue..."
read
# Test 2: Get statistics
echo "Test 2: Getting statistics..."
curl -s -H "Authorization: Bearer $API_KEY" \
"$BASE_URL/api/v1/stats" | jq .
echo ""
echo "Press Enter to continue..."
read
# Test 3: Create a new subscription
echo "Test 3: Creating a new subscription..."
# Note: You'll need to replace category_id with an actual ID from your categories
# You can get the list of categories with: curl -s "$BASE_URL/api/categories" | jq .
curl -s -X POST \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Test Subscription",
"cost": 9.99,
"schedule": "Monthly",
"status": "Active",
"category_id": 1
}' \
"$BASE_URL/api/v1/subscriptions" | jq .
echo ""
echo "Press Enter to continue..."
read
# Test 4: Export as JSON
echo "Test 4: Exporting as JSON..."
curl -s -H "Authorization: Bearer $API_KEY" \
"$BASE_URL/api/v1/export/json" | jq .
echo ""
echo "Test complete!"