Starship Rewards API

List Orders API

Search and filter order history with pagination and advanced filtering options

List Orders API

Retrieve a paginated list of orders with comprehensive filtering options for order management and reporting.

Endpoint

GET /api/v1/orders

Authentication: Bearer token required

Request Headers

Authorization: Bearer <access_token>

Query Parameters

ParameterTypeDefaultRequiredDescription
pageinteger1NoPage number for pagination (min: 1)
limitinteger10NoNumber of results per page (min: 1, max: 100)
statusstring-NoFilter by order status
product_idinteger-NoFilter orders by product ID

Status Values

Orders can have the following statuses:

StatusDescriptionWallet DeductionVouchers Available
PENDINGOrder created, processing in progressYes (Deducted)No (Not yet)
PROCESSINGOrder currently being fulfilledYes (Deducted)No (Not yet)
DELIVEREDOrder completed successfullyYes (Deducted)Yes (Available)
PARTIALLY_DELIVEREDSome vouchers deliveredYes (Deducted)Yes (Some available)
FAILEDOrder processing failedNo (Refunded)No (None)
CANCELLEDOrder was cancelledNo (Refunded)No (None)

Status Flow:

Order Creation → PENDING → PROCESSING → DELIVERED

                 FAILED (if processing fails)

Note: The status filter is case-insensitive. You can use either uppercase (e.g., PENDING) or lowercase (e.g., pending) values.

Response

Success Response

Status Code: 200 OK

Response Headers:

X-Page: 1
X-Per-Page: 10
X-Total-Count: 150
X-Total-Pages: 15

Response Body:

[
  {
    "id": 12345,
    "product_name": "Amazon Gift Card",
    "currency": "USD",
    "reference_code": "ORD-ABC123",
    "transaction_id": 789,
    "product_id": 1001,
    "denomination": "25.00",
    "quantity": 1,
    "amount": "25.00",
    "status": "delivered",
    "email": "customer@example.com",
    "mobile": {
      "mobile_country_code": "+1",
      "mobile_number": "5551234567"
    },
    "placed_at": "2024-01-15T10:30:00Z"
  },
  {
    "id": 12346,
    "product_name": "Google Play Gift Card",
    "currency": "EUR",
    "reference_code": "ORD-DEF456",
    "transaction_id": 790,
    "product_id": 2001,
    "denomination": "50.00",
    "quantity": 2,
    "amount": "100.00",
    "status": "processing",
    "email": "user@example.com",
    "mobile": {
      "mobile_country_code": "+44",
      "mobile_number": "7700900000"
    },
    "placed_at": "2024-01-15T11:45:00Z"
  }
]

Response Fields

FieldTypeDescription
idintegerUnique order identifier
product_namestringDisplay name of the ordered product
currencystringISO 4217 currency code
reference_codestringUnique order reference for tracking
transaction_idintegerAssociated payment transaction ID
product_idintegerProduct catalog identifier
denominationstringUnit value with 2 decimal places
quantityintegerNumber of units ordered
amountstringTotal order amount with 2 decimal places
statusstringCurrent order status
emailstringCustomer email address (may be null)
mobileobjectCustomer mobile information
mobile.mobile_country_codestringInternational dialing code
mobile.mobile_numberstringPhone number without country code
placed_atstringOrder timestamp in RFC3339 format

Pagination Headers

HeaderDescription
X-PageCurrent page number
X-Per-PageItems per page
X-Total-CountTotal number of orders
X-Total-PagesTotal number of pages

Examples

# Get first page of orders with default pagination
curl -X GET "{{host}}/api/v1/orders" \
  -H "Authorization: Bearer your_access_token"

# Filter by delivered status with custom pagination
curl -X GET "{{host}}/api/v1/orders?status=delivered&limit=20&page=1" \
  -H "Authorization: Bearer your_access_token"

# Get orders for specific product
curl -X GET "{{host}}/api/v1/orders?product_id=1001" \
  -H "Authorization: Bearer your_access_token"

# Combine filters
curl -X GET "{{host}}/api/v1/orders?status=delivered&product_id=1001&limit=50" \
  -H "Authorization: Bearer your_access_token"
<?php
// Function to list orders with pagination
function listOrders($api, $filters = []) {
    $defaultFilters = [
        'page' => 1,
        'limit' => 10
    ];
    
    $params = array_merge($defaultFilters, $filters);
    $queryString = http_build_query($params);
    
    $response = $api->makeAuthenticatedRequest(
        "{{host}}/api/v1/orders?{$queryString}"
    );
    
    // Access pagination info from headers
    $headers = $api->getLastResponseHeaders();
    $pagination = [
        'current_page' => $headers['X-Page'] ?? 1,
        'per_page' => $headers['X-Per-Page'] ?? 10,
        'total_count' => $headers['X-Total-Count'] ?? 0,
        'total_pages' => $headers['X-Total-Pages'] ?? 1
    ];
    
    return [
        'orders' => $response,
        'pagination' => $pagination
    ];
}

// Example: Get recent delivered orders
$result = listOrders($api, [
    'status' => 'delivered',
    'limit' => 20,
    'page' => 1
]);

foreach ($result['orders'] as $order) {
    echo "Order #{$order['id']}: {$order['product_name']}\n";
    echo "  Amount: {$order['currency']} {$order['amount']}\n";
    echo "  Status: {$order['status']}\n";
    echo "  Date: " . date('Y-m-d H:i', strtotime($order['placed_at'])) . "\n\n";
}

// Display pagination info
echo "Page {$result['pagination']['current_page']} of {$result['pagination']['total_pages']}\n";
echo "Total orders: {$result['pagination']['total_count']}\n";

// Example: Build order history table
function displayOrderTable($api, $page = 1, $status = null) {
    $filters = ['page' => $page, 'limit' => 25];
    if ($status) {
        $filters['status'] = $status;
    }
    
    $result = listOrders($api, $filters);
    
    echo "<table class='orders-table'>\n";
    echo "  <thead>\n";
    echo "    <tr>\n";
    echo "      <th>Order ID</th>\n";
    echo "      <th>Reference</th>\n";
    echo "      <th>Product</th>\n";
    echo "      <th>Amount</th>\n";
    echo "      <th>Status</th>\n";
    echo "      <th>Customer</th>\n";
    echo "      <th>Date</th>\n";
    echo "      <th>Actions</th>\n";
    echo "    </tr>\n";
    echo "  </thead>\n";
    echo "  <tbody>\n";
    
    foreach ($result['orders'] as $order) {
        $statusClass = 'status-' . strtolower($order['status']);
        $date = date('M d, Y H:i', strtotime($order['placed_at']));
        
        echo "    <tr>\n";
        echo "      <td>#{$order['id']}</td>\n";
        echo "      <td>{$order['reference_code']}</td>\n";
        echo "      <td>{$order['product_name']}</td>\n";
        echo "      <td>{$order['currency']} {$order['amount']}</td>\n";
        echo "      <td><span class='{$statusClass}'>{$order['status']}</span></td>\n";
        echo "      <td>" . ($order['email'] ?? 'N/A') . "</td>\n";
        echo "      <td>{$date}</td>\n";
        echo "      <td>\n";
        echo "        <a href='/orders/{$order['id']}' class='btn-view'>View</a>\n";
        echo "      </td>\n";
        echo "    </tr>\n";
    }
    
    echo "  </tbody>\n";
    echo "</table>\n";
    
    // Pagination controls
    $pagination = $result['pagination'];
    if ($pagination['total_pages'] > 1) {
        echo "<div class='pagination'>\n";
        
        // Previous button
        if ($pagination['current_page'] > 1) {
            $prevPage = $pagination['current_page'] - 1;
            echo "  <a href='?page={$prevPage}' class='btn-prev'>Previous</a>\n";
        }
        
        // Page numbers
        echo "  <span>Page {$pagination['current_page']} of {$pagination['total_pages']}</span>\n";
        
        // Next button
        if ($pagination['current_page'] < $pagination['total_pages']) {
            $nextPage = $pagination['current_page'] + 1;
            echo "  <a href='?page={$nextPage}' class='btn-next'>Next</a>\n";
        }
        
        echo "</div>\n";
    }
}

// Display the table
displayOrderTable($api, $_GET['page'] ?? 1, $_GET['status'] ?? null);
?>

Error Responses

401 Unauthorized

{
  "error": "unauthorized",
  "message": "Invalid or expired access token"
}

404 Not Found

{
  "error": "not_found",
  "message": "No Matching Result Found!"
}

429 Too Many Requests

{
  "error": "rate_limit_exceeded",
  "message": "Too many requests. Please try again later."
}

Filtering Best Practices

  1. Use Specific Filters - Apply filters to reduce response size and improve performance
  2. Paginate Large Results - Use appropriate page sizes (10-50 items) for better performance
  3. Cache Results - Cache order lists that don't change frequently
  4. Monitor Headers - Check pagination headers to handle multi-page results
  5. Combine Filters - Use multiple filters together for precise results

Performance Tips

Optimal Page Sizes

  • Interactive UI: 10-25 items per page
  • Bulk Processing: 50-100 items per page
  • Reports: Up to 100 items per page

Caching Strategy

  • Cache delivered orders (rarely change)
  • Don't cache pending/processing orders
  • Implement cache invalidation on status changes

Parallel Requests

When fetching multiple pages, use parallel requests with rate limit awareness:

<?php
// Fetch multiple pages in parallel using multi-curl
function fetchMultiplePages($api, $pages, $limit = 50) {
    $requests = [];
    foreach ($pages as $page) {
        $requests[] = [
            'url' => "{{host}}/api/v1/orders?page={$page}&limit={$limit}",
            'page' => $page
        ];
    }
    
    // Execute parallel requests (implement multi-curl handler)
    return $api->parallelRequests($requests);
}

// Example usage
$pages = [1, 2, 3, 4, 5];
$results = fetchMultiplePages($api, $pages, 50);
?>

## Rate Limits

- **Standard Rate**: 100 requests per minute
- **Burst Limit**: 20 requests per 10 seconds
- **Daily Limit**: 50,000 requests per day

Rate limit information in response headers:
- `X-RateLimit-Limit`: Maximum requests allowed
- `X-RateLimit-Remaining`: Requests remaining
- `X-RateLimit-Reset`: Unix timestamp when limit resets

## Use Cases

### Order Dashboard
Display recent orders with real-time status updates:
- Filter by status for quick views
- Show processing orders prominently
- Highlight failed orders for attention

### Order History
Provide searchable order history for customers:
- Default to delivered orders
- Sort by date (most recent first)
- Include reference codes for support

### Reporting
Generate order reports with filters:
- Export delivered orders by date range
- Calculate totals by product
- Track order completion rates

## Next Steps

- **View Order Details** - [Get complete order information](/docs/orders/3-get-order-details)
- **Create New Orders** - [Submit orders](/docs/orders/1-create-order)
- **Track Status Changes** - [Monitor order fulfillment](/docs/orders/3-get-order-details)
- **Product Catalog** - [Browse available products](/docs/products)