Skip to content

Implement REST API client adapter (vantage-api-client)#148

Open
romaninsh wants to merge 1 commit intomainfrom
api-client-support
Open

Implement REST API client adapter (vantage-api-client)#148
romaninsh wants to merge 1 commit intomainfrom
api-client-support

Conversation

@romaninsh
Copy link
Owner

@romaninsh romaninsh commented Mar 24, 2026

Adds vantage-api-client crate that implements TableSource for REST APIs using serde_json::Value directly — no custom type system needed, entities just use #[derive(Serialize, Deserialize)].

What's included

  • RestApi struct with base URL and Bearer auth support
  • TableSource impl that fetches paginated JSON ({"data": [...], "pagination": {...}})
  • Standalone test server (test-api-server) serving cities.csv via warp
  • Example with Country/City models demonstrating entity loading and reference traversal

Changes to existing crates

  • ReadableDataSet::get() now accepts impl Into<Self::Id> — so you can write table.get("Germany") instead of table.get(&"Germany".to_string())
  • Table::with_id_column() sets the ID field per-table (moved from data source level)
  • print_table() now takes &Table directly, fetches data async, and reads the id field from column flags to skip duplicate columns

Example usage

let countries = Country::api_table();
print_table(&countries).await?;

let argentina: Country = countries.get("Argentina").await?;
let cities = argentina.ref_cities(); // fetches /countries/Argentina/cities
print_table(&cities).await?;

let rosario: City = cities.get("Rosario").await?;
println!("population: {}", rosario.population);

@romaninsh romaninsh changed the title implement api client. Implement REST API client adapter (vantage-api-client) Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant