Contents

carsxe/carsxe-swift-package

A minimal, easy-to-use Swift package wrapping the CarsXE REST API. Quickly decode VINs, fetch vehicle data and images, estimate market value, and run plate/VIN OCR with simple method calls.

Usage

The Swift package exposes methods that throw on error and return dynamic JSON as [String: Any]. Use do/catch to handle errors.

Example (synchronous/throwing style):

let API_KEY = "YOUR_API_KEY"
let carsxe = CarsXE(apiKey: API_KEY)
let vin = "WBAFR7C57CC811956"

do {
    let vehicle = try carsxe.specs(["vin": vin])
    if let input = vehicle["input"] as? [String: Any],
       let vinValue = input["vin"] as? String {
        print("VIN: \(vinValue)")
    } else {
        print("Vehicle response: \(vehicle)")
    }
} catch {
    print("Error: \(error)")
}

Example (POST endpoints that accept an image URL):

do {
    let plateResult = try carsxe.plateImageRecognition(imageUrl: "https://api.carsxe.com/img/apis/plate_recognition.JPG")
    print(plateResult)
} catch {
    print("Plate image error: \(error)")
}

Note: Depending on the runtime and package version you use, there may also be async or completion-based helpers. Check the package source for async variants or completion wrappers.


📚 Endpoints

The CarsXE Swift package provides the following public methods (signatures may be throws and return [String: Any]):

specs — Decode VIN & get full vehicle specifications

Required:

  • vin

Optional:

  • deepdata
  • disableIntVINDecoding

Example:

let vehicle = try carsxe.specs(["vin": "WBAFR7C57CC811956"])

internationalVinDecoder — Decode VIN with worldwide support

Required:

  • vin

Example:

let intvin = try carsxe.internationalVinDecoder(["vin": "WF0MXXGBWM8R43240"])

platedecoder — Decode license plate info (plate, country)

Required:

  • plate
  • country (for many countries; may default to "US" when missing)

Optional:

  • state (required for some countries, e.g. US, AU, CA)
  • district (required for Pakistan)

Example:

let decodedPlate = try carsxe.platedecoder(["plate": "7XER187", "state": "CA", "country": "US"])

marketValue — Estimate vehicle market value based on VIN

Required:

  • vin

Optional:

  • state
  • mileage
  • condition

Example:

let marketvalue = try carsxe.marketValue([
    "vin": "WBAFR7C57CC811956",
    "state": "CA",
    "mileage": "50000",
    "condition": "average"
])

history — Retrieve vehicle history

Required:

  • vin

Example:

let history = try carsxe.history(["vin": "WBAFR7C57CC811956"])

images — Fetch images by make, model, year, trim

Required:

  • make
  • model

Optional:

  • year, trim, color, transparent, angle, photoType, size, license

Example:

let images = try carsxe.images(["make": "BMW", "model": "X5", "year": "2019"])

recalls — Get safety recall data for a VIN

Required:

  • vin

Example:

let recalls = try carsxe.recalls(["vin": "1C4JJXR64PW696340"])

plateImageRecognition — Read & decode plates from images (POST)

Required:

  • imageUrl (string)

Example:

let plateImg = try carsxe.plateImageRecognition(imageUrl: "https://api.carsxe.com/img/apis/plate_recognition.JPG")

vinOcr — Extract VINs from images using OCR (POST)

Required:

  • imageUrl (string)

Example:

let vinocr = try carsxe.vinOcr(imageUrl: "https://api.carsxe.com/img/apis/plate_recognition.JPG")

yearMakeModel — Query vehicle by year, make, model and trim (optional)

Required:

  • year, make, model

Optional:

  • trim

Example:

let yymm = try carsxe.yearMakeModel(["year": "2012", "make": "BMW", "model": "5 Series"])

obdcodesdecoder — Decode OBD error/diagnostic codes

Required:

  • code

Example:

let obdcode = try carsxe.obdcodesdecoder(["code": "P0115"])

lienAndTheft — Get lien and theft information

Required:

  • vin

Example:

let lienTheft = try carsxe.lienAndTheft(["vin": "2C3CDXFG1FH762860"])

Notes & Best Practices

  • Parameter requirements: Each endpoint requires specific parameters—see the Required/Optional fields above.
  • Return values: All responses from this package are Swift dictionaries ([String: Any]) for easy and flexible access.
  • Error handling: Use do/catch blocks to gracefully handle errors thrown by the API wrapper.
  • Threading & concurrency: Some package builds expose synchronous (blocking) wrappers that use URLSession + semaphores — avoid calling those from the main/UI thread. If the package or your code uses async/await, prefer keeping network calls and immediate processing in the same async context or convert responses to typed Codable/Sendable models before crossing concurrency boundaries.
  • Serialization: If you need to pass results between threads/tasks, consider serializing to Data (JSON) or decoding into Codable types before dispatching.
  • More info: For advanced usage and full details, visit the official API documentation.

Overall

CarsXE API provides a wide range of powerful, easy-to-use tools for accessing and integrating vehicle data into your applications and services. Whether you're a developer or a business owner, you can quickly get the information you need to take your projects to the next level—without hassle or inconvenience.

Package Metadata

Repository: carsxe/carsxe-swift-package

Homepage: https://swiftpackageindex.com/carsxe/carsxe-swift-package

Stars: 0

Forks: 0

Open issues: 0

Default branch: main

Primary language: swift

License: MIT

Topics: swift-sdk

README: README.md