mobdb_extract_datasets: Extract latest dataset information from search results

View source: R/utils-helpers.R

mobdb_extract_datasetsR Documentation

Extract latest dataset information from search results

Description

Helper function to extract dataset details from search results. The search endpoint includes a latest_dataset field with comprehensive information about the most recent dataset, including validation results.

Usage

mobdb_extract_datasets(results)

Arguments

results

A tibble returned by mobdb_search().

Value

A tibble with one row per feed, containing key dataset information:

  • id - Feed ID

  • dataset_id - Latest dataset ID

  • hosted_url - URL to download the latest validated dataset

  • downloaded_at - When the dataset was captured

  • hash - Dataset file hash

  • service_date_range_start - Start of service dates

  • service_date_range_end - End of service dates

  • total_error - Number of validation errors (if available)

  • total_warning - Number of validation warnings (if available)

  • Note: Report URLs (html_report, json_report) are only available when using mobdb_datasets(), not from search results

See Also

get_validation_report() to get full validation details with report URLs, mobdb_search() to search for feeds, mobdb_datasets() to get dataset information directly

Examples

# Create sample data matching mobdb_search() output with latest_dataset
sample_results <- tibble::tibble(
  id = "mdb-1",
  provider = "Sample Agency",
  latest_dataset = tibble::tibble(
    id = "mdb-1-202501010000",
    hosted_url = "https://example.com/dataset.zip",
    downloaded_at = "2025-01-01T00:00:00Z",
    hash = "abc123",
    service_date_range_start = "2025-01-01",
    service_date_range_end = "2025-12-31",
    agency_timezone = "America/Los_Angeles",
    validation_report = tibble::tibble(
      total_error = 0L,
      total_warning = 5L,
      total_info = 10L,
      url_html = "https://example.com/report.html",
      url_json = "https://example.com/report.json"
    )
  )
)

# Extract dataset information
mobdb_extract_datasets(sample_results)


# With real API data:
results <- mobdb_search("transit")
datasets <- mobdb_extract_datasets(results)


mobdb documentation built on Aug. 29, 2026, 1:07 a.m.