1. Go to this page and download the library: Download northbees/autotrader-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// To request a valuation, first complete a vehicle request
$vehicle = app(AutotraderApi::class)->getVehicle($advertiserId, $vrm);
// Then do a valuation lookup
$valuation = app(AutotraderApi::class)->getValuation($advertiserId, $vehicle->derivativeId, $mileage, $vehicle->firstRegistrationDate);
//You can also pass additional data to adjust your valuation
$valuation = app(AutotraderApi::class)->getValuation($advertiserId, $vehicle->derivativeId, $mileage, $vehicle->firstRegistrationDate, [
'totalPrice' => null,
'features' => null,
'conditionRating' => null,
'priceIndicatorRatingBands' => true,
]));
$valuation = app(AutotraderApi::class)->getMetrics($advertiserId, $vehicle->derivativeId, $mileage, $vehicle->firstRegistrationDate);
// With vatStatus for commercial vehicle No VAT valuations
$valuation = app(AutotraderApi::class)->getVehicleMetrics($advertiserId, $derivativeId, $mileage, $firstRegistrationDate, [
'vatStatus' => 'NO_VAT',
]);
// Get finance options (quotes)
$financeOptions = app(AutotraderApi::class)->getFinanceOptions($advertiserId, $vehicleData);
// Submit finance application (note: only months fields are used, not years)
// Use financeTerms.productType instead of deprecated financeTerms.product
// Use applicant.replacingExistingLoan instead of deprecated affordability.replacingExistingLoan
// Use applicant.lastName instead of deprecated applicant.surname
$application = app(AutotraderApi::class)->submitFinanceApplication($advertiserId, [
'monthsAtBank' => 40, // Previously would be yearsAtBank: 3, monthsAtBank: 4
'monthsAtEmployer' => 36,
'monthsAtAddress' => 48,
'financeTerms' => [
'productType' => 'PCP', // Use productType, not deprecated product
],
'applicant' => [
'lastName' => 'Smith', // Use lastName, not deprecated surname
'replacingExistingLoan' => true, // Use this, not deprecated affordability.replacingExistingLoan
'monthlyRentOrMortgage' => ['amountGBP' => 800], // Use this, not deprecated monthlyRentOrMortgageGBP
'monthlyChildcare' => ['amountGBP' => 200], // Use this, not deprecated monthlyChildCareGBP
'existingLoanMonthlyPayment' => ['amountGBP' => 100], // Jun 2026 - existing loan monthly payment
],
// ... other finance data
]);
// Update finance application
$updated = app(AutotraderApi::class)->updateFinanceApplication($advertiserId, $applicationId, $financeData);
// Get a finance application by ID
// Note: anonymised applications return {applicationId, status: "Expired"} instead of a 451 error
$application = app(AutotraderApi::class)->getFinanceApplication($advertiserId, $applicationId);
if (($application['status'] ?? null) === 'Expired') {
// Application has been anonymised due to legal reasons
}
// Get stock list with new features
$stock = app(AutotraderApi::class)->getStockList($advertiserId, $filters, [
'factoryCodes' => true,
'priceIndicatorRatingBands' => true,
'wheelbaseMM' => true,
]);
// Get real-time stock summary
$summary = app(AutotraderApi::class)->getStockSummary($advertiserId, $stockId);
// Update stock - mark as SOLD and unpublish tradeAdvert
$updated = app(AutotraderApi::class)->updateStock($advertiserId, [
'metadata' => ['stockId' => $stockId, 'lifecycleState' => 'SOLD'],
'adverts' => ['tradeAdvert' => ['status' => 'NOT_PUBLISHED']],
]);
// Get all deals for an advertiser
$deals = app(AutotraderApi::class)->getDeals($advertiserId);
// Get deals with filters
$deals = app(AutotraderApi::class)->getDeals($advertiserId, [
'page' => 1,
'from' => '2023-05-05',
'to' => '2023-05-07',
]);
// Get a specific deal
$deal = app(AutotraderApi::class)->getDeal($advertiserId, $dealId);
// Create a new deal (originated outside of Autotrader consumer journey)
$deal = app(AutotraderApi::class)->createDeal($advertiserId, [
'stockId' => $stockId,
// ... deal data
]);
// Complete a deal
$response = app(AutotraderApi::class)->completeDeal($advertiserId, $dealId);
// Cancel a deal with reason
$response = app(AutotraderApi::class)->cancelDeal($advertiserId, $dealId, 'Unaffordable', 'Customer cannot afford the deposit');
// Update a deal with custom data
$response = app(AutotraderApi::class)->updateDeal($advertiserId, $dealId, [
'advertiserDealStatus' => 'Complete'
]);
// Remove deal components
$response = app(AutotraderApi::class)->removeDealPartExchange($advertiserId, $dealId);
$response = app(AutotraderApi::class)->removeDealFinanceApplication($advertiserId, $dealId);
// Get messages for a specific message ID
$messages = app(AutotraderApi::class)->getMessages($advertiserId, $messagesId);
// Mark messages as read
$response = app(AutotraderApi::class)->markMessagesAsRead($advertiserId, $messagesId);
// Send a new message for a new conversation
$response = app(AutotraderApi::class)->sendMessage($advertiserId, [
'dealId' => '1a0e00aa-459b-162d-a23a-adcbb1110f04',
'message' => 'Your message here (max 1500 characters)'
]);
// Send a message to an existing conversation
$response = app(AutotraderApi::class)->sendMessage($advertiserId, [
'messagesId' => 'e00a1a0a-162d-459b-a23a-0f04adcbb111',
'message' => 'Your reply message here'
]);
// Get delivery details
$delivery = app(AutotraderApi::class)->getDelivery($advertiserId, $deliveryId);
// Get call details
$calls = app(AutotraderApi::class)->getCalls($advertiserId, $callId);
// Get integrations for the current partner
$integrations = app(AutotraderApi::class)->getIntegrations();
// Get advertisers
$advertisers = app(AutotraderApi::class)->getAdvertisers();
$response = app(AutotraderApi::class)->getVehicle($advertiserId, $vrm, $mileage, [
'history' => 'true',
]);
$record = $response['results'][0] ?? null;
if ($record === null) {
// totalResults is 0 — no vehicle matched the registration
}
$make = $record['vehicle']['make'];
$previousOwners = $record['history']['previousOwners'] ?? null;
$serviceWarnings = $response['warnings'] ?? []; // e.g. a token that cannot reach an endpoint
$recordWarnings = $record['warnings'] ?? []; // e.g. derivative information not sourced