This section describes the C API for Lua, that is, the set of C functions available to the host program to communicate with Lua. All API functions and related types and constants are declared in the header file lua.h

Even when we use the term "function", any facility in the API may be provided as a macro instead. All such macros use each of their arguments exactly once (except for the first argument, which is always a Lua state), and so do not generate any hidden side-effects.

As in most C libraries, the Lua API functions do not check their arguments for validity or consistency. However, you can change this behavior by compiling Lua with a proper definition for the macro luai_apicheck in file luaconf.h.


  1. The Stack
  2. Stack Size
  3. Pseudo-Indices
  4. C Closures
  5. Registry
  6. Error Handling in C
  7. Functions and Types
  8. The Debug Interface