diff --git a/Lua API.html b/Lua API.html
index 1a2888eb0..7d99228bf 100644
--- a/Lua API.html
+++ b/Lua API.html
@@ -1586,6 +1586,10 @@ are removed from extents. If allow_occupied, t
Checks if a bridge constructed at specified position would have
support from terrain, and thus won't collapse if retracted.
+dfhack.buildings.getStockpileContents(stockpile)
+Returns a list of items stored on the given stockpile.
+Ignores empty bins, barrels, and wheelbarrows assigned as storage and transport for that stockpile.
+
Low-level building creation functions;
diff --git a/Lua API.rst b/Lua API.rst
index 7283f196f..d770271ae 100644
--- a/Lua API.rst
+++ b/Lua API.rst
@@ -1394,6 +1394,11 @@ Buildings module
Checks if a bridge constructed at specified position would have
support from terrain, and thus won't collapse if retracted.
+* ``dfhack.buildings.getStockpileContents(stockpile)``
+
+ Returns a list of items stored on the given stockpile.
+ Ignores empty bins, barrels, and wheelbarrows assigned as storage and transport for that stockpile.
+
Low-level building creation functions;
* ``dfhack.buildings.allocInstance(pos, type, subtype, custom)``
diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp
index 3fd18a8d6..f2693363a 100644
--- a/library/LuaApi.cpp
+++ b/library/LuaApi.cpp
@@ -1744,11 +1744,20 @@ int buildings_setSize(lua_State *state)
}
+static int buildings_getStockpileContents(lua_State *state)
+{
+ std::vector pvec;
+ Buildings::getStockpileContents(Lua::CheckDFObject(state,1),&pvec);
+ Lua::PushVector(state, pvec);
+ return 1;
+}
+
static const luaL_Reg dfhack_buildings_funcs[] = {
{ "findAtTile", buildings_findAtTile },
{ "findCivzonesAt", buildings_findCivzonesAt },
{ "getCorrectSize", buildings_getCorrectSize },
{ "setSize", &Lua::CallWithCatchWrapper },
+ { "getStockpileContents", buildings_getStockpileContents},
{ NULL, NULL }
};