Skip to content

cURL Examples

Command-line examples for testing and integrating with the FundlyHub API using cURL.

Authentication Setup

Environment Variables

Set up your environment variables for easier testing

bash
# Set these environment variables in your terminal
export API_URL="https://api.fundlyhub.org/api/v1"
export COOKIE_JAR="cookies.txt"

# Test the connection
curl -i "$API_URL/health"

User Authentication

Register and sign in via AWS Cognito. Use a cookie jar to persist session cookies.

bash
# Register a new user
curl -X POST "$API_URL/cognito/signup" \
  -H "Content-Type: application/json" \
  -c "$COOKIE_JAR" \
  -d '{
    "email": "user@example.com",
    "password": "SecureP@ssw0rd!",
    "name": "John Doe"
  }'

# Confirm registration with email code
curl -X POST "$API_URL/cognito/confirm" \
  -H "Content-Type: application/json" \
  -c "$COOKIE_JAR" \
  -d '{
    "email": "user@example.com",
    "code": "123456"
  }'

# Sign in — cookies are stored in the cookie jar
curl -X POST "$API_URL/cognito/signin" \
  -H "Content-Type: application/json" \
  -c "$COOKIE_JAR" -b "$COOKIE_JAR" \
  -d '{
    "email": "user@example.com",
    "password": "SecureP@ssw0rd!"
  }'

Fundraiser Operations

GET

List Fundraisers

bash
# Get all active fundraisers
curl -X GET "$API_URL/fundraisers?status=active&limit=20"

# Filter by category
curl -X GET "$API_URL/fundraisers?category_id=123e4567-e89b-12d3-a456-426614174000"

# Search fundraisers
curl -X GET "$API_URL/fundraisers?search=medical&status=active"

POST

Create Fundraiser

bash
# Create a new fundraiser (requires auth — uses cookie jar)
curl -X POST "$API_URL/fundraisers" \
  -b "$COOKIE_JAR" -c "$COOKIE_JAR" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Help Support Local Food Bank",
    "summary": "Raising funds to support families",
    "story_html": "<p>Our local food bank serves...</p>",
    "goal_amount": 5000,
    "category_id": "789e0123-e89b-12d3-a456-426614174000",
    "location": "Austin, TX",
    "tags": ["community", "food"],
    "end_date": "2024-12-31"
  }'

Donations

POST

Process Donation

bash
# Create a donation
curl -X POST "$API_URL/donations" \
  -H "Content-Type: application/json" \
  -d '{
    "fundraiser_id": "123e4567-e89b-12d3-a456-426614174000",
    "amount": 5000,
    "currency": "USD",
    "donor_name": "Jane Smith",
    "donor_email": "jane@example.com",
    "payment_method_id": "pm_card_visa"
  }'

GET

Get My Donations

bash
# Get donation history (requires auth — uses cookie jar)
curl -X GET "$API_URL/donations/me" \
  -b "$COOKIE_JAR" -c "$COOKIE_JAR"

Advanced Operations

Batch Requests

bash
# Get stats for multiple fundraisers
curl -X POST "$API_URL/fundraisers/stats" \
  -H "Content-Type: application/json" \
  -d '{
    "fundraiser_ids": [
      "123e4567-e89b-12d3-a456-426614174000",
      "456e7890-e89b-12d3-a456-426614174000"
    ]
  }'

Built with VitePress