# Forbind til API

En stor del af Carnot platformens data kan til gåes ved brug af ens personlige API nøgle. Hvis du endnu ikke har fået din så følg linket herunder til 'Få adgang til API':

{% embed url="<https://app.gitbook.com/s/XJDkXMbKDF6XztXITb9z/~/changes/QtBipQyU6qMgcOzC9Sck/guides/fa-adgang-til-api>" %}
Få adgang til API
{% endembed %}

## Endpoints&#x20;

### /get\_predict - seneste prognoser

## Få de seneste prognoser på en tilgængelig energikilde, forbrug eller spotpris

<mark style="color:blue;">`GET`</mark> `https://openapi.carnot.dk/openapi/get_predict`

#### Query Parameters

| Name                                           | Type   | Description                                                                              |
| ---------------------------------------------- | ------ | ---------------------------------------------------------------------------------------- |
| energysource<mark style="color:red;">\*</mark> | string | Begrænset til \[offshorewindpower, onshorewindpower, solarpower, consumption, spotprice] |
| region<mark style="color:red;">\*</mark>       | string | Begrænset til \[dk1,dk2]                                                                 |
| daysahead<mark style="color:red;">\*</mark>    | int    | Antal af dage frem. Imellem 1 og 7                                                       |
| granularity                                    | string | **PREMIUM** - Begrænset til \[hourly, 15min]                                             |

#### Headers

| Name                                       | Type   | Description                                 |
| ------------------------------------------ | ------ | ------------------------------------------- |
| apikey<mark style="color:red;">\*</mark>   | string | Den personlige API nøgle                    |
| username<mark style="color:red;">\*</mark> | string | Din email adresse der er knyttet til Carnot |

{% tabs %}
{% tab title="200: OK " %}

```json
{
  "predictions": [
    {
      "id": 2362551,
      "dktime": "2022-08-15T17:00:00+00:00",
      "utctime": "2022-08-15T17:00:00+00:00",
      "latest": true,
      "pricearea": "dk1",
      "energysource": "offshorewindpower",
      "prediction": 128.79006411199998, // DKK hvis det er spotpris ellers MWh
      "addedtime": "2022-08-15T16:49:02.727329" // prognosens opdaterings tidspunkt
    },
  ]
}
```

{% endtab %}
{% endtabs %}

#### Request

```bash
curl -X 'GET' \
  'https://openapi.carnot.dk/openapi/get_predict?energysource=offshorewindpower&region=dk1&daysahead=7&granularity=hourly' \
  -H 'accept: application/json' \
  -H 'apikey: {{ APIKEY }}' \
  -H 'username: {{ CARNOT EMAIL }}'
```

### /get\_users\_cars - hent dine oprettede biler

## Hent dine oprettede biler

<mark style="color:blue;">`GET`</mark> `https://openapi.carnot.dk/openapi/get_users_cars`

#### Headers

| Name                                       | Type   | Description                                 |
| ------------------------------------------ | ------ | ------------------------------------------- |
| apikey<mark style="color:red;">\*</mark>   | string | Den personlige API nøgle                    |
| username<mark style="color:red;">\*</mark> | string | Din email adresse der er knyttet til Carnot |

{% tabs %}
{% tab title="200: OK " %}

```json
[
  {
    "username": "info@carnot.dk",
    "maxrange": 256,
    "bottombuffer": 0.2,
    "topbuffer": 0.2,
    "manufacturer": "VW",
    "year": 2018,
    "currentrange": 128,
    "id": 15,
    "chargetime": 3,
    "model": "e-up!",
    "name": "e-up!"
  },
  {
    "username": "info@carnot.dk",
    "maxrange": 354,
    "bottombuffer": 0.2,
    "topbuffer": 0.2,
    "manufacturer": "Tesla",
    "year": 2020,
    "currentrange": 280,
    "id": 21,
    "chargetime": 3,
    "model": "Model 3",
    "name": "Teslaen 3"
  }
]
```

{% endtab %}
{% endtabs %}

#### Request

```bash
// Some code

curl -X 'GET' \
  'https://openapi.carnot.dk/openapi/get_user_cars' \
  -H 'accept: application/json' \
  -H 'apikey: {{ APIKEY }}' \
  -H 'username: {{ CARNOT EMAIL }}'
```

### /get\_commuteplan\_for\_car - hent opladningsplan for en specifik bil

## Hent opladningsplan for en specifik bil

<mark style="color:blue;">`GET`</mark> `https://openapi.carnot.dk/openapi/get_commuteplan_for_car`

#### Query Parameters

| Name         | Type    | Description                                                     |
| ------------ | ------- | --------------------------------------------------------------- |
| region       | string  | Begrænset til \[dk1,dk2]                                        |
| includetoday | boolean | Styrer om hvor vidt dagens behov skal inkluderes i optimeringen |
| endonfull    | boolean | Styrer om hvor vidt planen skal ende med et fyldt batteri       |
| carid        | int     | id for din bil                                                  |

#### Headers

| Name     | Type   | Description                                 |
| -------- | ------ | ------------------------------------------- |
| apikey   | string | Den personlige API nøgle                    |
| username | string | Din email adresse der er knyttet til Carnot |

{% tabs %}
{% tab title="200: OK " %}

```json
{
  "best_schedule": [
    {
      "used": 1,
      "start_charge_point": "2022-08-15T16:00:00+00:00",
      "end_charge_point": "2022-08-16T06:00:00+00:00",
      "best_charge_point": "2022-08-16T00:00:00+00:00",
      "battery_charge_level": 180,
      "demands": 100,
      "reminder_demand": 100,
      "demandstart": "08:00:00",
      "demandend": "18:00:00",
      "charge_price_charge_point": 3.1481932780000004,
      "extra_charging": 0
    },
  ],
  "solution_value": 323.6342689784001,
  "improvement": 0.648722941036366
}on
```

{% endtab %}
{% endtabs %}

#### Request

```bash
// Some code
curl -X 'GET' \
  'https://openapi.carnot.dk/openapi/get_commuteplan_for_car?region=dk1&includetoday=true&endonfull=false&carid=21' \
  -H 'accept: application/json' \
  -H 'apikey: {{ APIKEY }}' \
  -H 'username: {{ CARNOT EMAIL }}'
```

### /get\_users\_electricitycompany - hent energiselskab knyttet til din konto

## Hent brugerens energiselskab

<mark style="color:blue;">`GET`</mark> `https://openapi.carnot.dk/openapi/get_users_electricitycompany`

#### Headers

| Name     | Type   | Description                                 |
| -------- | ------ | ------------------------------------------- |
| apikey   | string | Den personlige API nøgle                    |
| username | string | Din email adresse der er knyttet til Carnot |

{% tabs %}
{% tab title="200: OK " %}

```json
{
  "name": "andel energi - Variabel pris",
  "charge": 0.004,
  "id": 16,
  "link": "https://andelenergi.dk/"
}
```

{% endtab %}
{% endtabs %}

#### Request

```bash
curl -X 'GET' \
  'https://openapi.carnot.dk/openapi/get_users_electricitycompany' \
  -H 'accept: application/json' \
  -H 'apikey: {{ APIKEY }}' \
  -H 'username: {{ CARNOT EMAIL }}'

```

### /get\_users\_gridcompany- hent specifikt netselskaber knyttet til din konto

## Hent brugerens netselskab

<mark style="color:blue;">`GET`</mark> `https://openapi.carnot.dk/openapi/get_users_gridcompany`

#### Headers

| Name     | Type   | Description                                 |
| -------- | ------ | ------------------------------------------- |
| apikey   | string | Den personlige API nøgle                    |
| username | string | Din email adresse der er knyttet til Carnot |

{% tabs %}
{% tab title="200: OK " %}

```json
{
  "charge_nonpeak": 0.3003,
  "id": 1,
  "link": null,
  "charge_peak": 0.7651,
  "name": "Radius C"
}
```

{% endtab %}
{% endtabs %}

#### Request

```bash
curl -X 'GET' \
  'https://openapi.carnot.dk/openapi/get_users_gridcompany' \
  -H 'accept: application/json' \
  -H 'apikey: {{ APIKEY }}' \
  -H 'username: {{ CARNOT EMAIL }}'
```

### <mark style="color:orange;">**UNDER OPBYGNING**</mark>

### /structured\_dmi - hent struktureret DMI og energidataservice datasæt&#x20;

#### Parametre

* apikey&#x20;
  * Din personlige API nøgle
* username
  * Din email adresse der er knyttet til Carnot

#### Request

#### Returneret skema

###

```json
```

Alle åbne endpoints kan findes her:

{% embed url="<https://openapi.carnot.dk/docs>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kasperisme.gitbook.io/carnot/guides/forbind-til-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
