add json api for queries