Back to Claude Scientific Skills

Opentrons Python Protocol API v2 Reference

scientific-skills/opentrons-integration/references/api_reference.md

2.38.012.8 KB
Original Source

Opentrons Python Protocol API v2 Reference

Protocol Context Methods

Labware Management

MethodDescriptionReturns
load_labware(name, location, label=None, namespace=None, version=None)Load labware onto deckLabware object
load_adapter(name, location, namespace=None, version=None)Load adapter onto deckLabware object
load_labware_from_definition(definition, location, label=None)Load custom labware from JSONLabware object
load_labware_on_adapter(name, adapter, label=None)Load labware on adapterLabware object
load_labware_by_name(name, location, label=None, namespace=None, version=None)Alternative load methodLabware object
load_lid_stack(load_name, location, quantity=None)Load lid stack (Flex only)Labware object

Instrument Management

MethodDescriptionReturns
load_instrument(instrument_name, mount, tip_racks=None, replace=False)Load pipetteInstrumentContext

Module Management

MethodDescriptionReturns
load_module(module_name, location=None, configuration=None)Load hardware moduleModuleContext

Liquid Management

MethodDescriptionReturns
define_liquid(name, description=None, display_color=None)Define liquid typeLiquid object

Execution Control

MethodDescriptionReturns
pause(msg=None)Pause protocol executionNone
resume()Resume after pauseNone
delay(seconds=0, minutes=0, msg=None)Delay executionNone
comment(msg)Add comment to protocol logNone
home()Home all axesNone
set_rail_lights(on)Control rail lights (Flex only)None

Protocol Properties

PropertyDescriptionType
deckDeck layoutDeck object
fixed_trashFixed trash location (OT-2)TrashBin object
loaded_labwaresDictionary of loaded labwareDict
loaded_instrumentsDictionary of loaded instrumentsDict
loaded_modulesDictionary of loaded modulesDict
is_simulating()Check if protocol is simulatingBool
bundled_dataAccess to bundled data filesDict
paramsRuntime parametersParametersContext

Instrument Context (Pipette) Methods

Tip Management

MethodDescriptionReturns
pick_up_tip(location=None, presses=None, increment=None)Pick up tipInstrumentContext
drop_tip(location=None, home_after=True)Drop tip in trashInstrumentContext
return_tip(home_after=True)Return tip to rackInstrumentContext
reset_tipracks()Reset tip trackingNone

Liquid Handling - Basic

MethodDescriptionReturns
aspirate(volume=None, location=None, rate=1.0)Aspirate liquidInstrumentContext
dispense(volume=None, location=None, rate=1.0, push_out=None)Dispense liquidInstrumentContext
blow_out(location=None)Expel remaining liquidInstrumentContext
touch_tip(location=None, radius=1.0, v_offset=-1.0, speed=60.0)Remove droplets from tipInstrumentContext
mix(repetitions=1, volume=None, location=None, rate=1.0)Mix liquidInstrumentContext
air_gap(volume=None, height=None)Create air gapInstrumentContext

Liquid Handling - Complex

MethodDescriptionReturns
transfer(volume, source, dest, **kwargs)Transfer liquidInstrumentContext
distribute(volume, source, dest, **kwargs)Distribute from one to manyInstrumentContext
consolidate(volume, source, dest, **kwargs)Consolidate from many to oneInstrumentContext

transfer(), distribute(), consolidate() kwargs:

  • new_tip: 'always', 'once', or 'never'
  • trash: True/False - trash tips after use
  • touch_tip: True/False - touch tip after aspirate/dispense
  • blow_out: True/False - blow out after dispense
  • mix_before: (repetitions, volume) tuple
  • mix_after: (repetitions, volume) tuple
  • disposal_volume: Extra volume for contamination prevention
  • carryover: True/False - enable multi-transfer for large volumes
  • gradient: (start_concentration, end_concentration) for gradients

Movement and Positioning

MethodDescriptionReturns
move_to(location, force_direct=False, minimum_z_height=None, speed=None)Move to locationInstrumentContext
home()Home pipette axesNone

Pipette Properties

PropertyDescriptionType
default_speedDefault movement speedFloat
min_volumeMinimum pipette volumeFloat
max_volumeMaximum pipette volumeFloat
current_volumeCurrent volume in tipFloat
has_tipCheck if tip is attachedBool
namePipette nameString
modelPipette modelString
mountMount locationString
channelsNumber of channelsInt
tip_racksAssociated tip racksList
trash_containerTrash locationTrashBin object
starting_tipStarting tip for protocolWell object
flow_rateFlow rate settingsFlowRates object

Flow Rate Properties

Access via pipette.flow_rate:

PropertyDescriptionUnits
aspirateAspirate flow rateµL/s
dispenseDispense flow rateµL/s
blow_outBlow out flow rateµL/s

Labware Methods

Well Access

MethodDescriptionReturns
wells()Get all wellsList[Well]
wells_by_name()Get wells dictionaryDict[str, Well]
rows()Get wells by rowList[List[Well]]
columns()Get wells by columnList[List[Well]]
rows_by_name()Get rows dictionaryDict[str, List[Well]]
columns_by_name()Get columns dictionaryDict[str, List[Well]]

Labware Properties

PropertyDescriptionType
nameLabware nameString
parentParent locationLocation object
quirksLabware quirks listList
magdeck_engage_heightMagnetic module heightFloat
uriLabware URIString
calibrated_offsetCalibration offsetPoint

Well Methods and Properties

Liquid Operations

MethodDescriptionReturns
load_liquid(liquid, volume)Load liquid into wellNone
load_empty()Mark well as emptyNone
from_center_cartesian(x, y, z)Get location from centerLocation

Location Methods

MethodDescriptionReturns
top(z=0)Get location at top of wellLocation
bottom(z=0)Get location at bottom of wellLocation
center()Get location at center of wellLocation

Well Properties

PropertyDescriptionType
diameterWell diameter (circular)Float
lengthWell length (rectangular)Float
widthWell width (rectangular)Float
depthWell depthFloat
max_volumeMaximum volumeFloat
display_nameDisplay nameString
has_tipCheck if tip presentBool

Module Contexts

Temperature Module

MethodDescriptionReturns
set_temperature(celsius)Set target temperatureNone
await_temperature(celsius)Wait for temperatureNone
deactivate()Turn off temperature controlNone
load_labware(name, label=None, namespace=None, version=None)Load labware on moduleLabware

Properties:

  • temperature: Current temperature (°C)
  • target: Target temperature (°C)
  • status: 'idle', 'holding', 'cooling', or 'heating'
  • labware: Loaded labware

Magnetic Module

MethodDescriptionReturns
engage(height_from_base=None, offset=None, height=None)Engage magnetsNone
disengage()Disengage magnetsNone
load_labware(name, label=None, namespace=None, version=None)Load labware on moduleLabware

Properties:

  • status: 'engaged' or 'disengaged'
  • labware: Loaded labware

Heater-Shaker Module

MethodDescriptionReturns
set_target_temperature(celsius)Set heater targetNone
wait_for_temperature()Wait for temperatureNone
set_and_wait_for_temperature(celsius)Set and waitNone
deactivate_heater()Turn off heaterNone
set_and_wait_for_shake_speed(rpm)Set shake speedNone
deactivate_shaker()Turn off shakerNone
open_labware_latch()Open latchNone
close_labware_latch()Close latchNone
load_labware(name, label=None, namespace=None, version=None)Load labware on moduleLabware

Properties:

  • temperature: Current temperature (°C)
  • target_temperature: Target temperature (°C)
  • current_speed: Current shake speed (rpm)
  • target_speed: Target shake speed (rpm)
  • labware_latch_status: 'idle_open', 'idle_closed', 'opening', 'closing'
  • status: Module status
  • labware: Loaded labware

Thermocycler Module

MethodDescriptionReturns
open_lid()Open lidNone
close_lid()Close lidNone
set_lid_temperature(celsius)Set lid temperatureNone
deactivate_lid()Turn off lid heaterNone
set_block_temperature(temperature, hold_time_seconds=0, hold_time_minutes=0, ramp_rate=None, block_max_volume=None)Set block temperatureNone
deactivate_block()Turn off blockNone
execute_profile(steps, repetitions, block_max_volume=None)Run temperature profileNone
load_labware(name, label=None, namespace=None, version=None)Load labware on moduleLabware

Profile step format:

python
{'temperature': 95, 'hold_time_seconds': 30, 'hold_time_minutes': 0}

Properties:

  • block_temperature: Current block temperature (°C)
  • block_target_temperature: Target block temperature (°C)
  • lid_temperature: Current lid temperature (°C)
  • lid_target_temperature: Target lid temperature (°C)
  • lid_position: 'open', 'closed', 'in_between'
  • ramp_rate: Block temperature ramp rate (°C/s)
  • status: Module status
  • labware: Loaded labware

Absorbance Plate Reader Module

MethodDescriptionReturns
initialize(mode, wavelengths)Initialize readerNone
read(export_filename=None)Read plateDict
close_lid()Close lidNone
open_lid()Open lidNone
load_labware(name, label=None, namespace=None, version=None)Load labware on moduleLabware

Read modes:

  • 'single': Single wavelength
  • 'multi': Multiple wavelengths

Properties:

  • is_lid_on: Lid status
  • labware: Loaded labware

Common Labware API Names

Plates

  • corning_96_wellplate_360ul_flat
  • nest_96_wellplate_100ul_pcr_full_skirt
  • nest_96_wellplate_200ul_flat
  • biorad_96_wellplate_200ul_pcr
  • appliedbiosystems_384_wellplate_40ul

Reservoirs

  • nest_12_reservoir_15ml
  • nest_1_reservoir_195ml
  • usascientific_12_reservoir_22ml

Tip Racks

Flex:

  • opentrons_flex_96_tiprack_50ul
  • opentrons_flex_96_tiprack_200ul
  • opentrons_flex_96_tiprack_1000ul

OT-2:

  • opentrons_96_tiprack_20ul
  • opentrons_96_tiprack_300ul
  • opentrons_96_tiprack_1000ul

Tube Racks

  • opentrons_10_tuberack_falcon_4x50ml_6x15ml_conical
  • opentrons_24_tuberack_nest_1.5ml_snapcap
  • opentrons_24_tuberack_nest_1.5ml_screwcap
  • opentrons_15_tuberack_falcon_15ml_conical

Adapters

  • opentrons_flex_96_tiprack_adapter
  • opentrons_96_deep_well_adapter
  • opentrons_aluminum_flat_bottom_plate

Error Handling

Common exceptions:

  • OutOfTipsError: No tips available
  • LabwareNotLoadedError: Labware not loaded on deck
  • InvalidContainerError: Invalid labware specification
  • InstrumentNotLoadedError: Pipette not loaded
  • InvalidVolumeError: Volume out of range

Simulation and Debugging

Check simulation status:

python
if protocol.is_simulating():
    protocol.comment('Running in simulation')

Access bundled data files:

python
data_file = protocol.bundled_data['data.csv']
with open(data_file) as f:
    data = f.read()

Version Compatibility

API Level compatibility:

API LevelFeatures
2.19Latest features, Flex support
2.18Absorbance plate reader
2.17Liquid tracking improvements
2.16Flex 8-channel partial tip pickup
2.15Heater-Shaker Gen1
2.13Temperature Module Gen2
2.0-2.12Core OT-2 functionality

Always use the latest stable API version for new protocols.