Support Support Home » APIs » XiAPI


xiAPI stands for XIMEA Application Programming Interface.
It is a new common interface for all XIMEA cameras, and represents a simplified version of generic M3API.


xiAPI Manual
xiAPI Camera Trigger and Synchronization Signals
xiAPI Image Data Flow
Sample code


API is a software interface between the camera system driver and application.

  • On Windows: xiAPI is compiled into xiapi32.dll or xiapi64.dll
  • On Linux: xiAPI is compiled into /usr/lib/libm3api.so


It is possible to enumerate all cameras from multiple processes. It is possible to use xiGetParamInfoString to obtain SN, User_ID or Model name from any process or thread.
The camera can be opened only once by xiOpenDevice. If camera is opened by one process or thread - other processes can't open this camera until previous process closes the handle by xiCloseDevice.


It is possible to use the same handle returned by xiOpenDevice of one camera from multiple threads within one process.
It is suggested:
  • to have one Acquisition thread (calling xiGetImage)
  • to have other Main Control Thread (calling xiGetParam, xiSetParam)
  • to close acquisition thread before the acquisition is stopped by Main Control Thread.



Here follows a sample code which captures one raw image data from the sensor without any post-processing.
Exposure time is set 10 ms.

#include "..\include\xiApi.h" 
#include <memory.h>
#define HandleResult(res,place) if (res!=XI_OK) {printf("Error after %s (%d)",place,res);goto finish;}


// image buffer
XI_IMG image;
image.size = sizeof(XI_IMG);

// Retrieving a handle to the camera device 
stat = xiOpenDevice(0, &xiH);

// Setting Exposure Time parameter (10ms)
stat = xiSetParamInt(xiH, XI_PRM_EXPOSURE, 10000); // microseconds
HandleResult(stat,"xiSetParam (exposure time set)");

// Note:
// The default parameters of each camera might be different
// in different API versions, please set all parameters
// expected by your application to required value.

// Start acquisition
stat = xiStartAcquisition(xiH);

// getting image from camera
stat = xiGetImage(xiH, 1000, &image);

printf("OK - Got one image (%dx%d) from camera\n", image.width, image.height);

// Close device
if (xiH) xiCloseDevice(xiH);

XIMEA API Sample With Start Stop Acquisition


The core of xiAPI are the following 6 functions, which allow to control most of the camera functionality.

// open interface
XI_RETURN xiOpenDevice(IN DWORD DevId, OUT PHANDLE hDevice);

// set parameter
XI_RETURN xiSetParam(IN HANDLE hDevice, const char* prm, void* val, DWORD size, PRM_TYPE type);

// get parameter
XI_RETURN xiGetParam(IN HANDLE hDevice, const char* prm, void* val, DWORD * size, PRM_TYPE * type);

// start acquisition
XI_RETURN xiStartAcquisition(IN HANDLE hDevice);

// get next image from queue
XI_RETURN xiGetImage(IN HANDLE hDevice, IN DWORD timeout_ms, OUT LPXI_IMG img);

// close interface
XI_RETURN xiCloseDevice(IN HANDLE hDevice);

Offline Processing

xiAPI allows to process already captured and stored images using Offline Processing. Please read more at xiAPI Offline Processing.