---
title: "Checking the API status"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Checking the API status}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

First we load the package

```{r}
library(dawaR)
```

## Use `status_check()` to assert whether the services are available

`status_check()` is built to provide a simple `cli` response in the R console with the current status of the API.

```{r}
status_check()
```

It is also possible to return a dataframe specifying the individual status of each service provided by the government entity that maintains DAWA. This is particularly useful if you would like to use it in any further analyses.

```{r}
status_check(return_df = TRUE)
```

You can also use the `status_check(error_if_unavailable = TRUE)` as a test to stop your script if one of the services is currently unavailable.

For more granular handling of connection errors, you can use `connection_check()` which simply returns a logical value to help you determine how to handle the connection.

## DAWA *will* be phased out

The government entity that maintains the Danish Web Address API has disclosed that the API will be phased out at some point. When that time comes, this package will become deprecated and I will have another package ready to provide the same functionality. The service that is to replace DAWA is called Datafordeleren (The Data Distribution) and is in the works. Some functionality in relation to The Central Register of Buildings (BBR) has already been moved to the new service.

If you know how to read danish (or use machine-translation) you can keep yourself up to date on [this page](https://dataforsyningen.dk/data/4924).

But no worries! It does not sound like the shutdown of DAWA will happen anytime soon or without due notice. 
Any updates will be written below.

### Change history

- The Central Register of Buildings has been moved effective: 03-April-2024
