This guide provides copy-paste curl commands to test the core donation API flows without requiring Postman or Insomnia.
# Set your environment variables
export API_KEY="your-api-key-here"
export BASE_URL="http://localhost:3000/api"
export DONOR_PUBLIC_KEY="GBUQWP3BOUZX34ULNQG23RQ6F4BWFIРЕQCLMNZ4QSY47PCNQRICKS57"
export RECIPIENT_PUBLIC_KEY="GCEZWJG7SSHQUUP7IBRN23JQCQR53ROE44TSBROAM4TOBJOJJU5YV2Z2"curl -X POST "$BASE_URL/wallets" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"publicKey": "'$DONOR_PUBLIC_KEY'",
"name": "My Donation Wallet",
"metadata": {
"region": "US",
"donorType": "individual"
}
}'curl -X GET "$BASE_URL/wallets/$DONOR_PUBLIC_KEY/transactions" \
-H "X-API-Key: $API_KEY"curl -X POST "$BASE_URL/donations" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"senderId": "'$DONOR_PUBLIC_KEY'",
"recipientId": "'$RECIPIENT_PUBLIC_KEY'",
"amount": "50.00",
"memo": "Education fund donation",
"sdgCategories": ["04"]
}' | jq .curl -X GET "$BASE_URL/donations/recent?limit=10" \
-H "X-API-Key: $API_KEY" | jq .# Replace TRANSACTION_HASH with the hash from create response
curl -X POST "$BASE_URL/donations/verify" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"transactionHash": "TRANSACTION_HASH_HERE"
}' | jq .curl -X GET "$BASE_URL/donations/limits" \
-H "X-API-Key: $API_KEY" | jq .curl -X POST "$BASE_URL/stream/create" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"donorId": "'$DONOR_PUBLIC_KEY'",
"recipientId": "'$RECIPIENT_PUBLIC_KEY'",
"amount": "25.00",
"frequency": "monthly",
"startDate": "2026-07-01"
}' | jq .curl -X GET "$BASE_URL/stream/schedules" \
-H "X-API-Key: $API_KEY" | jq .# Replace SCHEDULE_ID with ID from list response
curl -X GET "$BASE_URL/stream/schedules/SCHEDULE_ID" \
-H "X-API-Key: $API_KEY" | jq .# Replace SCHEDULE_ID with ID from list response
curl -X DELETE "$BASE_URL/stream/schedules/SCHEDULE_ID" \
-H "X-API-Key: $API_KEY"curl -X GET "$BASE_URL/stats/daily" \
-H "X-API-Key: $API_KEY" | jq .curl -X GET "$BASE_URL/stats/weekly" \
-H "X-API-Key: $API_KEY" | jq .curl -X GET "$BASE_URL/stats/summary" \
-H "X-API-Key: $API_KEY" | jq .curl -X GET "$BASE_URL/stats/donors" \
-H "X-API-Key: $API_KEY" | jq .curl -X GET "$BASE_URL/stats/recipients" \
-H "X-API-Key: $API_KEY" | jq .This uses SSE (Server-Sent Events) for real-time updates. Open in a separate terminal and leave running:
curl -X GET "$BASE_URL/stream/transactions" \
-H "X-API-Key: $API_KEY" \
-H "Accept: text/event-stream"You should see events like:
data: {"type":"transaction","id":"123","amount":"50.00","sender":"...","recipient":"..."}
curl -X GET "$BASE_URL/stream/leaderboard" \
-H "X-API-Key: $API_KEY" \
-H "Accept: text/event-stream"curl -X GET "$BASE_URL/health" | jq .All requests (except /health) require the X-API-Key header:
-H "X-API-Key: your-api-key-here"- Pretty-print JSON: Add
| jq .to any curl command to format the response - Save response: Add
-o filename.jsonto save the response - Include headers: Add
-iflag to see response headers - Show request headers: Add
-vflag for verbose output - Debug: Add
-X GETexplicitly if curl is confused about the HTTP method
#!/bin/bash
set -e # Exit on error
# Set variables
export API_KEY="dev-key"
export BASE_URL="http://localhost:3000/api"
export DONOR="GBUQWP3BOUZX34ULNQG23RQ6F4BWFIРЕQCLMNZ4QSY47PCNQRICKS57"
export RECIPIENT="GCEZWJG7SSHQUUP7IBRN23JQCQR53ROE44TSBROAM4TOBJOJJU5YV2Z2"
echo "📊 Checking API health..."
curl -s "$BASE_URL/health" | jq .
echo -e "\n💰 Creating a donation..."
DONATION=$(curl -s -X POST "$BASE_URL/donations" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"senderId": "'$DONOR'",
"recipientId": "'$RECIPIENT'",
"amount": "50",
"memo": "Test donation"
}')
echo $DONATION | jq .
echo -e "\n📈 Getting recent donations..."
curl -s "$BASE_URL/donations/recent?limit=5" \
-H "X-API-Key: $API_KEY" | jq .
echo -e "\n📊 Getting summary stats..."
curl -s "$BASE_URL/stats/summary" \
-H "X-API-Key: $API_KEY" | jq .Save as test-api.sh, make executable (chmod +x test-api.sh), and run (./test-api.sh).
401 Unauthorized: Make sure API_KEY is set correctly in the X-API-Key header
404 Not Found: Check that BASE_URL is correct and the server is running
Connection refused: Make sure the API is running on localhost:3000
jq: command not found: Install jq with sudo apt-get install jq (Linux) or brew install jq (macOS)