In basketball, is it legal to shoot and score directly from a throw in? I have seen people do it online, but I couldn't find any official rules that describe the legality of it in a real game.
I'm not sure you looked very hard :-) From the offical FIBA rules, Rule 17.3.1:
The player taking the throw-in shall not: [...] Cause the ball to enter the basket directly
In the NBA rules, this is covered by Rule 10, Section III:
A thrower-in shall not [...] throw the ball so that it enters the basket before touching anyone on the court