Chapter 1. NAPI: The NeXus Application Programming Interface

Table of Contents

Purpose of API
Core API
C and C++ Interface
Fortran 77 Interface
Fortran 90 Interface
Java Interface
Python Interface
IDL Interface
Utility API
List of F90 Utility Routines
Building Programs
Reporting Bugs in the NeXus API

The Application Program Interface (API) has been developed to facilitate the reading and writing of NeXus files. Those writing applications to produce NeXus files are encouraged to use the API in order to ensure compliance with the NeXus standard. The API supports the reading and writing of HDF4, HDF5, and XML files. However, it is possible to create programs that write and/or read NeXus files without using the NAPI. Two examples are provided in Example NeXus programs using native HDF5 commands.

The core routines have been written in C but wrappers are available for a number of other languages including C++, Fortran 77, Fortran 90, Java, Python and IDL. The API makes the reading and writing of NeXus files transparent; the user doesn't even need to know the underlying format when reading a file since the API calls are the same.

More in-depth and up-to-date information about the NeXus Application Programming Interface for the various language backends is available on-line from NAPI doxygen documentation: http://download.nexusformat.org/

The (NeXusIntern.pdf[30]) document describes the internal workings of the NeXus-API. You are very welcome to read it, but it will not be of much use if all you want is to read and write files using the NAPI.

Purpose of API

The NeXus Application Program Interface call routines in the appropriate backend (HDF4, HDF5 or XML) to read and write files with the correct structure. The API serves a number of purposes:

  1. It simplifies the reading and writing of NeXus files.

  2. It ensures a certain degree of compliance with the NeXus standard.

  3. It hides the implementation details of the format. In particular, the API can read and write HDF4, HDF5, and XML files using the same routines.

Note

While it is possible to write NeXus compilant data files using a supported on-disk backend directly, we strongly encourage using the supported NeXus-API. This ensures the maximum compatibily.