具有共享代码逻辑的不同REST API

I would like to design few different REST API, eg:

mobile.api.com - for mobile

client.api.com - for client side

admin.api.com - for admin side

However, these API might need to separate out to different server and using the reuse some code logic, since it is a same app, but process the output according different platforms.

My question is, how to make these different API to use the same code logic without duplicate the code if possible?

So far the solution I think of (hmm, not so suitable) is create a common API (where the same code logic sits here), each API will curl to this API (assume all server in same network)

EG: if request a user details (where it is a common for each these API), mobile.api.com or admin.api.com will curl to common.api.com to get the user details, like common.api.com/users/userA , then process the output.

I hope there is a better architecture or solutions for this.

Thanks

I think just get one framework for example Yii

just creating module applications

all basic login will be in default module and we will have main models controller and others and modules will extends this classes

and in .htaccess file we will write some redirections

it just my openion. it have other variants also . . .