Skip to main content
GET
/
transactions
curl -X GET https://api.example.com/transactions \
  -H "Authorization: Bearer YOUR_TOKEN"
[
  {
    "id": 1,
    "userId": "550e8400-e29b-41d4-a716-446655440000",
    "total": 47.98,
    "coupon": "SUMMER20",
    "discount": 11.99,
    "transactionDate": "2024-03-15T14:30:00.000Z",
    "contents": [
      {
        "id": 1,
        "quantity": 2,
        "price": 19.99,
        "product": {
          "id": 1,
          "name": "Wireless Mouse",
          "description": "Ergonomic wireless mouse",
          "price": 19.99,
          "inventory": 48,
          "category": "Electronics"
        }
      },
      {
        "id": 2,
        "quantity": 1,
        "price": 19.99,
        "product": {
          "id": 5,
          "name": "USB Cable",
          "description": "USB-C to USB-A cable",
          "price": 9.99,
          "inventory": 199,
          "category": "Accessories"
        }
      }
    ]
  },
  {
    "id": 2,
    "userId": "550e8400-e29b-41d4-a716-446655440000",
    "total": 29.99,
    "coupon": null,
    "discount": 0,
    "transactionDate": "2024-03-15T16:45:00.000Z",
    "contents": [
      {
        "id": 3,
        "quantity": 1,
        "price": 29.99,
        "product": {
          "id": 3,
          "name": "Mechanical Keyboard",
          "description": "RGB mechanical keyboard",
          "price": 29.99,
          "inventory": 24,
          "category": "Electronics"
        }
      }
    ]
  }
]

Authentication

Requires JWT authentication. The authenticated user’s information is automatically extracted using the @CurrentUser decorator.

Query Parameters

transactionDate
string
Filter transactions by date (ISO 8601 format: YYYY-MM-DD)Returns all transactions that occurred on the specified date (from start to end of day)

Response

transactions
array
Array of transaction objects
curl -X GET https://api.example.com/transactions \
  -H "Authorization: Bearer YOUR_TOKEN"
[
  {
    "id": 1,
    "userId": "550e8400-e29b-41d4-a716-446655440000",
    "total": 47.98,
    "coupon": "SUMMER20",
    "discount": 11.99,
    "transactionDate": "2024-03-15T14:30:00.000Z",
    "contents": [
      {
        "id": 1,
        "quantity": 2,
        "price": 19.99,
        "product": {
          "id": 1,
          "name": "Wireless Mouse",
          "description": "Ergonomic wireless mouse",
          "price": 19.99,
          "inventory": 48,
          "category": "Electronics"
        }
      },
      {
        "id": 2,
        "quantity": 1,
        "price": 19.99,
        "product": {
          "id": 5,
          "name": "USB Cable",
          "description": "USB-C to USB-A cable",
          "price": 9.99,
          "inventory": 199,
          "category": "Accessories"
        }
      }
    ]
  },
  {
    "id": 2,
    "userId": "550e8400-e29b-41d4-a716-446655440000",
    "total": 29.99,
    "coupon": null,
    "discount": 0,
    "transactionDate": "2024-03-15T16:45:00.000Z",
    "contents": [
      {
        "id": 3,
        "quantity": 1,
        "price": 29.99,
        "product": {
          "id": 3,
          "name": "Mechanical Keyboard",
          "description": "RGB mechanical keyboard",
          "price": 29.99,
          "inventory": 24,
          "category": "Electronics"
        }
      }
    ]
  }
]

Role-Based Access Control

Admin Users

Administrators can see all transactions from all users:
// Admin sees all transactions regardless of userId
[
  { "id": 1, "userId": "user-123", ... },
  { "id": 2, "userId": "user-456", ... },
  { "id": 3, "userId": "user-789", ... }
]

Regular Users

Regular users can only see their own transactions:
// User with ID "user-123" only sees their transactions
[
  { "id": 1, "userId": "user-123", ... }
]

Date Filtering

When using the transactionDate query parameter:
  • Date must be in ISO 8601 format (YYYY-MM-DD)
  • Returns transactions from start of day (00:00:00) to end of day (23:59:59)
  • Invalid date formats return a 400 Bad Request error
  • Date filtering works in combination with role-based access control

Example Date Filter

GET /transactions?transactionDate=2024-03-15

# Returns all transactions between:
# 2024-03-15T00:00:00.000Z and 2024-03-15T23:59:59.999Z
The @CurrentUser decorator automatically extracts user information (id and role) from the JWT token to enforce role-based access control.
Transaction contents include eager-loaded product information, so you get complete product details without additional requests.

Build docs developers (and LLMs) love