The Batches API provides methods to list all batches and retrieve specific batch information.
Batch Struct
The Batch struct contains information about an RC batch:
#[derive( Debug , Clone , Serialize , Deserialize )]
pub struct Batch {
pub id : u32 ,
pub name : String ,
#[serde(default)]
pub short_name : Option < String >,
#[serde(default)]
pub alt_name : Option < String >,
#[serde(default)]
pub start_date : Option < String >,
#[serde(default)]
pub end_date : Option < String >,
}
Information about an RC batch. Unique identifier for the batch
Full batch name (e.g., “Summer 2, 2024”)
Short batch name (e.g., “S2’24”)
Batch start date (ISO 8601 format)
Batch end date (ISO 8601 format)
List All Batches
Retrieve a list of all RC batches.
/// List all batches
pub fn list_batches ( & self ) -> Result < Vec < Batch >> {
let url = self . build_url ( "/batches" );
let response = self . client . get ( & url ) . headers ( self . auth_headers ()) . send () ? ;
Self :: handle_response ( response )
}
list_batches
fn(&self) -> Result<Vec<Batch>>
List all batches. Returns: Result<Vec<Batch>>API Endpoint: GET /api/v1/batches
Example
use rc_api :: RcApiClient ;
let client = RcApiClient :: new ( token ) ? ;
let batches = client . list_batches () ? ;
println! ( "Total batches: {}" , batches . len ());
for batch in batches {
println! (
"Batch {}: {} ({})" ,
batch . id,
batch . name,
batch . short_name . unwrap_or_default ()
);
}
Example Output
Total batches: 150
Batch 1: Winter 1, 2024 (W1'24)
Batch 2: Winter 2, 2024 (W2'24)
Batch 3: Spring 1, 2024 (SP1'24)
Batch 4: Spring 2, 2024 (SP2'24)
...
Get Batch by ID
Retrieve a specific batch by its ID.
/// Get a batch by ID
pub fn get_batch ( & self , batch_id : u32 ) -> Result < Batch > {
let url = self . build_url ( & format! ( "/batches/{}" , batch_id ));
let response = self . client . get ( & url ) . headers ( self . auth_headers ()) . send () ? ;
Self :: handle_response ( response )
}
get_batch
fn(&self, u32) -> Result<Batch>
Get a batch by ID. Parameters:
batch_id (u32): The batch’s unique ID
Returns: Result<Batch>API Endpoint: GET /api/v1/batches/{batch_id}Errors: Returns RcApiError::NotFound if batch doesn’t exist
Example
let batch = client . get_batch ( 123 ) ? ;
println! ( "Batch: {}" , batch . name);
if let Some ( start ) = batch . start_date {
println! ( "Starts: {}" , start );
}
if let Some ( end ) = batch . end_date {
println! ( "Ends: {}" , end );
}
Working with Batch Data
Find Current Batches
use chrono :: Utc ;
let batches = client . list_batches () ? ;
let today = Utc :: now () . date_naive () . to_string ();
let current_batches : Vec < _ > = batches
. into_iter ()
. filter ( | b | {
if let ( Some ( start ), Some ( end )) = ( & b . start_date, & b . end_date) {
start <= & today && & today <= end
} else {
false
}
})
. collect ();
println! ( "Current batches: {}" , current_batches . len ());
Get Batch Members
Use the Profiles API with the batch_id parameter:
use rc_api :: ProfileSearchParams ;
let batch_id = 123 ;
let profiles = client . search_profiles ( ProfileSearchParams {
batch_id : Some ( batch_id ),
.. Default :: default ()
}) ? ;
println! ( "Batch {} has {} members" , batch_id , profiles . len ());
Display Batch Info
// From RC VCF Generator - extracting batch info from stints
let batch_info : Vec < String > = profile
. stints
. iter ()
. filter_map ( | stint | {
stint . batch . as_ref () . map ( | b | {
format! (
"Recurse {}" ,
b . short_name . clone () . unwrap_or ( b . name . clone ())
)
})
})
. collect ();
Deprecated: Get Batch People
The get_batch_people() method is deprecated. Use search_profiles() with the batch_id parameter instead.
/// Get people in a batch (deprecated - use search_profiles instead)
#[deprecated(note = "Use search_profiles with batch_id parameter instead" )]
pub fn get_batch_people ( & self , batch_id : u32 ) -> Result < Vec < Person >> {
let url = self . build_url ( & format! ( "/batches/{}/people" , batch_id ));
let response = self . client . get ( & url ) . headers ( self . auth_headers ()) . send () ? ;
Self :: handle_response ( response )
}
Migration Guide
Deprecated (Don't use)
Recommended
#[allow(deprecated)]
let people = client . get_batch_people ( 123 ) ? ;
Stint
Stints represent a person’s participation in a batch:
#[derive( Debug , Clone , Serialize , Deserialize )]
pub struct Stint {
pub id : u32 ,
#[serde(rename = "type" )]
pub stint_type : String ,
#[serde(default)]
pub title : Option < String >,
pub for_half_batch : bool ,
pub in_progress : bool ,
pub start_date : String ,
#[serde(default)]
pub end_date : Option < String >,
#[serde(default)]
pub batch : Option < Batch >,
}
A person’s stint (participation) in an RC batch. Type of stint (e.g., “retreat”, “batch”)
Stint title if applicable (e.g., “Resident”, “Facilitator”)
Whether this is a half-batch stint
Whether the stint is currently active
The associated batch information
Example: Working with Stints
let profile = client . get_profile_by_id ( 12345 ) ? ;
for stint in & profile . stints {
println! ( "Stint type: {}" , stint . stint_type);
if let Some ( batch ) = & stint . batch {
println! ( " Batch: {} (ID: {})" , batch . name, batch . id);
}
if stint . in_progress {
println! ( " Status: Currently active" );
}
if stint . for_half_batch {
println! ( " Duration: Half batch" );
}
}
Next Steps
Profiles Get batch members using Profiles API
Locations Search for batch locations
Error Handling Handle batch-related errors