Star Trek "facts" tend to come from a wide variety of sources.
I've listed them in the order of canonicity; e.g. how much weight they carry in the trek community.
Canon references;
1) The TV episodes and films themselves, as well as transcripts of the episodes.
1.5) The new IDW Ongoing Star Trek comic series, and film prequel comics and are all now considered to be canon sources of information
2) Original scripts (which may or may not mirror what actually happened on the show)
3) Interviews with the writers and producers, cast and crew.
4) Canon reference books such as the "TNG Technical Manual", "DS9 Technical Manual", and "Voyager Technical manual". These were originally written as reference manuals for potential script writers.
5) Non-canon reference books such as "Mr Scott's Guide To The Enterprise" and the "Starfleet Technical Manual". These were written by people closely associated with the show but may have been contradicted later. They're usually considered 'canon unless otherwise contradicted'.
6) Official novelisations of various episodes and films.
Non-canon references;
7) Deleted scenes
8) Officially licensed properties such as Star Trek Games, RPGs and Trek Comics
9) Expanded-Universe Star Trek books. Those written by those involved in the show (such as Bill Shatner, Jeri Taylor, Andrew Robinson and Armin Shimerman) are generally considered more worthwhile than those written by people with little or no involvement in the show itself.
10) Fan-made properties such as Star Trek: Phase II