Skip to main content

Setup your development environment

Learn how to set up your development environment and make your first API request to Harbor Parking.
Before getting started, make sure you have:
  • Node.js 18+ installed on your machine
  • A Supabase account and project
  • Basic familiarity with REST APIs and HTTP requests
  • An API testing tool like Postman, Insomnia, or curl
  1. Set up Supabase project
    • Create a new project in your Supabase dashboard
    • Note your project URL and anon key from Settings > API
  2. Configure Harbor Parking
    • Clone the Harbor Parking repository
    • Set up environment variables with your Supabase credentials
    • Run the database migrations to create required tables
  3. Create a test user
    • Sign up through the Harbor Parking web interface
    • Get admin approval for full API access
    • Extract your JWT token for API requests

Make your first request

curl -X GET "https://harbor-parking.vercel.app/api/profile" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json"

Expected Response

If your request is successful, you’ll receive a response like this:
{
  "profile": {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "email": "john.doe@example.com",
    "full_name": "John Doe",
    "apartment_number": "12A",
    "phone_number": "+1234567890",
    "is_approved": true,
    "is_admin": false,
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  },
  "user": {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "email": "john.doe@example.com",
    "email_confirmed_at": "2024-01-15T10:30:00Z",
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  }
}

Common Workflows

Now that you’ve made your first request, try these common workflows:

1. Register a Parking Spot

curl -X POST "https://harbor-parking.vercel.app/api/parking-spots" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "spot_number": "A-15",
    "building_section": "Level 2 Parking Garage"
  }'

2. Set Spot Availability

curl -X POST "https://harbor-parking.vercel.app/api/availabilities" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "spot_id": "123e4567-e89b-12d3-a456-426614174000",
    "start_time": "2024-12-25T10:00:00Z",
    "end_time": "2024-12-25T18:00:00Z"
  }'

3. Claim an Available Spot

curl -X POST "https://harbor-parking.vercel.app/api/claims" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "availability_id": "123e4567-e89b-12d3-a456-426614174000",
    "start_time": "2024-12-25T10:00:00Z",
    "end_time": "2024-12-25T18:00:00Z"
  }'

4. Get Dashboard Data

curl -X GET "https://harbor-parking.vercel.app/api/dashboard" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json"

Error Handling

The API uses standard HTTP status codes and returns detailed error messages:
{
  "error": "Validation failed",
  "details": {
    "spot_number": {
      "_errors": ["Spot number is required"]
    }
  }
}
Common status codes:
  • 200 - Success
  • 201 - Created successfully
  • 400 - Bad request (validation error)
  • 401 - Unauthorized (invalid or missing token)
  • 403 - Forbidden (insufficient permissions)
  • 404 - Not found
  • 409 - Conflict (duplicate resource)
  • 500 - Internal server error

Next Steps

Great! You’ve successfully made your first API requests. Here’s what to explore next:

Need Help?