RcApiClient is a Rust client library for interacting with the Recurse Center API. It provides a type-safe, ergonomic interface for accessing profiles, batches, locations, hub visits, and other RC data.
Installation
Add the client to yourCargo.toml:
Basic Usage
Client Architecture
The API client is built on top ofreqwest and provides:
- Type-safe requests: All API responses are deserialized into strongly-typed structs
- Flexible authentication: Support for both bearer tokens and basic auth
- Automatic URL building: Constructs API URLs from the base URL and version
- Error handling: Custom error types for common API errors
- Blocking interface: Uses
reqwest::blockingfor synchronous operations
Base URL Configuration
By default, the client useshttps://www.recurse.com/api/v1 as the base URL. You can override this for testing:
src/rc_api.rs:9-10,378-410
Custom Base URL Example
Client Struct
The main API client structure.
Constructor Methods
Creates a new API client with bearer token authentication.Parameters:
access_token(String): Your RC personal access token
Result<RcApiClient, RcApiError>Creates a new API client with basic authentication.Parameters:
email(String): Your RC email addresspassword(String): Your RC password
Result<RcApiClient, RcApiError>Creates a new API client with custom authentication.Parameters:
auth(Authentication): Custom authentication enum
Result<RcApiClient, RcApiError>Sets a custom base URL for the client (useful for testing).Parameters:
base_url(String): Custom base URL (e.g., “https://test.recurse.com”)
RcApiClient (consumes self)Real-World Example
Here’s how the RC VCF Generator uses the client:src/main.rs:323-333
Next Steps
Authentication
Learn about authentication methods
Profiles API
Search and retrieve RC profiles
Error Handling
Handle API errors gracefully
Batches
Work with RC batches