fix api for new db schema, add api filter function