use before_filters for api actions instead of ugly if elses
fix bugs in api controller, works great now