# Separate logic for API and Application

**URL:** <https://www.ruby-forum.com/t/separate-logic-for-api-and-application/140516>\
**Category:** Rails\
**Created:** [June 15, 2008, 3:33pm UTC](https://www.ruby-forum.com/t/separate-logic-for-api-and-application/140516 "2008-06-15T15:33:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ADADAD](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85e7bf/32.png) [@ADADAD](https://www.ruby-forum.com/u/ADADAD)\
**Post date:** [June 15, 2008, 3:33pm UTC](https://www.ruby-forum.com/t/separate-logic-for-api-and-application/140516/1 "2008-06-15T15:33:40Z")

</div>

Hello,

I am a strong believer of the value of REST , especially when it comes  
to  
being able to offer an API “for free”. Consolidating logic so that your  
web  
application and your API use the same service layer is certainly  
helpful.

The problem I face is being able to separate specific functions  
between  
the two. For example, when you log into the web app we generate a  
session  
for a dropdown list in the app. Obviously this is not needed for the  
API  
calls. This is just one of the examples where separation of logic has  
become tricky between the API and the WEb application.

How have people been handling using 1 common code base used for both  
API  
and Web app where these challenges come up?

Thx  
Adam
