pub struct SocrataClient { /* private fields */ }Expand description
A client for the Socrata Open Data API (SODA).
Implementations§
Source§impl SocrataClient
impl SocrataClient
Sourcepub fn new(base_url: &str, app_token: Option<String>) -> Self
pub fn new(base_url: &str, app_token: Option<String>) -> Self
Creates a new SocrataClient.
§Arguments
base_url- The base domain of the Socrata instance (e.g., “https://www.datos.gov.co”)app_token- Optional Socrata App Token for higher rate limits.
Sourcepub async fn fetch<T: DeserializeOwned>(
&self,
dataset_id: &str,
limit: u32,
offset: u32,
order: Option<&str>,
where_clause: Option<&str>,
) -> Result<Vec<T>, SocrataError>
pub async fn fetch<T: DeserializeOwned>( &self, dataset_id: &str, limit: u32, offset: u32, order: Option<&str>, where_clause: Option<&str>, ) -> Result<Vec<T>, SocrataError>
Fetch data from a specific dataset ID using SODA API.
§Arguments
dataset_id- The 4x4 ID of the dataset (e.g. “jbjy-vk9h”)limit- Number of records to returnoffset- Number of records to skiporder- SoQL order clause (e.g. “date DESC”)where_clause- Optional SoQL where clause
Sourcepub async fn get_all<T: DeserializeOwned>(
&self,
dataset_id: &str,
order: Option<&str>,
where_clause: Option<&str>,
) -> Result<Vec<T>, SocrataError>
pub async fn get_all<T: DeserializeOwned>( &self, dataset_id: &str, order: Option<&str>, where_clause: Option<&str>, ) -> Result<Vec<T>, SocrataError>
Fetch ALL data from a dataset, automatically paginating through results.
This method handles pagination internally and returns all records.
For very large datasets, consider using fetch() with explicit pagination.
§Arguments
dataset_id- The 4x4 ID of the datasetorder- Optional SoQL order clausewhere_clause- Optional SoQL where clause
Sourcepub async fn get_metadata(
&self,
dataset_id: &str,
) -> Result<DatasetMetadata, SocrataError>
pub async fn get_metadata( &self, dataset_id: &str, ) -> Result<DatasetMetadata, SocrataError>
Sourcepub async fn datasets(
&self,
limit: u32,
offset: u32,
) -> Result<Vec<CatalogResource>, SocrataError>
pub async fn datasets( &self, limit: u32, offset: u32, ) -> Result<Vec<CatalogResource>, SocrataError>
List all datasets in the domain.
Uses the Socrata Catalog API to discover available datasets.
§Arguments
limit- Maximum number of datasets to return (0 = all)offset- Number of datasets to skip
Auto Trait Implementations§
impl Freeze for SocrataClient
impl !RefUnwindSafe for SocrataClient
impl Send for SocrataClient
impl Sync for SocrataClient
impl Unpin for SocrataClient
impl !UnwindSafe for SocrataClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more