Sacred Games is based on the novel by Vikram Chandra by the same name. However, the entire novel isn't adopted into this show, but first quarter of the book.
From Express article,
Sacred Games is based on Vikram Chandra’s critically acclaimed 2006 novel of the same name.
The novel is 1000 pages long and it is thought the first season is based on approximately the first quarter of the book.
From the same article,
Sacred Games is not a real story, however, the book and Netflix series combine fiction with true historical events and Hindu mythology.
Though, this is not based on a real story, but it is combined with true historical events and Hindu mythology.
The true historical events shown in the show are Shah Bano case, Babri Mosque case, the Mandal Commission case, Legal Sterilization Scheme, and the Bofors scam. But these are only used to show how these events affect lives of common men in India despite what people in power say.