The New York Times (thereafter NYT) has a pretty detailed explanation of their methodology.
First, the list does talk about retail sales (which is rather good news, but is not the case in other industries such as video games). Those figures are measured from a panel on which NYT does not say much, except that it's confidential and should be trusted, and is restricted to the US.
Rankings reflect unit sales reported on a confidential basis by vendors offering a wide range of general interest titles. Every week, thousands of diverse selling locations report their actual sales on hundreds of thousands of individual titles. The panel of reporting retailers is comprehensive and reflects sales in stores of all sizes and demographics across the United States.
In a list à la Prévert, we find out that those thousand of retailers include
national, regional and local chains; scores of online and multimedia entertainment retailers; supermarkets, university, gift and big-box department stores; and newsstands
and is opt-in based:
If you are a book retailer interested in reporting your store's weekly sales to The New York Times Best-Seller Lists, send a request here.
This is as much as we know on the data and its representativeness: we do not know much about the panel's exact size or composition. The fact that you can opt-in on it probably correlates it a bit too strongly with the lectorate of NYT.
Let's also note that editors that are nominated for appearance in the list should complete some requirements from NYT to appear in the actual, published list. Very little is known about those requirements, whether they include a financial participation, etc.
Publishers and vendors of all ranked titles must conform in a timely fashion to The New York Times Best-Seller Lists requirement to allow for examination and independent corroboration of their reported sales for that week
Despite those meager news on the overall obscurity of the process, three positive points should be noted about the process: NYT is very transparent about how significant it judges its ranking:
An asterisk (*) indicates that a book's sales are barely distinguishable from those of the book above.
It is transparent also about any distinguishable manipulation in figures:
When included, such bulk purchases appear with a dagger (†).
And the body is independent from the advertising department:
The New York Times Best Sellers are compiled and archived by The Best-Seller Lists Desk of The New York Times News Department, and are separate from the Culture, Advertising and Business sides of The New York Times Company.
TL;DR: You can trust The New York Times to know what they do, but hey, they won't tell us.