> For the complete documentation index, see [llms.txt](https://mrwheel-docs.gitbook.io/dsmrlogger32/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mrwheel-docs.gitbook.io/dsmrlogger32/beschrijving-restapis-v2.md).

# Beschrijving restAPI's (v2)

Alle beschikbare gegevens kunnen via restAPI call's bij de DSMR-logger worden opgevraagd. De restAPI's zijn verdeeld in drie groepen. Informatie die met de hardware en firmware te maken heeft (`/dev`), informatie die met de Slimme Meter te maken heeft (`/sm`) en historische gegevens die, aan de hand van de door de Slimme Meter afgegeven gegevens, door de DSMR-logger in bestanden worden opgeslagen (`/hist`).

* [DSMR-logger gerelateerde restAPI's](/dsmrlogger32/beschrijving-restapis-v2/dsmr-logger-gerelateerde-restapis.md)
* [Slimme Meter gerelateerde restAPI's](/dsmrlogger32/beschrijving-restapis-v2/slimme-meter-gerelateerde-restapis.md)
* [Historie gerelateerde restAPI's](/dsmrlogger32/beschrijving-restapis-v2/historische-gegevens-gerelateerde-restapis.md)

## Aanroepen restAPI vanuit verschillende systemen

Een restAPI kan op verschillende manieren worden aangeroepen.

* [Javascript](#javascript)
* [Unix command](#unix-command)
* [Home Assistant](#home-assistant)
* [Arduino Mega met Ethernet Shield](/dsmrlogger32/beschrijving-restapis-v2/arduino-mega-met-ethernet-shield.md)
* [ESP8266](/dsmrlogger32/beschrijving-restapis-v2/esp8266-wifi.md)
* [ESP32](/dsmrlogger32/beschrijving-restapis-v2/esp32-wifi.md)

### Javascript

```
    fetch(APIGW+"v2/dev/time")
      .then(response => response.json())
      .then(json => {
        //console.log("parsed .., data is ["+ JSON.stringify(json)+"]");
        data = json.devtime;
        for( let field in data )
        {
          //console.log("dev/time: field["+field+"], value["+data[field]+"]");
          if (field == "time")
          {
            //console.log("Got new time ["+data[field]+"]");
            document.getElementById('theTime').innerHTML = data[field];
          }
        }
      })
      .catch(function(error) {
        var p = document.createElement('p');
        p.appendChild(
          document.createTextNode('Error: ' + error.message)
        );
      });     
```

### Unix command

```
curl http://dsmr-api.local/api/v2/dev/time
```

Geeft dit als output:

```
{
  "devtime": {
    "timestamp": "230104142233W",
    "time": "04-01-2023 14:22:17",
    "time_rev": "2023-01-04 14:22:17",
    "epoch": 1672838537,
    "uptime": "1(d)-22:27(H:m)",
    "uptime_secs": 167241
  }
}
```

### Home Assistant

configuration.yaml:

```
### configuration.yaml
### DSMRloggerAPI 

    <<help>>
```

geeft dit resultaat:

{% hint style="danger" %} <mark style="color:red;">Heeft iemand een werkend Home-Assistant yaml bestand dat hij wil delen?</mark>
{% endhint %}

De source van deze code kun je op [github](https://github.com/mrWheel/readDSMR-logger) vinden.

### Andere systemen

Veel andere systemen hebben hun eigen manier om restAPI's op te vragen. Lees hiervoor de betreffende documentatie.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://mrwheel-docs.gitbook.io/dsmrlogger32/beschrijving-restapis-v2.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
