Buildings consume 72% of electricity in the U.S. and are a prime opportunity for software to improve sustainability and unlock new capabilities. Many commercial buildings have digital controls and extensive sensor networks that can be used to develop novel applications for saving energy, detecting faults, improving comfort, etc. However, buildings are custom designed, leading to differences in functionality, connectivity, controls and operation. As a result today's building applications are hard to write and non-portable. We present BAS, an application programming interface and runtime that addresses these issues using a fuzzy query API, a graph representation of building metadata and a hierarchical driver model for building components. We demonstrate and evaluate BAS by exploring three applications enabled by this architecture. Specifically, we focus on a class of applications that incorporate occupant feedback into building operation. We develop a personalized lighting control application that uses existing lighting hardware and saves over 50% of lighting energy. We also develop a ventilation optimization and a personal HVAC control application, demonstrating that BAS enables rapid development and scale for building applications.