Skip to contents

Transforms a raw USAspending API response into a tibble format with additional metadata preserved as attributes. This method handles the conversion of API-specific data structures while maintaining important context from the original response.

Usage

# S3 method for class 'usasp_raw_response'
as_tibble(x, ..., flatten = FALSE)

Arguments

x

An API response object of class 'usasp_response'

...

Additional arguments not used

flatten

Logical. If TRUE, attempts to flatten nested data structures into separate columns where possible. Complex nested structures may remain as list-columns if they cannot be flattened without data loss.

Value

A tibble of class 'usasp_tibble' containing:

  • Transformed API response data

  • Original endpoint information as an attribute

  • Pagination metadata if present

  • API messages if present

Note

This function serves as the primary method for converting raw API responses into a tabular format suitable for data analysis while preserving important metadata