Can I write my own pool software by using bitcoin API? Theoretically speaking, if I know programming (C,C++,C# etc.) can I write my own mining pool software/server using only Bitcoin API or I need more information than that?

https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list
You can, of course! But you may start from some existing programs that do what you say, most are open source and well documented. And ask someone, it's very hard to do it on your own!