How to add custom requirement in dream factory?

For example, I want to detect user’s IP ,How can I do in dream factory?
If I need run a script through api_doc,a script that we write before.

We don’t currently expose the user’s IP in session or any response for that matter , that I know of.
When I wrapped the DreamFactory Mobile App with Cordova, i used a plugin to grab that ip address along with the UUID.

But to answer your whole question, you can assign a script to the POST on /user/session to fire scripts when a user logs in.

If it means I could write a script that used in server to capture user’s ip or other infos.then fire it while some api_doc invoked?

Yes, when the user logs in and the API successfully returns a session call a server-side script that gets the IP address for that user ID.