Skip to contents

Perform full text search or use parameters to programamatically query your portal for content items.

Usage

search_items(
  query = NULL,
  filter = NULL,
  title = NULL,
  description = NULL,
  snippet = NULL,
  tags = NULL,
  owner = NULL,
  orgid = NULL,
  item_type = NULL,
  type_keywords = NULL,
  created = NULL,
  modified = NULL,
  categories = NULL,
  category_filters = NULL,
  sort_field = NULL,
  sort_order = NULL,
  count_fields = NULL,
  count_size = NULL,
  display_sublayers = FALSE,
  filter_logic = "and",
  bbox = NULL,
  page_size = 50,
  max_pages = Inf,
  .progress = TRUE,
  host = arc_host(),
  token = arc_token()
)

Arguments

query

a scalar character for free text search or a valid query string as defined by the REST API.

filter

a scalar character. If provided all other arguments except query are ignored.

title

optional character vector of content item titles.

description, snippet

optional scalar character of text to check for.

tags

optional character vector of tags to search for.

owner

optional character vector of owner usernames to search for.

orgid

optional character vector of organization IDs to search for.

item_type

optional character vector of content item types. Validated with item_type().

type_keywords

optional character vector of content tpye keywords. Validated with item_keyword().

created, modified

optional length two vector which must be coercible to a date time vector. Converted using as.POSIXct(). Returns only items within this range.

categories

optional character vector of up to 8 organization content categories.

category_filters

optional character vector of up to 3 category terms. Items that have matching categories are returned. Exclusive with categories.

sort_field

optional character vector of fields to sort by. Can sort by title, created, type, owner, modified, avgrating, numratings, numcomments, numviews, and scorecompleteness.

sort_order

optional string. One of either asc or desc for ascending or descending order respectively.

count_fields

optional character vector of up to 3 fields to count. Must be one of c("type", "access", "contentstatus", "categories").

count_size

optional integer determines the maximum number of field values to count for each counted field in count_fields. Maximum of 200.

display_sublayers

default FALSE. Returns feature layers inside of feature services.

filter_logic

default "and" must be one of c("and", "or", "not"). Determines if parameters

bbox

unimplemented.

page_size

a scalar integer between 1 and 100 indicating the number of responses per page.

max_pages

the maximum number of pages to fetch. By default fetches all pages.

.progress

default TRUE. Whether to display a progress bar for requests.

host

default "https://www.arcgis.com". The host of your ArcGIS Portal.

token

an object of class httr2_token as generated by auth_code() or related function

Value

a data.frame.

Details

[Experimental]

Search is quite nuanced and should be handled with care as you may get unexpected results.

  • Most arguments are passed as filter parameters to the API endpoint.

  • If multiple values are passed to an argument such as tags, the search will use an "OR" statement.

  • When multiple arguments are provided, for example tags, owner, and item_type, the search will use "AND" logic—i.e. results shown match the tags and owner and item_type.

    • Note: you can change this to "OR" behavior by setting filter_logic = "or"

  • If the filter argument is provided, all other arguments except query are ignored.

References

API Documentation

Examples

crime_items <- search_items(
  query = "crime",
  item_type = "Feature Service",
  max_pages = 1
)
crime_items
#> # A data frame: 50 × 46
#>    id      owner created             modified            guid  name  title type 
#>  * <chr>   <chr> <dttm>              <dttm>              <lgl> <chr> <chr> <chr>
#>  1 ea0cfe… Toro… 2023-03-28 15:02:39 2025-01-22 18:27:48 NA    Neig… Neig… Feat…
#>  2 0a239a… Toro… 2023-03-27 18:59:00 2025-08-06 14:01:27 NA    Majo… Majo… Feat…
#>  3 5e055d… JASo… 2023-04-04 17:36:59 2023-09-07 19:05:06 NA    NA    Sher… Feat…
#>  4 64691a… Temp… 2024-01-17 20:01:43 2024-01-17 20:04:45 NA    hate… Hate… Feat…
#>  5 7c2b78… JASo… 2023-04-04 17:49:30 2025-09-24 16:43:33 NA    NA    Sher… Feat…
#>  6 c749e3… open… 2024-02-23 19:36:34 2025-09-17 14:39:35 NA    NA    Crim… Feat…
#>  7 e0992d… balt… 2023-07-31 20:27:01 2025-01-22 21:21:01 NA    Part… Part… Feat…
#>  8 2cb53d… KASU… 2019-12-10 19:06:39 2019-12-10 19:14:27 NA    Viol… Viol… Feat…
#>  9 30644d… MyCi… 2025-03-14 14:55:06 2025-08-20 13:55:24 NA    HPD_… HPD … Feat…
#> 10 5dc4e6… iwat… 2023-06-23 22:07:21 2023-08-09 15:33:46 NA    NA    Prop… Feat…
#> # ℹ 40 more rows
#> # ℹ 38 more variables: typeKeywords <list>, description <chr>, tags <list>,
#> #   snippet <chr>, thumbnail <chr>, documentation <lgl>, extent <list>,
#> #   categories <list>, spatialReference <chr>, accessInformation <chr>,
#> #   classification <lgl>, licenseInfo <chr>, culture <chr>, properties <list>,
#> #   advancedSettings <lgl>, url <chr>, proxyFilter <lgl>, access <chr>,
#> #   size <int>, subInfo <int>, appCategories <list>, industries <list>, …