I want to create an api that various clients can connect to it like Web, Mobile platforms etc. My problem is that sometimes things are different with each client. For example i use different method for authentication for Web and Mobile platforms and my question is: 

I have to create different files for each type of client or use if
  else statements to detect client type and do proper functions in the
  same class?

I want to create clean and standard API. I know this can have a lots of answers and its a broad question, But i just have a clue in this.
There is definitely not 'the one and only' way to create an API.
However, checking the type of client is definitely not the way to go, as it would mean checking headers, which can be forged when sending the request.
For authentication, if you want to use different methods, your best bet is probably to have different authentication strategies, and try them one after the other. If the first fail, you run the next, etc.
A common way to implement this is to add an authentication middleware, which tries each available strategy to authenticate the client, and stops the request if it could not.
This does mean that even if you want your strategy A to work only for the browser, it could also be used to login from a mobile app, but there is no way to prevent this, and anyway it should not lead to any security issue either. If it does, the issue is probably somewhere else.
Creating clean and standard API with different type of clients