📡 API Reference

The BioBots REST API provides a unified endpoint for querying bioprinting statistics. All metrics, comparisons, and aggregations use a single URL pattern.

Overview

The API is built on ASP.NET Web API 2 and exposes a single parameterized endpoint that handles all metric queries. Data is loaded from a JSON file and cached in memory with automatic file-watch reload.

💡 Note: All queries return numeric values — integer counts for comparison queries, and numeric values for aggregation queries.

Base URL

http://localhost:{port}/api/prints

When running locally via Visual Studio, the port is assigned dynamically. Check the browser URL after launching with F5.

Endpoint

GET /api/prints/{metric}/{comparison}/{value}

Query print records by metric. Returns a count of matching records (for comparison operations) or a computed value (for aggregation functions).

Path Parameters

ParameterTypeDescription
metric string The metric to query. See Metrics below.
comparison string Comparison operator: greater, lesser, or equal
value number | string Numeric threshold, or aggregation function name (Maximum, Minimum, Average)

Response Codes

CodeDescription
200 OK Query executed successfully. Returns a numeric value.
400 Bad Request Unknown metric, invalid comparison operator, or non-numeric value.
404 Not Found No valid records in dataset after null filtering.

Metrics

11 metrics are available for querying, grouped by category:

Print Data

MetricTypeUnitDescription
livePercentdouble%Cell viability — percentage alive via live/dead imaging
deadPercentdouble%Cell mortality — percentage dead via live/dead imaging
elasticitydoublekPaStructural rigidity of the final print

Crosslinking

MetricTypeUnitDescription
cl_durationintmsPhotocrosslinking duration
cl_intensityint%Light intensity percentage

Pressure

MetricTypeUnitDescription
extruder1doublePressure of extruder 1 at print time
extruder2doublePressure of extruder 2 at print time

Resolution

MetricTypeUnitDescription
layerHeightdoublemmHeight per layer
layerNumintTotal number of layers

Metadata

MetricTypeUnitDescription
serialintBioBot 1 serial number
wellplateintWellplate type used (6, 12, 24, 48, 96)
Type matters: Integer metrics use exact equality comparison; double metrics use epsilon tolerance (1e-9) to handle IEEE 754 floating-point precision.

Comparison Queries

Comparison queries count how many print records satisfy the condition. The response is always an integer count.

OperatorMeaningExample
greater metric > value /api/prints/livePercent/greater/50 → count of prints with >50% viability
lesser metric < value /api/prints/deadPercent/lesser/20 → count of prints with <20% dead cells
equal metric ≈ value /api/prints/wellplate/equal/6 → count of 6-well plate prints

Aggregation Queries

Aggregation queries compute a single statistic across all records. Pass the function name as the value parameter. The comparison operator is ignored for aggregations.

Aggregation results are returned in O(1) time — statistics are pre-computed when the data file is loaded.

FunctionReturnsExample
Maximum Highest value across all records /api/prints/elasticity/greater/Maximum → max elasticity value
Minimum Lowest value across all records /api/prints/layerNum/greater/Minimum → min layer count
Average Arithmetic mean across all records /api/prints/livePercent/greater/Average → average cell viability
⚠️ Integer truncation: For integer metrics (serial, cl_duration, cl_intensity, layerNum, wellplate), Maximum and Minimum results are truncated to integers. Average always returns a double.

Response Format

Success (200 OK)

// Comparison: count of matching records
42

// Aggregation: computed value
87.53

Error (400 Bad Request)

{
  "Message": "Unknown metric: 'invalidName'. Valid metrics: serial, livePercent, deadPercent, elasticity, cl_duration, cl_intensity, extruder1, extruder2, layerHeight, layerNum, wellplate."
}

Examples

curl

# Count prints with >50% cell viability
curl http://localhost:5000/api/prints/livePercent/greater/50

# Get maximum layer count
curl http://localhost:5000/api/prints/layerNum/greater/Maximum

# Average elasticity
curl http://localhost:5000/api/prints/elasticity/greater/Average

# Count prints using 6-well plates
curl http://localhost:5000/api/prints/wellplate/equal/6

# Prints with crosslinking <10s
curl http://localhost:5000/api/prints/cl_duration/lesser/10000

JavaScript (fetch)

// Count prints with >50% viability
const count = await fetch('/api/prints/livePercent/greater/50')
  .then(r => r.json());
console.log(`${count} prints with >50% viability`);

// Get max elasticity
const maxElasticity = await fetch('/api/prints/elasticity/greater/Maximum')
  .then(r => r.json());
console.log(`Max elasticity: ${maxElasticity} kPa`);

C# (HttpClient)

using var client = new HttpClient { BaseAddress = new Uri("http://localhost:5000") };

// Count prints with >50% viability
var count = await client.GetFromJsonAsync<int>("/api/prints/livePercent/greater/50");

// Average elasticity
var avg = await client.GetFromJsonAsync<double>("/api/prints/elasticity/greater/Average");

Try It

Build a query URL interactively:

/api/prints/livePercent/greater/50