Docs  |  API Reference

API Reference

Query the Invert database programmatically using SQL. Authentication, available views, and example queries.

Open in full page

Tokens for Invert's external API are issued through Auth0. The same authentication flow applies to both the Core and DSP views.

Receive a token from Auth0

In order to get a valid token use the following command:

curl --request POST \
  --url https://invert.eu.auth0.com/oauth/token \
  --header 'content-type: application/json' \
  --data '{
    "client_id": "<CLIENT_ID>",
    "client_secret": "<CLIENT_SECRET>",
    "audience": "https://api.invertbio.com/",
    "grant_type": "client_credentials"
  }'

CLIENT_ID and CLIENT_SECRET will be shared with you separately. The token returned by Auth0 will be valid for 24 hours and will need to be sent along with each SQL request.

The response will look like this:

{
  "access_token": "<ACCESS_TOKEN>",
  "expires_in": 86400,
  "token_type": "Bearer"
}

Using the token

Include the token in the Authorization header of every request:

curl -H "Authorization: Bearer <ACCESS_TOKEN>" \
 -H "Content-Type: application/json" \
 -X POST \
 -d '{"statement": "SELECT * FROM v_bioprocesses LIMIT 1"}' \
 https://api.invertbio.com/external/v1/statements/

If the token is invalid or expired, the response will be:

{
  "message": "Unauthorized"
}

Get a new Auth0 token and retry.

Open in full page

The Core external API provides SQL access to bioprocess data in Invert. See Authentication for how to obtain an access token.

Available Views

v_bioprocesses

Note: parents of bioprocesses (aka experiments) have been moved to a separate table called experiments

curl -H "Authorization: Bearer <AUTH0_TOKEN>" \
 -H "Content-Type: application/json" \
 -X POST \
 -d '{"statement": "SELECT * FROM v_bioprocesses LIMIT 1"}' \
 https://api.invertbio.com/external/v1/statements/
Field NameTypeDescription
idStringUnique identifier for the bioprocess
external_idStringAn external identifier for the bioprocess
nameStringName of the bioprocess
parent_idString or nullIdentifier of the parent bioprocess, if this is a child process
scheduled_start_timestampString or nullScheduled start time (ISO 8601)
scheduled_end_timestampString or nullScheduled end time (ISO 8601)
start_timestampStringRecord start time (ISO 8601 with timezone)
run_start_timestampString or nullStart time of the bioprocess run
run_end_timestampString or nullEnd time of the bioprocess run
end_timestampStringRecord end time (ISO 8601 with timezone)
duration_msNumberDuration of the bioprocess in milliseconds
statusStringDraft / Requested / Scheduled / In-progress / Completed
qcObjectQuality control information: {status, failure_mode}
dataArrayList of data objects associated with the bioprocess
eventsArrayList of events associated with the bioprocess
induction_eventObject or nullInformation about the induction event
attachmentsArrayList of attachments
lineageObject or nullLineage information
last_updated_atStringTimestamp of the last update (ISO 8601)
Common Event Types

DbObservationEvent

FieldTypeDescription
noteStringTextual observation or comment

DbAdditionEvent

FieldTypeDescription
lot_numberString or nullLot number of the added material
reagent_nameString or nullName of the reagent added
addition_typeStringType of addition (e.g., "Reagent Bolus", "Feed Start", "Induction", "Inoculation")
volumeObject{unit: string, value: number}

DbRemovalEvent

FieldTypeDescription
volumeObject{unit: string, value: number}
lot_numberString or nullLot number associated with the removal
sample_nameString or nullName or identifier of the sample removed
removal_typeStringType of removal (e.g., "Sample", "Harvest")

DbBioprocessPhaseEvent

FieldTypeDescription
phaseStringName of the bioprocess phase (e.g., "growth", "production")
time_pointStringIndicator of the phase timing (e.g., "start", "end")

v_timeseries

curl -H "Authorization: Bearer <AUTH0_TOKEN>" \
 -H "Content-Type: application/json" \
 -X POST \
 -d '{"statement": "SELECT * FROM v_timeseries LIMIT 1"}' \
 https://api.invertbio.com/external/v1/statements/
Field NameTypeDescription
idStringUnique identifier for the timeseries
bioprocess_idStringIdentifier of the associated bioprocess
quantity_idStringIdentifier of the associated quantity
start_timestampStringStart time (ISO 8601 with timezone)
end_timestampStringEnd time (ISO 8601 with timezone)
duration_msNumberDuration in milliseconds
unitStringUnit of measurement
statisticsObjectStatistical summary (see below)
last_updated_atStringTimestamp of last update (ISO 8601)

statistics object:

FieldTypeDescription
maxNumber or nullMaximum value
minNumber or nullMinimum value
sumNumberSum of all values
lastNumber or nullLast value
countNumberNumber of data points
firstNumber or nullFirst value
arithmetic_meanNumber or nullAverage of all values
standard_deviationNumber or nullStandard deviation

v_timeseries_data

curl -H "Authorization: Bearer <AUTH0_TOKEN>" \
 -H "Content-Type: application/json" \
 -X POST \
 -d '{"statement": "SELECT * FROM v_timeseries_data LIMIT 1"}' \
 https://api.invertbio.com/external/v1/statements/
Field NameTypeDescription
idStringIdentifier of the timeseries this data point belongs to (ref to v_timeseries.id)
timestampStringTimestamp of the data point (ISO 8601)
valueNumber or nullThe recorded value at this timestamp
data_item_idString or nullOptional identifier for the specific data item

v_quantities

curl -H "Authorization: Bearer <AUTH0_TOKEN>" \
 -H "Content-Type: application/json" \
 -X POST \
 -d '{"statement": "SELECT * FROM v_quantities LIMIT 1"}' \
 https://api.invertbio.com/external/v1/statements/
Field NameTypeDescription
idStringUnique identifier
nameStringPrimary name of the quantity
alternative_namesArray of StringsList of alternative names
is_timeseriesBooleanWhether this quantity represents time series data
data_typeStringThe data type
default_unitStringThe default display unit
default_ingestion_unitStringThe default unit used when ingesting data
base_unitsObjectBase units object
molar_massNumber or nullThe molar mass, if applicable
notesString or nullAdditional notes
last_updated_atStringTimestamp of last update (ISO 8601)

v_formulas

curl -H "Authorization: Bearer <AUTH0_TOKEN>" \
 -H "Content-Type: application/json" \
 -X POST \
 -d '{"statement": "SELECT * FROM v_formulas LIMIT 1"}' \
 https://api.invertbio.com/external/v1/statements/
Field NameTypeDescription
idStringUnique identifier
nameStringName of the formula
formulaStringThe actual formula/calculation
log_scaleBooleanWhether to apply on a logarithmic scale
disable_interpolationBooleanWhether interpolation is disabled
default_unitString or nullDefault unit for the result
run_phaseString or nullPhase during which this formula is applicable
notesString or nullAdditional notes
stateStringCurrent state (e.g., "ready")
last_updated_atStringTimestamp of last update (ISO 8601)

Example formula types:

  1. Simple references: A, B
  2. Basic arithmetic: (A+B+C)/3, A+B
  3. More complex: (A*3)*B/100
  4. Time-based: time_derivative_hours(A), time_integral_hours(A*2)
  5. Advanced statistical: log_linear_regression(A)

v_formula_results

Field NameTypeDescription
idStringUnique identifier
formula_idStringIdentifier of the formula used
bioprocess_idStringIdentifier of the associated bioprocess
unitStringUnit of measurement
dataObject or nullSingle value result (if not a time series)
timeseriesObject or nullTime series data (if formula produces multiple values)
timeseries_start_timestampStringStart time of the time series
timeseries_offset_msNumberTime offset in milliseconds
timeseries_statistics_minNumberMinimum value
timeseries_statistics_maxNumberMaximum value
timeseries_statistics_arithmetic_meanNumberArithmetic mean
timeseries_statistics_standard_deviationNumberStandard deviation
timeseries_statistics_sumNumberSum of all values
timeseries_statistics_firstNumberFirst value
timeseries_statistics_lastNumberLast value
timeseries_statistics_countNumberNumber of data points
last_updated_atStringTimestamp of last update

When timeseries is not null: {data: Array<Number>, times_ms: Array<Number>}

v_archived_records

Field NameTypeDescription
record_idStringUnique identifier for the archived record
table_nameStringName of the source table
archived_atStringTimestamp of archival (ISO 8601)

v_experiments

Field NameTypeDescription
idStringUnique identifier
external_idStringAn external identifier
scheduled_start_timestampString or nullScheduled start time (ISO 8601)
scheduled_end_timestampString or nullScheduled end time (ISO 8601)
last_updated_atStringTimestamp of last update (ISO 8601)

Example Queries

Delta Loads

Request data produced after a given date:

curl -H "Authorization: Bearer <ACCESS_TOKEN>" \
 -H "Content-Type: application/json" \
 -X POST \
 -d '{"statement": "SELECT * FROM v_bioprocesses WHERE last_updated_at > '"'"'2024-07-29'"'"' LIMIT 1"}' \
 https://api.invertbio.com/external/v1/statements/

Get timeseries updated since a bioprocess was last updated:

curl -H "Authorization: Bearer <ACCESS_TOKEN>" \
 -H "Content-Type: application/json" \
 -X POST \
 -d '{"statement": "SELECT * FROM v_timeseries WHERE last_updated_at > (SELECT MAX(last_updated_at) FROM v_bioprocesses)"}' \
 https://api.invertbio.com/external/v1/statements/

View Joins

Get bioprocesses associated to a timeseries:

curl -H "Authorization: Bearer <ACCESS_TOKEN>" \
 -H "Content-Type: application/json" \
 -X POST \
 -d '{"statement": "SELECT t.*, b.* FROM v_timeseries t LEFT JOIN v_bioprocesses b ON t.bioprocess_id = b.id LIMIT 1"}' \
 https://api.invertbio.com/external/v1/statements/

Error States

Timeouts

Long running requests (>30 seconds) will be terminated and return a 504. Modify your query to reduce/chunk the amount of data.

SQL execution errors

No data returned:

{
  "data": [],
  "status": {
    "state": "success",
    "message": "Statement executed successfully, but returned no results."
  }
}

Non-existent view:

{
  "data": [],
  "status": {
    "state": "error",
    "message": "relation \"v_non_existent_view\" does not exist"
  }
}

Syntax errors: JSON decode error — be careful about use of single vs double quotation marks.

Unexpected exceptions

{
  "data": [],
  "status": {
    "state": "error",
    "message": "Error executing statement"
  }
}
Open in full page

The DSP external API provides SQL access to material streams, unit operations, and bioprocess data. See Authentication for how to obtain an access token.

Available Views (DSP)

The DSP API exposes all the same views as the upstream API (v_bioprocesses, v_timeseries, v_timeseries_data, v_quantities, v_formulas, v_formula_results, v_experiments), plus the following additional views:

v_material_streams

curl -H "Authorization: Bearer <AUTH0_TOKEN>" \
 -H "Content-Type: application/json" \
 -X POST \
 -d '{"statement": "SELECT * FROM v_material_streams LIMIT 1"}' \
 https://api.invertbio.com/external/v1/statements/
Field NameTypeDescription
idStringUnique identifier
nameStringName of the material stream
start_timestampString or nullStart time (ISO 8601)
end_timestampString or nullEnd time (ISO 8601)
unit_operation_idString or nullIdentifier of the associated unit operation
is_global_material_streamBooleantrue = data belonging to a unit operation; false = material stream data
dataArrayList of data objects
last_updated_atStringTimestamp of last update (ISO 8601)

v_unit_operations

curl -H "Authorization: Bearer <AUTH0_TOKEN>" \
 -H "Content-Type: application/json" \
 -X POST \
 -d '{"statement": "SELECT * FROM v_unit_operations LIMIT 1"}' \
 https://api.invertbio.com/external/v1/statements/
Field NameTypeDescription
idStringUnique identifier
external_idStringExternal identifier
nameStringName of the unit operation
experiment_idString or nullIdentifier of the associated experiment
run_start_timestampString or nullStart time of the run
run_end_timestampString or nullEnd time of the run
statusStringDraft / Requested / Scheduled / In-progress / Completed
qc_statusStringQuality control status
qc_failure_modeStringQuality control failure mode
unit_operation_type_idObject or nullIdentifier of the associated unit operation type
last_updated_atStringTimestamp of last update (ISO 8601)

v_unit_operation_types

curl -H "Authorization: Bearer <AUTH0_TOKEN>" \
 -H "Content-Type: application/json" \
 -X POST \
 -d '{"statement": "SELECT * FROM v_unit_operation_types LIMIT 1"}' \
 https://api.invertbio.com/external/v1/statements/
Field NameTypeDescription
idStringUnique identifier
nameStringName of the unit operation type
iconString or nullName of the icon
last_updated_atStringTimestamp of last update (ISO 8601)

Example Queries and Error States

Queries, delta load patterns, view joins, and error state handling are identical between the Core and DSP views. See Core views for details.