Dealer Endpoints

Dealer Endpoints

This guide covers the dealer endpoints in the AutoElite API, which allow you to retrieve, create, update, and manage dealer information.

Base URL

All dealer endpoints are accessible at:

https://api.autoelite.io/api/dealers

Authentication

All requests to the dealer endpoints require authentication using an API key. Include your API key in the X-API-Key header:

X-API-Key: your-api-key-here

Endpoints

Get All Dealers

GET /api/dealers

Retrieve a list of all dealers.

Query Parameters

Parameter Type Description
state string Filter dealers by state
city string Filter dealers by city
active boolean Filter by active status (true, false)
limit integer Maximum number of results to return
offset integer Number of results to skip (for pagination)

Example Request

curl -X GET "https://api.autoelite.io/api/dealers" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json"

Example Response

[
  {
    "id": 1,
    "name": "AutoPret 123",
    "address": "123 Main St",
    "city": "Metropolis",
    "state": "NY",
    "zip": "10001",
    "phone": "555-123-4567",
    "email": "[email protected]",
    "website": "https://autopret123.com",
    "active": 1,
    "created_at": "2025-01-01T00:00:00Z",
    "updated_at": "2025-01-01T00:00:00Z"
  },
  {
    "id": 2,
    "name": "AutoElite Main",
    "address": "456 Broadway",
    "city": "Metropolis",
    "state": "NY",
    "zip": "10002",
    "phone": "555-987-6543",
    "email": "[email protected]",
    "website": "https://autoelite.com",
    "active": 1,
    "created_at": "2025-01-02T00:00:00Z",
    "updated_at": "2025-01-02T00:00:00Z"
  }
]

Get a Specific Dealer

GET /api/dealers/:id

Retrieve a specific dealer by its ID.

Example Request

curl -X GET "https://api.autoelite.io/api/dealers/1" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json"

Example Response

{
  "id": 1,
  "name": "AutoPret 123",
  "address": "123 Main St",
  "city": "Metropolis",
  "state": "NY",
  "zip": "10001",
  "phone": "555-123-4567",
  "email": "[email protected]",
  "website": "https://autopret123.com",
  "active": 1,
  "logo_url": "https://storage.autoelite.io/dealers/1/logo.png",
  "description": "Premier auto dealer in Metropolis with a wide selection of new and used vehicles.",
  "hours": {
    "monday": "9:00 AM - 8:00 PM",
    "tuesday": "9:00 AM - 8:00 PM",
    "wednesday": "9:00 AM - 8:00 PM",
    "thursday": "9:00 AM - 8:00 PM",
    "friday": "9:00 AM - 9:00 PM",
    "saturday": "10:00 AM - 6:00 PM",
    "sunday": "Closed"
  },
  "social_media": {
    "facebook": "https://facebook.com/autopret123",
    "twitter": "https://twitter.com/autopret123",
    "instagram": "https://instagram.com/autopret123"
  },
  "created_at": "2025-01-01T00:00:00Z",
  "updated_at": "2025-01-01T00:00:00Z"
}

Create a Dealer

POST /api/dealers

Create a new dealer.

Request Body

Field Type Required Description
name string Yes Dealer name
address string Yes Street address
city string Yes City
state string Yes State
zip string Yes ZIP/Postal code
phone string Yes Phone number
email string Yes Email address
website string No Website URL
logo_url string No URL to dealer logo
description string No Dealer description
hours object No Business hours
social_media object No Social media links
active boolean No Whether the dealer is active (default: true)

Example Request

curl -X POST "https://api.autoelite.io/api/dealers" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "New Dealer",
    "address": "789 Oak St",
    "city": "Metropolis",
    "state": "NY",
    "zip": "10003",
    "phone": "555-111-2222",
    "email": "[email protected]",
    "website": "https://newdealer.com",
    "description": "A new dealer in town"
  }'

Example Response

{
  "id": 3,
  "name": "New Dealer",
  "address": "789 Oak St",
  "city": "Metropolis",
  "state": "NY",
  "zip": "10003",
  "phone": "555-111-2222",
  "email": "[email protected]",
  "website": "https://newdealer.com",
  "description": "A new dealer in town",
  "active": 1,
  "created_at": "2025-12-03T21:50:00.000Z",
  "updated_at": "2025-12-03T21:50:00.000Z"
}

Update a Dealer

PUT /api/dealers/:id

Update an existing dealer.

Example Request

curl -X PUT "https://api.autoelite.io/api/dealers/3" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "555-333-4444",
    "description": "Updated dealer description",
    "hours": {
      "monday": "8:00 AM - 6:00 PM",
      "tuesday": "8:00 AM - 6:00 PM",
      "wednesday": "8:00 AM - 6:00 PM",
      "thursday": "8:00 AM - 6:00 PM",
      "friday": "8:00 AM - 6:00 PM",
      "saturday": "9:00 AM - 5:00 PM",
      "sunday": "Closed"
    }
  }'

Example Response

{
  "id": 3,
  "name": "New Dealer",
  "address": "789 Oak St",
  "city": "Metropolis",
  "state": "NY",
  "zip": "10003",
  "phone": "555-333-4444",
  "email": "[email protected]",
  "website": "https://newdealer.com",
  "description": "Updated dealer description",
  "hours": {
    "monday": "8:00 AM - 6:00 PM",
    "tuesday": "8:00 AM - 6:00 PM",
    "wednesday": "8:00 AM - 6:00 PM",
    "thursday": "8:00 AM - 6:00 PM",
    "friday": "8:00 AM - 6:00 PM",
    "saturday": "9:00 AM - 5:00 PM",
    "sunday": "Closed"
  },
  "active": 1,
  "created_at": "2025-12-03T21:50:00.000Z",
  "updated_at": "2025-12-03T21:55:00.000Z"
}

Delete a Dealer

DELETE /api/dealers/:id

Delete a dealer. This is a soft delete that marks the dealer as inactive.

Example Request

curl -X DELETE "https://api.autoelite.io/api/dealers/3" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json"

Example Response

{
  "success": true,
  "message": "Dealer deactivated successfully"
}

Dealer Inventory

Get Dealer Inventory

GET /api/dealers/:id/vehicles

Retrieve all vehicles for a specific dealer.

Example Request

curl -X GET "https://api.autoelite.io/api/dealers/1/vehicles" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json"

Example Response

{
  "meta": {
    "total": 2,
    "dealer_id": 1,
    "timestamp": "2025-12-03T22:00:00.000Z"
  },
  "vehicles": [
    {
      "id": 32,
      "dealer_id": 1,
      "make": "Tesla",
      "model": "Model Y",
      "year": 2025,
      "price": 45000,
      "status": "available",
      "created_at": "2025-11-28 05:30:15",
      "updated_at": "2025-11-28 05:30:15"
    },
    {
      "id": 31,
      "dealer_id": 1,
      "make": "Test Make",
      "model": "Test Model",
      "year": 2023,
      "price": 10000,
      "status": "available",
      "created_at": "2025-11-27 23:29:30",
      "updated_at": "2025-11-27 23:29:30"
    }
  ]
}

Get Dealer Statistics

GET /api/dealers/:id/stats

Retrieve statistics for a specific dealer.

Example Request

curl -X GET "https://api.autoelite.io/api/dealers/1/stats" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json"

Example Response

{
  "dealer_id": 1,
  "total_vehicles": 25,
  "available_vehicles": 18,
  "sold_vehicles": 5,
  "pending_vehicles": 2,
  "average_price": 32500,
  "inventory_value": 812500,
  "newest_vehicle": {
    "id": 32,
    "make": "Tesla",
    "model": "Model Y",
    "year": 2025,
    "created_at": "2025-11-28 05:30:15"
  },
  "oldest_vehicle": {
    "id": 10,
    "make": "Honda",
    "model": "Civic",
    "year": 2020,
    "created_at": "2025-10-15 12:30:00"
  },
  "timestamp": "2025-12-03T22:05:00.000Z"
}

Error Handling

The API uses standard HTTP status codes to indicate success or failure:

  • 200 OK: Request succeeded
  • 201 Created: Resource created successfully
  • 400 Bad Request: Invalid request parameters
  • 401 Unauthorized: Missing or invalid API key
  • 403 Forbidden: Insufficient permissions
  • 404 Not Found: Dealer not found
  • 500 Internal Server Error: Server error

Error responses include a JSON body with an error message:

{
  "error": "Dealer not found",
  "timestamp": "2025-12-03T22:10:00.000Z"
}

Code Examples

JavaScript

// Get all dealers
async function getDealers() {
  const response = await fetch('https://api.autoelite.io/api/dealers', {
    headers: {
      'X-API-Key': 'your-api-key-here',
      'Content-Type': 'application/json'
    }
  });
  
  return await response.json();
}

// Get a specific dealer
async function getDealer(id) {
  const response = await fetch(`https://api.autoelite.io/api/dealers/${id}`, {
    headers: {
      'X-API-Key': 'your-api-key-here',
      'Content-Type': 'application/json'
    }
  });
  
  return await response.json();
}

// Create a new dealer
async function createDealer(dealerData) {
  const response = await fetch('https://api.autoelite.io/api/dealers', {
    method: 'POST',
    headers: {
      'X-API-Key': 'your-api-key-here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(dealerData)
  });
  
  return await response.json();
}

// Update a dealer
async function updateDealer(id, dealerData) {
  const response = await fetch(`https://api.autoelite.io/api/dealers/${id}`, {
    method: 'PUT',
    headers: {
      'X-API-Key': 'your-api-key-here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(dealerData)
  });
  
  return await response.json();
}

// Get dealer inventory
async function getDealerInventory(id) {
  const response = await fetch(`https://api.autoelite.io/api/dealers/${id}/vehicles`, {
    headers: {
      'X-API-Key': 'your-api-key-here',
      'Content-Type': 'application/json'
    }
  });
  
  const data = await response.json();
  return data.vehicles;
}

Python

import requests

API_KEY = "your-api-key-here"
BASE_URL = "https://api.autoelite.io"

# Get all dealers
def get_dealers():
    url = f"{BASE_URL}/api/dealers"
    
    response = requests.get(
        url,
        headers={
            "X-API-Key": API_KEY,
            "Content-Type": "application/json"
        }
    )
    
    return response.json()

# Get a specific dealer
def get_dealer(dealer_id):
    url = f"{BASE_URL}/api/dealers/{dealer_id}"
    
    response = requests.get(
        url,
        headers={
            "X-API-Key": API_KEY,
            "Content-Type": "application/json"
        }
    )
    
    return response.json()

# Create a new dealer
def create_dealer(dealer_data):
    url = f"{BASE_URL}/api/dealers"
    
    response = requests.post(
        url,
        json=dealer_data,
        headers={
            "X-API-Key": API_KEY,
            "Content-Type": "application/json"
        }
    )
    
    return response.json()

# Update a dealer
def update_dealer(dealer_id, dealer_data):
    url = f"{BASE_URL}/api/dealers/{dealer_id}"
    
    response = requests.put(
        url,
        json=dealer_data,
        headers={
            "X-API-Key": API_KEY,
            "Content-Type": "application/json"
        }
    )
    
    return response.json()

# Get dealer inventory
def get_dealer_inventory(dealer_id):
    url = f"{BASE_URL}/api/dealers/{dealer_id}/vehicles"
    
    response = requests.get(
        url,
        headers={
            "X-API-Key": API_KEY,
            "Content-Type": "application/json"
        }
    )
    
    data = response.json()
    return data.get("vehicles", [])

Next Steps