Skip to main content

Get Tractor

Retrieve tractor information using different methods: by ID, available only, or with search filters.

Get by ID

Endpoint

GET /api/tractors/:id

Path Parameters

id
integer
required
Unique identifier of the tractor to retrieve. Must be a positive integer.

Response Fields

success
boolean
Indicates if the request was successful
data
object
Tractor object with complete details

Example Request

curl -X GET http://localhost:4000/api/tractors/1 \
  -H "Content-Type: application/json"

Example Responses

{
  "success": true,
  "data": {
    "tractor_id": 1,
    "name": "John Deere 6130M",
    "brand": "John Deere",
    "model": "6130M",
    "engine_power_hp": 130,
    "weight_kg": 5200,
    "traction_force_kn": 45.5,
    "traction_type": "4x4",
    "tire_type": "radial",
    "tire_width_mm": 540,
    "tire_diameter_mm": 1600,
    "tire_pressure_psi": 15,
    "status": "available"
  }
}

Error Cases

Returned when the provided ID is invalid (not a positive integer).Examples of invalid IDs:
  • Negative numbers: -1
  • Zero: 0
  • Non-numeric values: abc, null
  • Decimal numbers: 1.5
Returned when no tractor exists with the specified ID.The ID may be valid, but the tractor might have been deleted or never existed.
Returned when an unexpected server error occurs (e.g., database connection issues).

Use Cases

Tractor Details Page

Display complete specifications for a specific tractor in your application

Equipment Comparison

Fetch multiple tractors by ID to compare specifications side-by-side

Recommendation Context

Get detailed specs after receiving tractor recommendations

Verification

Verify tractor exists and is available before creating calculations

Get Available Tractors

Endpoint

GET /api/tractors/available
Returns only tractors with status “available”, ordered by power (descending).

Query Parameters

limit
integer
default:"10"
Number of results per page
offset
integer
default:"0"
Number of records to skip for pagination

Examples

curl -X GET "http://localhost:4000/api/tractors/available?limit=5&offset=0" \
  -H "Content-Type: application/json"

Response Example (200 OK)

{
  "success": true,
  "data": [
    {
      "tractor_id": 5,
      "tractor_name": "New Holland T7.315",
      "brand": "New Holland",
      "model": "T7.315",
      "engine_power_hp": 315,
      "max_pto_power_hp": 275,
      "traction_type": "4x4",
      "weight_kg": 9500,
      "fuel_tank_capacity_l": 605,
      "status": "available"
    }
  ],
  "pagination": {
    "total": 12,
    "limit": 5,
    "offset": 0
  }
}

Search Tractors

Endpoint

GET /api/tractors/search
Advanced search with multiple filter options. Returns tractors matching the specified criteria.

Query Parameters

brand
string
Filter by brand name (partial match, case-insensitive)
model
string
Filter by model name (partial match, case-insensitive)
minPower
number
Minimum engine power in HP
maxPower
number
Maximum engine power in HP
tractionType
string
Filter by traction type: 4x2, 4x4, or track
limit
integer
default:"10"
Number of results per page
offset
integer
default:"0"
Number of records to skip

Examples

curl -X GET "http://localhost:4000/api/tractors/search?minPower=100&maxPower=200" \
  -H "Content-Type: application/json"

Response Example (200 OK)

{
  "success": true,
  "data": [
    {
      "tractor_id": 3,
      "tractor_name": "John Deere 6175M",
      "brand": "John Deere",
      "model": "6175M",
      "engine_power_hp": 175,
      "traction_type": "4x4",
      "status": "available"
    }
  ],
  "pagination": {
    "total": 8,
    "limit": 10,
    "offset": 0
  },
  "filters": {
    "brand": null,
    "model": null,
    "minPower": 150,
    "maxPower": null
  }
}

List All Tractors

Get paginated list of all tractors

Create Tractor

Add new tractor (admin only)

Update Tractor

Modify tractor details (admin only)

Delete Tractor

Remove tractor from catalog (admin only)

Build docs developers (and LLMs) love