Getting latest candle

Hey. In my program I am trying to get the latest (fully formed) candle (of either crypto or stocks). I found that trying to do it with Historical data (5Min candles) comes with approximately a 20-30 second delay from the moment every 5th minute has closed, which is absolutely unacceptable.

Is there any other way to achieve this? And if yes please provide me with some sample code. Ideally I want to get the latest candle as soon as it has fully formed (maybe 1 second delay).

Thanks in advance.