> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fryte.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Plan a Stuttgart → Berlin trip and find where the truck needs to charge.

## 1. Submit your route

<Info>
  You need an [API key](/#authentication) and a [Vehicle ID](/planner/vehicles).
</Info>

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST "https://api.fryte.eu/planner/v2" \
    -H "Authorization: Bearer <your-token>" \
    -H "Content-Type: application/json" \
    -d '{
      "vehicle_id": "010160700001",
      "battery_level_start": 0.8,
      "section_list": [
        {
          "start_pos": [48.7758, 9.1829],
          "stop_pos": [52.5200, 13.4050],
          "payload_kg": 19300
        }
      ],
      "poi_info": {
        "min_kW": 150,
        "connector_type": ["CCS"]
      }
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api.fryte.eu/planner/v2",
      headers={"Authorization": "Bearer <your-token>"},
      json={
          "vehicle_id": "010160700001",
          "battery_level_start": 0.8,
          "section_list": [
              {
                  "start_pos": [48.7758, 9.1829],
                  "stop_pos": [52.5200, 13.4050],
                  "payload_kg": 19300,
              }
          ],
          "poi_info": {
              "min_kW": 150,
              "connector_type": ["CCS"],
          },
      },
  )
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.fryte.eu/planner/v2", {
    method: "POST",
    headers: {
      "Authorization": "Bearer <your-token>",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      vehicle_id: "010160700001",
      battery_level_start: 0.8,
      section_list: [
        {
          start_pos: [48.7758, 9.1829],
          stop_pos: [52.5200, 13.4050],
          payload_kg: 19300,
        },
      ],
      poi_info: {
        min_kW: 150,
        connector_type: ["CCS"],
      },
    }),
  });
  const data = await response.json();
  console.log(data);
  ```

  ```csharp C# theme={null}
  using var client = new HttpClient();
  client.DefaultRequestHeaders.Add("Authorization", "Bearer <your-token>");

  var json = """
  {
      "vehicle_id": "010160700001",
      "battery_level_start": 0.8,
      "section_list": [
          {
              "start_pos": [48.7758, 9.1829],
              "stop_pos": [52.5200, 13.4050],
              "payload_kg": 19300
          }
      ],
      "poi_info": {
          "min_kW": 150,
          "connector_type": ["CCS"]
      }
  }
  """;

  var response = await client.PostAsync(
      "https://api.fryte.eu/planner/v2",
      new StringContent(json, System.Text.Encoding.UTF8, "application/json")
  );
  var result = await response.Content.ReadAsStringAsync();
  Console.WriteLine(result);
  ```
</CodeGroup>

The API starts optimizing in the background and returns identifiers to track the job.

```json theme={null}
{
  "optimization_id": 7716,
  "job_id": "20ccaf8b-d36b-4c21-bb32-d00e758abe14",
  "tour_id": 7673
}
```

## 2. Check progress

Poll with your `job_id` until `status` is `succeeded`.

<CodeGroup>
  ```bash curl theme={null}
  curl "https://api.fryte.eu/planner/jobs/<job_id>" \
    -H "Authorization: Bearer <your-token>"
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      "https://api.fryte.eu/planner/jobs/<job_id>",
      headers={"Authorization": "Bearer <your-token>"},
  )
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.fryte.eu/planner/jobs/<job_id>", {
    headers: {
      "Authorization": "Bearer <your-token>",
    },
  });
  const data = await response.json();
  console.log(data);
  ```

  ```csharp C# theme={null}
  using var client = new HttpClient();
  client.DefaultRequestHeaders.Add("Authorization", "Bearer <your-token>");

  var response = await client.GetAsync("https://api.fryte.eu/planner/jobs/<job_id>");
  var result = await response.Content.ReadAsStringAsync();
  Console.WriteLine(result);
  ```
</CodeGroup>

```json theme={null}
{
  "status": "succeeded",
  "optimization_id": 7716,
  "job_id": "20ccaf8b-d36b-4c21-bb32-d00e758abe14",
  "tour_id": 7673,
  "vehicle_id": "010160700001"
}
```

## 3. Get your optimized route

<CodeGroup>
  ```bash curl theme={null}
  curl "https://api.fryte.eu/planner/optimizations/7716/result" \
    -H "Authorization: Bearer <your-token>"
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      "https://api.fryte.eu/planner/optimizations/7716/result",
      headers={"Authorization": "Bearer <your-token>"},
  )
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.fryte.eu/planner/optimizations/7716/result", {
    headers: {
      "Authorization": "Bearer <your-token>",
    },
  });
  const data = await response.json();
  console.log(data);
  ```

  ```csharp C# theme={null}
  using var client = new HttpClient();
  client.DefaultRequestHeaders.Add("Authorization", "Bearer <your-token>");

  var response = await client.GetAsync("https://api.fryte.eu/planner/optimizations/7716/result");
  var result = await response.Content.ReadAsStringAsync();
  Console.WriteLine(result);
  ```
</CodeGroup>

The optimizer found two charging stops for the 640 km route:

```json theme={null}
{
  "qualification": "Driveable",
  "battery_level_start": 0.8,
  "battery_level_end": 0.19,
  "sections": [
    {
      "start_pos": [48.78, 9.18, 0.80],
      "stop_pos": [50.05, 11.62, 0.48],
      "poi_summary": {
        "name": "IONITY",
        "address": "Bayreuther Straße 1",
        "power_available_kW": 350.0,
        "energy_kWh": 168.0,
        "charge_time_min": 32.0,
        "service_time_min": 35.0
      }
    },
    {
      "start_pos": [50.06, 11.62, 0.48],
      "stop_pos": [50.37, 11.79, 0.65],
      "poi_summary": {
        "name": "IONITY",
        "address": "Sieggrubenstraße 2",
        "power_available_kW": 350.0,
        "energy_kWh": 178.5,
        "charge_time_min": 34.0,
        "service_time_min": 37.0
      }
    },
    {
      "start_pos": [50.37, 11.79, 0.65],
      "stop_pos": [52.52, 13.40, 0.19],
      "poi_summary": {
        "name": "Destination",
        "address": "See Destination",
        "power_available_kW": 0,
        "energy_kWh": 0,
        "charge_time_min": 0,
        "service_time_min": 0
      }
    }
  ],
  "toll_summary": [],
  "poi_list": ["..."]
}
```
