The CarsXE Python SDK provides a simple and powerful way to integrate vehicle data into your Python applications. This guide will help you get started quickly.
For more information, see the package on PyPI.
## Installation
Install the CarsXE Python package using pip:
`pip install carsxe`
## Setup
First, import the CarsXE client and initialize it with your API key:
```python
import asyncio
from carsxe_api import CarsXE
# Initialize the client
carsxe = CarsXE('YOUR_API_KEY_HERE')
```
## Basic Usage
### VIN Specifications
```python
import asyncio
from carsxe_api import CarsXE
carsxe = CarsXE('YOUR_API_KEY')
vin = 'WBAFR7C57CC811956'
try:
vehicle = asyncio.run(carsxe.specs({"vin": vin}))
print(vehicle["input"]["vin"])
except Exception as error:
print(f"Error: {error}")
```
### International VIN Decoder
```python
import asyncio
from carsxe_api import CarsXE
carsxe = CarsXE('YOUR_API_KEY')
try:
intvin = asyncio.run(carsxe.int_vin_decoder({"vin": "WF0MXXGBWM8R43240"}))
print(intvin)
except Exception as error:
print(f"Error: {error}")
```
### Market Value
```python
import asyncio
from carsxe_api import CarsXE
carsxe = CarsXE('YOUR_API_KEY')
try:
marketvalue = asyncio.run(carsxe.market_value({"vin": "WBAFR7C57CC811956"}))
print(marketvalue)
except Exception as error:
print(f"Error: {error}")
```
### Vehicle History
```python
import asyncio
from carsxe_api import CarsXE
carsxe = CarsXE('YOUR_API_KEY')
try:
history = asyncio.run(carsxe.history({"vin": "WBAFR7C57CC811956"}))
print(history)
except Exception as error:
print(f"Error: {error}")
```
### License Plate Decoder
```python
import asyncio
from carsxe_api import CarsXE
carsxe = CarsXE('YOUR_API_KEY')
try:
decoded_plate = asyncio.run(carsxe.plate_decoder({"plate": "7XER187", "state": "CA", "country": "US"}))
print(decoded_plate)
except Exception as error:
print(f"Error: {error}")
```
### Vehicle Images
```python
import asyncio
from carsxe_api import CarsXE
carsxe = CarsXE('YOUR_API_KEY')
try:
images = asyncio.run(carsxe.images({"make": "BMW", "model": "X5", "year": "2019"}))
print(images)
except Exception as error:
print(f"Error: {error}")
```
### Vehicle Recalls
```python
import asyncio
from carsxe_api import CarsXE
carsxe = CarsXE('YOUR_API_KEY')
try:
recalls = asyncio.run(carsxe.recalls({"vin": "1C4JJXR64PW696340"}))
print(recalls)
except Exception as error:
print(f"Error: {error}")
```
### Plate Image Recognition
```python
import asyncio
from carsxe_api import CarsXE
carsxe = CarsXE('YOUR_API_KEY')
try:
plateimg = asyncio.run(carsxe.plate_image_recognition({"upload_url": "https://imagedelivery.net/moyiiSImjJPI_EZVxNMBBw/f49aed53-d736-4370-f3f4-97418841c800/public"}))
print(plateimg)
except Exception as error:
print(f"Error: {error}")
```
### VIN OCR from Image
```python
import asyncio
from carsxe_api import CarsXE
carsxe = CarsXE('YOUR_API_KEY')
try:
vinocr = asyncio.run(carsxe.vin_ocr({"upload_url": "https://imagedelivery.net/moyiiSImjJPI_EZVxNMBBw/f49aed53-d736-4370-f3f4-97418841c800/public"}))
print(vinocr)
except Exception as error:
print(f"Error: {error}")
```
### Year-Make-Model Search
```python
import asyncio
from carsxe_api import CarsXE
carsxe = CarsXE('YOUR_API_KEY')
try:
yymm = asyncio.run(carsxe.year_make_model({"year": "2012", "make": "BMW", "model": "5 Series"}))
print(yymm)
except Exception as error:
print(f"Error: {error}")
```
### OBD Code Decoder
```python
import asyncio
from carsxe_api import CarsXE
carsxe = CarsXE('YOUR_API_KEY')
try:
obdcode = asyncio.run(carsxe.obd_codes_decoder({"code": "P0115"}))
print(obdcode)
except Exception as error:
print(f"Error: {error}")
```
### Lien and Theft
```python
import asyncio
from carsxe_api import CarsXE
carsxe = CarsXE('YOUR_API_KEY')
try:
lien_and_theft = asyncio.run(carsxe.lien_and_theft({"vin": "2C3CDXFG1FH762860"}))
print(lien_and_theft)
except Exception as error:
print(f"Error: {error}")
```
Start building powerful automotive applications with CarsXE's Python SDK!