According to the documentation, under Filtering, you can filter your parameters by appending a specific option using double underscores. Since you're wanting to filter based on date_filed, the documentation says we can pass an OPTIONS request on the API endpoint and inspect the filters key in the response. In httr, this might look something like:
library(httr)
dockets <- "https://www.courtlistener.com/api/rest/v4/dockets/"
# Allows us to pass any arbitrary verb besides the usual suspects (e.g., GET, POST, etc.)
filter_options <- httr::VERB(
verb = "OPTIONS",
url = dockets
) |>
content() |>
purrr::pluck("filters", "date_filed", "lookup_types")|>
purrr::list_simplify()
# Print our options out
filter_options
[1] "exact" "gte" "gt" "lte" "lt" "range" "year" "month" "day"
So we can see that the options available to us include exact filtering, greater than or equal to (gte), greater than (gt), less than or equal to (lte), less than (lt), range, year, month and day. Range seems to best fit our purposes, so then our query parameters would instead look something like:
query_params <- list(
q = "defamation OR libel OR slander", # Search for relevant cases
date_filed__range = "2023-01-01,2024-01-01"
)
From here, we perform the request as before and the result returns only those docket items filed between January 1, 2023 and January 1, 2024:
data <- GET(url = dockets, query = query_params) |>
content() |>
purrr::pluck("results")
Hope that helps! Edit: I omitted the API key in the requests since I do not have one and Court Listener allows you to request data without one, but in your use case, if you want to avoid running into issues from throttling or rate-limiting, it's best to include your API key in the requests.