# API Reference

Welcome to the **Closer Platform API** documentation. This API allows you to build applications that interact with the Closer ecosystem—manage bookings, events, users, payments, and more.

## Getting Started

### Base URL

```
https://api.traditionaldreamfactory.com
```

### Authentication

All API requests require authentication using a Bearer token in the HTTP header:

```bash
curl -X GET "https://api.traditionaldreamfactory.com/api/user" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"
```

> 🔑 **Getting an API Key:** Contact the platform administrator or generate one from your account settings.

### Response Format

All responses are returned in JSON format:

```json
{
  "results": [...],
  "count": 10,
  "page": 1
}
```

### Error Handling

| Status Code | Meaning                                   |
| ----------- | ----------------------------------------- |
| `200`       | Success                                   |
| `201`       | Created                                   |
| `400`       | Bad Request - Invalid parameters          |
| `401`       | Unauthorized - Invalid or missing API key |
| `403`       | Forbidden - Insufficient permissions      |
| `404`       | Not Found - Resource doesn't exist        |
| `500`       | Server Error                              |

***

## API Reference

### Core APIs

| API                                                              | Description                            | Endpoints |
| ---------------------------------------------------------------- | -------------------------------------- | --------- |
| [Auth](https://closer.gitbook.io/documentation/api/auth)         | Authentication and session management  | 20        |
| [Users](https://closer.gitbook.io/documentation/api/users)       | User profile management                | 1         |
| [Bookings](https://closer.gitbook.io/documentation/api/bookings) | Booking and reservation operations     | 21        |
| [Crud](https://closer.gitbook.io/documentation/api/crud)         | Generic CRUD operations for all models | 547       |

### Payments & Billing

| API                                                                                      | Description                 | Endpoints |
| ---------------------------------------------------------------------------------------- | --------------------------- | --------- |
| [Payments](https://closer.gitbook.io/documentation/api/payments)                         | Payment processing          | 1         |
| [Payments-arx](https://github.com/closerdao/documentation/blob/main/api/payments-arx.md) | ARX payment integration     | 4         |
| [Stripe](https://closer.gitbook.io/documentation/api/stripe)                             | Stripe payment integration  | 3         |
| [Subscriptions](https://closer.gitbook.io/documentation/api/subscriptions)               | Subscription management     | 5         |
| [Charges](https://github.com/closerdao/documentation/blob/main/api/charges.md)           | Payment charges and billing | 2         |
| [Carrots](https://github.com/closerdao/documentation/blob/main/api/carrots.md)           | Token rewards system        | 7         |

### Content & Resources

| API                                                                              | Description                     | Endpoints |
| -------------------------------------------------------------------------------- | ------------------------------- | --------- |
| [Articles](https://github.com/closerdao/documentation/blob/main/api/articles.md) | Content articles and blog posts | 1         |
| [Event](https://closer.gitbook.io/documentation/api/event)                       | Event management                | 1         |
| [Products](https://github.com/closerdao/documentation/blob/main/api/products.md) | Product catalog                 | 2         |
| [Photo](https://github.com/closerdao/documentation/blob/main/api/photo.md)       | Photo uploads and management    | 2         |

### System & Utilities

| API                                                                                  | Description           | Endpoints |
| ------------------------------------------------------------------------------------ | --------------------- | --------- |
| [Health](https://github.com/closerdao/documentation/blob/main/api/health.md)         | API health checks     | 1         |
| [Meta](https://github.com/closerdao/documentation/blob/main/api/meta.md)             | API metadata          | 4         |
| [Swagger](https://github.com/closerdao/documentation/blob/main/api/swagger.md)       | OpenAPI specification | 1         |
| [Moderator](https://github.com/closerdao/documentation/blob/main/api/moderator.md)   | Content moderation    | 2         |
| [Onboarding](https://github.com/closerdao/documentation/blob/main/api/onboarding.md) | User onboarding flows | 1         |

### Other APIs

| API                                                                                                    | Description            | Endpoints |
| ------------------------------------------------------------------------------------------------------ | ---------------------- | --------- |
| [Accounting](https://github.com/closerdao/documentation/blob/main/api/accounting.md)                   | Accounting operations  | 1         |
| [Actions](https://github.com/closerdao/documentation/blob/main/api/actions.md)                         | Custom actions         | 1         |
| [Emails](https://github.com/closerdao/documentation/blob/main/api/emails.md)                           | Email notifications    | 1         |
| [Finance-application](https://github.com/closerdao/documentation/blob/main/api/finance-application.md) | Finance applications   | 4         |
| [Metrics](https://github.com/closerdao/documentation/blob/main/api/metrics.md)                         | Analytics and metrics  | 1         |
| [Paygrid](https://github.com/closerdao/documentation/blob/main/api/paygrid.md)                         | Paygrid integration    | 1         |
| [Proposals](https://closer.gitbook.io/documentation/api/proposals)                                     | Governance proposals   | 6         |
| [Reporting](https://github.com/closerdao/documentation/blob/main/api/reporting.md)                     | Reports generation     | 1         |
| [Sale](https://github.com/closerdao/documentation/blob/main/api/sale.md)                               | Sales operations       | 1         |
| [Toconline](https://github.com/closerdao/documentation/blob/main/api/toconline.md)                     | TOC Online integration | 1         |
| [Token](https://closer.gitbook.io/documentation/api/token)                                             | Token operations       | 4         |
| [User-reports](https://github.com/closerdao/documentation/blob/main/api/user-reports.md)               | User reporting         | 1         |
| [Webinar](https://github.com/closerdao/documentation/blob/main/api/webinar.md)                         | Webinar management     | 1         |

***

## Data Models

See [**schemas.md**](https://closer.gitbook.io/documentation/api/schemas) for complete documentation of all data models including:

* **Booking** - Accommodation and event reservations
* **Event** - Community events and gatherings
* **User** - User profiles and authentication
* **Listing** - Accommodation listings
* **Product** - Products for sale
* **Ticket** - Event tickets
* And many more...

***

## Common Patterns

### Pagination

Most list endpoints support pagination:

```bash
GET /api/booking?limit=20&page=1
```

| Parameter | Type    | Default | Description                |
| --------- | ------- | ------- | -------------------------- |
| `limit`   | integer | 20      | Number of results per page |
| `page`    | integer | 1       | Page number                |

### Filtering

Filter results using query parameters:

```bash
GET /api/booking?where={"status":"confirmed"}
```

### Sorting

Sort results by any field:

```bash
GET /api/booking?sort_by=-created
```

Use `-` prefix for descending order.

### Field Selection

Select specific fields to reduce response size:

```bash
GET /api/booking?fields=_id,status,checkin,checkout
```

***

## Rate Limiting

API requests are rate-limited to ensure fair usage. If you exceed the limit, you'll receive a `429 Too Many Requests` response.

***

## Need Help?

* 📖 **Interactive API:** [Swagger UI](https://api.traditionaldreamfactory.com/swagger)
* 💬 **Support:** Contact the platform team
* 🐛 **Found a bug?** Report issues through the appropriate channels

***

*This documentation is auto-generated from the OpenAPI specification.*
