Does anybody knows how to write an API inside a Truffle application?
No, Truffle is not a framework for APIs.
It is a wrapper around a
smart-contract which enables the methods defined in
But you can.
Since it is like a node app, you can use any node.js modules to make it work as an API endpoint using
If you mean API's in the traditional sense then no. However Smart Contracts can be considered as services or APIs in themselves, and that's an increasingly common usage of it. Truffle/Mix/Embark are good frameworks for writing "API's" in that sense.