Software
Cardealer DP provides SDKs for Python and TypeScript/JavaScript to make it easy to publish and consume Car Dealer Data Packages.
Python
Section titled “Python”Installation
Section titled “Installation”pip install cardealerdp frictionlessPublication
Section titled “Publication”from cardealerdp import Package, Car, Dealerimport frictionless
# Create dealer informationdealer = Dealer( title="Premium Auto Sales", country="United States", region="California", city="Los Angeles", address="1234 Sunset Boulevard", postcode="90028", phone="+1-323-555-0100", email="sales@premiumauto.com", url="https://www.premiumauto.com", lat=34.0983, lon=-118.3267,)
# Create car listingscar = Car( title="2023 Tesla Model 3 Long Range", url="https://www.premiumauto.com/cars/tesla-model-3-2023", price=45990, currency="USD", year=2023, mileage=12000, brand="Tesla", model="Model 3", version="Long Range AWD", fuel="electric", gearbox="auto", category="saloon", color="white", door="fourfive", power=346, seats=5, range=358, battery=75,)
package = Package( { "$schema": "https://datisthq.github.io/cardealerdp/extension/v0.3.3/profile.json", "resources": [ { "name": "car", "data": [car], "schema": "https://datisthq.github.io/cardealerdp/extension/v0.3.3/schemas/car.json", }, { "name": "dealer", "data": [dealer], "schema": "https://datisthq.github.io/cardealerdp/extension/v0.3.3/schemas/dealer.json", }, ], })
frictionless.Package(package).to_json("cardealer.json")Validation
Section titled “Validation”import frictionless
report = frictionless.validate("cardealer.json")print(report)Consumption
Section titled “Consumption”import frictionless
package = frictionless.Package("cardealer.json")print(package)TypeScript
Section titled “TypeScript”Installation
Section titled “Installation”npm install cardealerdp dpkitPublication
Section titled “Publication”import type { Car, Dealer, Package } from "cardealerdp";import { savePackageDescriptor } from "dpkit";
const dealer: Dealer = { title: "Premium Auto Sales", country: "United States", region: "California", city: "Los Angeles", address: "1234 Sunset Boulevard", postcode: "90028", phone: "+1-323-555-0100", email: "sales@premiumauto.com", url: "https://www.premiumauto.com", lat: 34.0983, lon: -118.3267,};
const car: Car = { title: "2023 Tesla Model 3 Long Range", url: "https://www.premiumauto.com/cars/tesla-model-3-2023", price: 45990, currency: "USD", year: 2023, mileage: 12000, brand: "Tesla", model: "Model 3", version: "Long Range AWD", fuel: "electric", gearbox: "auto", category: "saloon", color: "white", door: "fourfive", power: 346, seats: 5, range: 358, battery: 75,};
const dataPackage: Package = { $schema: "https://datisthq.github.io/cardealerdp/extension/v0.3.3/profile.json", resources: [ { name: "car", data: [car], schema: "https://datisthq.github.io/cardealerdp/extension/v0.3.3/schemas/car.json", }, { name: "dealer", data: [dealer], schema: "https://datisthq.github.io/cardealerdp/extension/v0.3.3/schemas/dealer.json", }, ],};
await savePackageDescriptor(dataPackage, { path: "cardealer.json", overwrite: true,});Validation
Section titled “Validation”import { validatePackage } from "dpkit";
const { valid, errors } = await validatePackage("cardealer.json");console.log(valid, errors);Consumption
Section titled “Consumption”import { loadPackageDescriptor } from "dpkit";
const dataPackage = await loadPackageDescriptor("cardealer.json");console.log(dataPackage);Command-Line
Section titled “Command-Line”Installation
Section titled “Installation”curl -fsSL https://dpkit.dev/install.sh | shValidation
Section titled “Validation”./dp package validate cardealer.jsonConsumption
Section titled “Consumption”./dp table explore -p cardealer.json