Trip FetchAll API
Retrieve paginated trips with financial summaries
Endpoint
GET/api/trip/fetchAll
Retrieves a paginated list of trips with summarized financial data from their associated sectors.
Authentication
Provide your API token in the request headers:
X-Api-Token: your_token_prefix.your_token_secret
Parameters
Pagination
| Parameter | Type | Required | Description |
|---|---|---|---|
| page | integer | Optional | Page number (default: 1, min: 1) |
| per_page | integer | Optional | Items per page (default: 50, min: 1, max: 100) |
Filtering
| Parameter | Type | Required | Description |
|---|---|---|---|
| active | boolean | Optional | Filter by trip active status |
| corporate | boolean | Optional | Filter by trip type (true=corporate, false=leisure) |
| branch_id | integer | Optional | Filter by specific branch ID |
| consultant_id | integer | Optional | Filter by specific consultant ID |
| client_id | integer | Optional | Filter by specific client ID |
| trip_status | string | Optional | Filter by trip status |
| trip_type | string | Optional | Filter by trip type |
| date_from | date | Optional | Filter trips from date (YYYY-MM-DD) |
| date_to | date | Optional | Filter trips to date (YYYY-MM-DD) |
| search | string | Optional | Search across multiple trip fields |
Usage Examples
Get all trips
GET /api/trip/fetchAll
Filter by consultant and date range
GET /api/trip/fetchAll?consultant_id=123&date_from=2024-01-01&date_to=2024-12-31
Search active trips
GET /api/trip/fetchAll?search=Melbourne&active=true
Get corporate trips by branch
GET /api/trip/fetchAll?corporate=true&branch_id=5&per_page=25
Response Format
{
"success": true,
"data": [
{
"id": 12345,
"client_id": 789,
"consultant_id": 456,
"branch_id": 5,
"passenger_id": 234,
"date_opened": "2024-01-15 09:30:00",
"date_quoted": "2024-01-15 10:15:00",
"date_activated": "2024-01-16 14:20:00",
"trip_type": "Business",
"purchase_order": "PO-2024-001",
"booked_by": "John Smith",
"destination": "MEL-SYD",
"charge_to": "ABC Corporation",
"source": "Online",
"is_active": true,
"is_archived": false,
"is_corporate": true,
"trip_status": "Active",
"date_closed": null,
"date_cancelled": null,
"date_finalized": null,
"sector_summary": {
"sector_count": 4,
"active_sectors": 3,
"total_amount": 125000,
"total_net": 110000,
"total_fees": 5000,
"total_gst": 10000,
"total_commission": 8500,
"earliest_travel_date": "2024-02-01",
"latest_travel_date": "2024-02-15",
"total_amount_formatted": "1250.00",
"total_net_formatted": "1100.00",
"total_fees_formatted": "50.00",
"total_gst_formatted": "100.00",
"total_commission_formatted": "85.00"
}
}
],
"pagination": {
"total": 1250,
"page": 1,
"per_page": 50,
"total_pages": 25,
"has_next": true,
"has_previous": false
},
"timestamp": "2024-01-15T09:30:00+00:00"
}
Response Fields
Main Trip Data
| Field | Type | Description |
|---|---|---|
| id | integer | Unique trip identifier |
| client_id | integer | Associated client ID |
| consultant_id | integer | Assigned consultant ID |
| branch_id | integer | Associated branch ID |
| trip_type | string | Type of trip (Business, Leisure, etc.) |
| destination | string | Trip destination description |
| trip_status | string | Current status of the trip |
| is_active | boolean | Whether the trip is active |
| is_corporate | boolean | Whether this is a corporate trip |
Sector Summary
| Field | Type | Description |
|---|---|---|
| sector_count | integer | Total number of sectors in the trip |
| active_sectors | integer | Number of active sectors |
| total_amount | integer | Total amount in cents |
| total_net | integer | Total net amount in cents |
| total_fees | integer | Total fees in cents |
| total_gst | integer | Total GST in cents |
| total_commission | integer | Total commission in cents |
| *_formatted | string | Human-readable formatted amounts |
Search Functionality
The search parameter searches across the following fields:
- Purchase Order: Exact and partial matches
- Booked By: Name of the person who booked
- Destination: Trip destination
- Charge To: Billing entity
- Source: Booking source
- Trip ID: Numeric trip identifier
Search examples
# Search by destination
GET /api/trip/fetchAll?search=Melbourne
# Search by purchase order
GET /api/trip/fetchAll?search=PO-2024
# Search by person's name
GET /api/trip/fetchAll?search=Smith
Code Examples
JavaScript (Fetch)
const response = await fetch('/api/trip/fetchAll?active=true&per_page=25', {
headers: {
'X-Api-Key': 'your_api_key_here'
}
});
const data = await response.json();
if (data.success) {
data.data.forEach(trip => {
console.log(`Trip ${trip.id}: ${trip.destination}`);
console.log(`Total: $${trip.sector_summary.total_amount_formatted}`);
});
}
PHP (cURL)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '/api/trip/fetchAll?active=true&per_page=25');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-Api-Key: your_api_key_here'
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
if ($data['success']) {
foreach ($data['data'] as $trip) {
echo "Trip {$trip['id']}: {$trip['destination']}\n";
echo "Total: \${$trip['sector_summary']['total_amount_formatted']}\n";
}
}