diff --git a/DESCRIPTION b/DESCRIPTION
index 5fd965afdfc6eedeeb38a0dabcd94fe9b19937b1..1e57fc92dedbfb63b8a0f39fa10c832b114f48d7 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -17,3 +17,6 @@ Imports:
     urltools
 RoxygenNote: 7.1.1
 Roxygen: list(markdown = TRUE)
+Suggests: 
+    testthat (>= 3.0.0)
+Config/testthat/edition: 3
diff --git a/R/doApiQuery.R b/R/doApiQuery.R
index 2b61f459588afa5912b1e3d83769611c312f0ded..1b691b6c50d352b2538413fc58b5f9398d2b2907 100644
--- a/R/doApiQuery.R
+++ b/R/doApiQuery.R
@@ -86,6 +86,10 @@ doApiQuery <- function(api,
       }
     } else {
       l <- httr::content(resp, "parsed")
+      if (as.numeric(l$count) > 20000) {
+        stop("The request reach the API limitation of 20000 records.\n",
+             "Use filter arguments to reduce the number of records of your request.")
+      }
       data <- c(data, l$data)
       if (resp$status_code == 206) {
         query <- l$`next`
diff --git a/man/doApiQuery.Rd b/man/doApiQuery.Rd
index afd4a33b2ac3bb0ca019c57f37eaeeddf4220b2e..ee6c9e95989d922f908be0d960683e7ba9f42aec 100644
--- a/man/doApiQuery.Rd
+++ b/man/doApiQuery.Rd
@@ -38,7 +38,7 @@ Pagination of the queries is handled automatically and the returned \link{list}
 \details{
 The function \code{get_available_params} returns the list of available query parameters for a given operation in an API.
 
-The functions \verb{get_[api]_[operation]} call the function \code{doQueryApi} and convert the response in a convenient format for the user (\link{data.frame} or \link{tibble})
+The functions \verb{get_[api]_[operation]} call the function \code{doQueryApi} and convert the response in a convenient format for the user (\link{data.frame} or \link[tibble:tibble]{tibble::tibble})
 }
 \examples{
 # To get the available APIs in the package
diff --git a/tests/testthat.R b/tests/testthat.R
new file mode 100644
index 0000000000000000000000000000000000000000..510a4f1f4f16e36f6885f9c6a904252998a4f168
--- /dev/null
+++ b/tests/testthat.R
@@ -0,0 +1,4 @@
+library(testthat)
+library(hubeau)
+
+test_check("hubeau")
diff --git a/tests/testthat/test-doApiQuery.R b/tests/testthat/test-doApiQuery.R
new file mode 100644
index 0000000000000000000000000000000000000000..1508a2a52db0f15104142e822bd5b999f09f8e8f
--- /dev/null
+++ b/tests/testthat/test-doApiQuery.R
@@ -0,0 +1,4 @@
+test_that("A query of more than 20000 records", {
+  expect_error(doApiQuery("indicateurs_services", "communes", params = list()),
+               regexp = "The request reach the API limitation of 20000 records")
+})