openapi: 3.0.0
info:
  title: SalvageDB API
  description: API for checking vehicle history and VIN decoding
  version: 1.0.0
servers:
  - url: /api
    description: Main server

paths:
  /search:
    post:
      summary: Search vehicle by VIN
      description: Search for vehicle information by VIN number
      parameters:
        - name: access_code
          in: query
          required: true
          schema:
            type: string
          description: API access code for authentication
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                vin:
                  type: string
                  description: Vehicle Identification Number
                  example: "1HGCM82633A123456"
      responses:
        '200':
          description: Successful search
          content:
            application/json:
              schema:
                type: object
                properties:
                  found:
                    type: boolean
                    description: Whether the vehicle was found
                  details:
                    type: object
                    description: Vehicle details
                    properties:
                      make:
                        type: string
                        description: Vehicle manufacturer
                      model:
                        type: string
                        description: Vehicle model
                      year:
                        type: integer
                        description: Manufacturing year
                      body:
                        type: string
                        description: Vehicle body type
                      engine:
                        type: string
                        description: Engine model
                      cylinders:
                        type: string
                        description: Number of engine cylinders
                      drive:
                        type: string
                        description: Drive type (FWD/RWD/AWD)
        '400':
          description: Invalid VIN or access code
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Error description

  /v2/search:
    post:
      summary: Search vehicle by VIN (v2)
      description: Search for vehicle information with full history records
      parameters:
        - name: access_code
          in: query
          required: true
          schema:
            type: string
          description: API access code for authentication
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                vin:
                  type: string
                  description: Vehicle Identification Number
                  example: "1HGCM82633A123456"
      responses:
        '200':
          description: Successful search
          content:
            application/json:
              schema:
                type: object
                properties:
                  found:
                    type: boolean
                    description: Whether the vehicle was found
                  details:
                    type: object
                    description: Vehicle details
                    properties:
                      make:
                        type: string
                        description: Vehicle manufacturer
                      model:
                        type: string
                        description: Vehicle model
                      year:
                        type: integer
                        description: Manufacturing year
                      body:
                        type: string
                        description: Vehicle body type
                      engine:
                        type: string
                        description: Engine model
                      cylinders:
                        type: string
                        description: Number of engine cylinders
                      drive:
                        type: string
                        description: Drive type (FWD/RWD/AWD)
                  records:
                    type: array
                    description: Vehicle history records
                    items:
                      type: object
                      properties:
                        odometer:
                          type: integer
                          description: Odometer reading in miles
                        odometer_status:
                          type: string
                          description: Odometer status (ACTUAL, EXEMPT, NOT ACTUAL)
                        title:
                          type: string
                          description: Title status (CLEAR, SALVAGE, REBUILT)
                        damage1:
                          type: string
                          description: Primary damage type
                        damage2:
                          type: string
                          description: Secondary damage type
                        add_to_db:
                          type: string
                          format: date
                          description: Date added to database
                        RD_Status:
                          type: string
                          description: Vehicle status
                        Sale_Location:
                          type: string
                          description: Sale location
                        Repear_Cost:
                          type: number
                          description: Repair cost in USD
                        Photo_Count:
                          type: integer
                          description: Number of available photos
        '400':
          description: Invalid VIN or access code
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Error description

  /v2/reqphoto:
    post:
      summary: Get vehicle photos
      description: Get photos of the vehicle by VIN
      parameters:
        - name: access_code
          in: query
          required: true
          schema:
            type: string
          description: API access code for authentication
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                vin:
                  type: string
                  description: Vehicle Identification Number
                  example: "1HGCM82633A123456"
      responses:
        '200':
          description: Successful photo retrieval
          content:
            application/json:
              schema:
                type: object
                properties:
                  found:
                    type: boolean
                    description: Whether photos were found
                  photos:
                    type: array
                    description: List of photo information
                    items:
                      type: object
                      properties:
                        url:
                          type: string
                          description: URL of the photo
                        type:
                          type: string
                          description: Type of photo (FRONT, REAR, SIDE, INTERIOR, etc.)
                        date:
                          type: string
                          format: date
                          description: Date when photo was taken
        '400':
          description: Invalid VIN or access code
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Error description

  /restfact:
    get:
      summary: Check account balance
      description: Get current account balance and pricing information
      parameters:
        - name: access_code
          in: query
          required: true
          schema:
            type: string
          description: API access code for authentication
      responses:
        '200':
          description: Successful balance check
          content:
            application/json:
              schema:
                type: object
                properties:
                  access_code:
                    type: string
                    description: API access code
                  restfact:
                    type: number
                    description: Current account balance
        '400':
          description: Invalid access code
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Error description

  /restfact_detail:
    get:
      summary: Get request history
      description: Get detailed history of API requests for the last 45 days
      parameters:
        - name: access_code
          in: query
          required: true
          schema:
            type: string
          description: API access code for authentication
      responses:
        '200':
          description: Successful history retrieval
          content:
            application/json:
              schema:
                type: object
                properties:
                  access_code:
                    type: string
                    description: API access code
                  report:
                    type: array
                    items:
                      type: object
                      properties:
                        VIN:
                          type: string
                          description: Vehicle Identification Number
                        IP:
                          type: string
                          description: IP address used for request
                        STATUS:
                          type: string
                          description: Request status (FOUND/NOT FOUND)
                        DATETIME:
                          type: string
                          format: date-time
                          description: Request date and time
                        COST:
                          type: number
                          description: Cost of the request
        '400':
          description: Invalid access code
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Error description