# Tesla (`ralvaromariano/tesla`) Actor

Get real-time Tesla inventory & pricing data globally! This Apify Scraper extracts new, used & demo car stock direct from Tesla's API. Filter by country, model (S, 3, X, Y), and condition. Ideal for market analysis, competitive insights, or finding your next Tesla.

- **URL**: https://apify.com/ralvaromariano/tesla.md
- **Developed by:** [Álvaro Rodríguez](https://apify.com/ralvaromariano) (community)
- **Categories:** Other, Automation, E-commerce
- **Stats:** 54 total users, 1 monthly users, 100.0% runs succeeded, 3 bookmarks
- **User rating**: 4.00 out of 5 stars

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Tesla Official Inventory & Pricing Scraper

This Apify Actor extracts real-time inventory and pricing data directly from Tesla's official website API. It allows you to precisely target your search by country, model, and vehicle condition (new, used, or demo). Get up-to-date information on available Tesla vehicles globally for market research, competitive analysis, or personal car shopping.

### Features

- Official Data Source: Scrapes directly from Tesla's public inventory API, ensuring high data accuracy and freshness.
- Comprehensive Filtering: Specify target countries, models (S, 3, X, Y), and conditions (new, used, demo).
- Global Coverage: Supports all countries listed, including US, Canada, Mexico, and various European markets.
- Structured Output: Provides clean, machine-readable JSON data for each car listing, including VIN, price, model details, mileage, location, and more.

### Input Parameters

The Actor accepts the following input fields, which you can specify in JSON format:

```json
{
  "countries": [
    "us",
    "de",
    "ca",
    "es",
  ],
  "models": [
    "s",
    "3",
    "x",
    "y"
  ],
  "conditions": [
    "new",
    "used"
  ],
  "limit": 10,
  "offset": 0
}
```

- countries (Array of Strings, optional):
  - A list of lowercase 2-letter country codes for which to fetch inventory.
  - Example: \["us", "de", "gb"] for United States, Germany, and United Kingdom.
  - Default: \["us"]

- models (Array of Strings, optional):
  - A list of Tesla model codes.
  - Valid options: "s", "3", "x", "y".
  - Example: \["3", "y"] for Model 3 and Model Y.
  - Default: \["s", "3", "x", "y"] (all models)

- conditions (Array of Strings, optional):
  - A list of vehicle conditions to filter by.
  - Valid options: "new", "used", "demo".
  - Example: \["used"] for only used vehicles.
  - Default: \["used", "new"]

### Output Example

The Actor outputs a dataset where each item represents a single Tesla vehicle listing. Here's an example of the structure:

```json
[
  {
    "ActualPrice": 45000,
    "Assets": [
      {
        "type": "image",
        "url": "https://digitalassets.tesla.com/..."
      }
    ],
    "City": "New York",
    "Country": "US",
    "DeliveryType": "Direct",
    "Drive": "AWD",
    "ExteriorColor": "Pearl White Multi-Coat",
    "InteriorColor": "Black",
    "InventoryType": "used",
    "LocationId": "12345",
    "Model": "Model 3",
    "Odometer": 15000,
    "OptionCodeList": ["ADPX1", "ADPC0", "APF0", "..."],
    "OptionNameList": ["Premium Interior", "Autopilot", "..."],
    "Price": 45000,
    "PurchasePrice": 45000,
    "Region": "NY",
    "Series": "Long Range",
    "State": "New York",
    "Trim": "Long Range AWD",
    "VIN": "5YJ3E1EAXXX",
    "Year": 2022,
    "Zip": "10001",
    "scraped_country": "US",
    "scraped_condition": "used",
    "scraped_model": "3"
  },
  // ... more listings
]
```

### Potential Use Cases

- Market Analysis: Track pricing trends, inventory levels, and popular configurations across different regions.
- Competitive Intelligence: Monitor Tesla's stock in various markets.
- Car Dealerships: Keep an eye on direct competitor inventory and pricing.
- Research & Analytics: Gather data for academic studies on automotive market dynamics.
- Personal Car Shopping: Find specific Tesla models with desired features and conditions in your area or abroad.

# Actor input Schema

## `countries` (type: `array`):

Select the 2-letter country codes for which to scrape Tesla inventory. The actor will iterate through each selected country.

## `models` (type: `array`):

Select the Tesla model codes to scrape.

## `conditions` (type: `array`):

Select the vehicle conditions to filter by.

## `limit` (type: `integer`):

Maximum number of results to retrieve per request. Tesla commonly returns paged results. Set to 0 only if you handle it in code; otherwise use a positive number.

## `offset` (type: `integer`):

Number of results to skip from the beginning.

## `minDelaySeconds` (type: `number`):

Minimum delay in seconds between requests. Higher values help reduce 429 rate limits.

## `maxDelaySeconds` (type: `number`):

Maximum delay in seconds between requests. A random value between min and max is used after each request.

## `maxRetries` (type: `integer`):

Maximum number of retries when Tesla returns HTTP 429.

## `extraQuery` (type: `object`):

Optional extra fields merged into Tesla's internal query object. Use this for fields like zip, lat, lng, range, PaymentType, paymentRange, Odometer, or options.

## `pageWaitMs` (type: `integer`):

Time to stay on the Tesla inventory page before calling the API from inside the browser context.

## `debugHeaded` (type: `boolean`):

Run Chromium with headless disabled for debugging under Xvfb.

## `saveScreenshots` (type: `boolean`):

Save screenshots on landing page load and on failures.

## `proxySettings` (type: `object`):

Select Apify Proxy or provide your own proxies. Residential proxies are recommended if Tesla starts returning 403 or 429 frequently.

## Actor input object example

```json
{
  "countries": [
    "us"
  ],
  "models": [
    "s",
    "3",
    "x",
    "y"
  ],
  "conditions": [
    "new",
    "used"
  ],
  "limit": 20,
  "offset": 0,
  "minDelaySeconds": 8,
  "maxDelaySeconds": 15,
  "maxRetries": 5,
  "extraQuery": {},
  "pageWaitMs": 5000,
  "debugHeaded": false,
  "saveScreenshots": true,
  "proxySettings": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "proxySettings": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("ralvaromariano/tesla").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "proxySettings": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    } }

# Run the Actor and wait for it to finish
run = client.actor("ralvaromariano/tesla").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "proxySettings": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call ralvaromariano/tesla --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ralvaromariano/tesla"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/Av2aOuwnks5DsqGfJ/builds/YVhMzMB7u66Qvhmw7/openapi.json
