> ## Documentation Index
> Fetch the complete documentation index at: https://lapscher.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get up and running with the Harbor Parking API in under 5 minutes

## Setup your development environment

Learn how to set up your development environment and make your first API request to Harbor Parking.

<AccordionGroup>
  <Accordion title="Prerequisites">
    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
  </Accordion>

  <Accordion title="Get your API credentials">
    1. **Set up Supabase project**
       * Create a new project in your [Supabase dashboard](https://supabase.com/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
  </Accordion>
</AccordionGroup>

## Make your first request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://harbor-parking.vercel.app/api/profile" \
    -H "Authorization: Bearer YOUR_JWT_TOKEN" \
    -H "Content-Type: application/json"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://harbor-parking.vercel.app/api/profile', {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer YOUR_JWT_TOKEN',
      'Content-Type': 'application/json'
    }
  });

  const profileData = await response.json();
  console.log(profileData);
  ```

  ```python Python theme={null}
  import requests

  url = "https://harbor-parking.vercel.app/api/profile"
  headers = {
      "Authorization": "Bearer YOUR_JWT_TOKEN",
      "Content-Type": "application/json"
  }

  response = requests.get(url, headers=headers)
  profile_data = response.json()
  print(profile_data)
  ```

  ```php PHP theme={null}
  <?php
  $url = 'https://harbor-parking.vercel.app/api/profile';
  $headers = [
      'Authorization: Bearer YOUR_JWT_TOKEN',
      'Content-Type: application/json'
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

  $response = curl_exec($ch);
  $profile_data = json_decode($response, true);
  curl_close($ch);

  print_r($profile_data);
  ?>
  ```
</CodeGroup>

## Expected Response

If your request is successful, you'll receive a response like this:

```json theme={null}
{
  "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

<CodeGroup>
  ```bash cURL theme={null}
  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"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://harbor-parking.vercel.app/api/parking-spots', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_JWT_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      spot_number: 'A-15',
      building_section: 'Level 2 Parking Garage'
    })
  });

  const spotData = await response.json();
  console.log(spotData);
  ```
</CodeGroup>

### 2. Set Spot Availability

<CodeGroup>
  ```bash cURL theme={null}
  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"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://harbor-parking.vercel.app/api/availabilities', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_JWT_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      spot_id: '123e4567-e89b-12d3-a456-426614174000',
      start_time: '2024-12-25T10:00:00Z',
      end_time: '2024-12-25T18:00:00Z'
    })
  });

  const availabilityData = await response.json();
  console.log(availabilityData);
  ```
</CodeGroup>

### 3. Claim an Available Spot

<CodeGroup>
  ```bash cURL theme={null}
  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"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://harbor-parking.vercel.app/api/claims', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_JWT_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      availability_id: '123e4567-e89b-12d3-a456-426614174000',
      start_time: '2024-12-25T10:00:00Z',
      end_time: '2024-12-25T18:00:00Z'
    })
  });

  const claimData = await response.json();
  console.log(claimData);
  ```
</CodeGroup>

### 4. Get Dashboard Data

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://harbor-parking.vercel.app/api/dashboard" \
    -H "Authorization: Bearer YOUR_JWT_TOKEN" \
    -H "Content-Type: application/json"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://harbor-parking.vercel.app/api/dashboard', {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer YOUR_JWT_TOKEN',
      'Content-Type': 'application/json'
    }
  });

  const dashboardData = await response.json();
  console.log(dashboardData);
  ```
</CodeGroup>

## Error Handling

The API uses standard HTTP status codes and returns detailed error messages:

```json theme={null}
{
  "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:

<CardGroup cols={2}>
  <Card title="Authentication Deep Dive" icon="key" href="/api-reference/authentication">
    Learn about JWT tokens, refresh tokens, and security best practices
  </Card>

  <Card title="API Reference" icon="book" href="/api-reference/introduction">
    Complete documentation for all endpoints
  </Card>
</CardGroup>

## Need Help?

* **[GitHub Discussions](https://github.com/ylapscher/harbor-parking/discussions)** - Community support
* **[API Reference](/api-reference/introduction)** - Complete endpoint documentation
