How to create api-only rails app with normal rails new newapp?

can it be possible to create both functionality in one app?

Just pass —api or —minimal flag to rails new app command

By default, Rails is a full-stack application simply frontend + backend. When you are planning to develop a backend-only application, you can create it using –api flag.

The way your APIs are exposed will be the same for both the full-stack and API-only rails applications. So if you create a normal(full-stack) application, you can use it both ways.