Chemical reactions can be broadly divided into two types: exothermic if they release heat energy, or endothermic if they absorb heat energy when they progress.
An exothermic reaction releases heat energy to the surroundings. When you light a stove, for example, the burning gas reacts with oxygen in the air and releases heat, in an exothermic reaction. The heat raises the temperature of the surrounding air and the pan on the stovetop.
An endothermic reaction absorbs heat energy from the surroundings when it progresses. If you put some sugar in a hot pan, it absorbs heat from the pan and eventually melts and begins to caramelise. The caramelisation reaction is endothermic — it absorbs heat from the pan as it progresses.
Caramelising sugar over a hot flame. The caramelisation reaction is endothermic.
Both reactions need a certain amount of heat to kick them off — you have to light the stove with a match, for example — but the difference is that overall, an exothermic reaction, such as one caused by burning gas, releases more heat than it takes in.
It’s important to understand that an endothermic reaction is not the same thing as the beans simply absorbing heat and getting hotter. If you heat a substance but no reaction takes place, its temperature increases. In this case, the energy the substance has absorbed persists in the form of heat energy, so no endothermy has taken place. The process is endothermic only when that heat energy is converted into a different form — for example, breaking chemical bonds in an endothermic reaction, or changing water molecules into steam.
Similarly, although the caramelisation reaction takes in heat, it doesn’t mean that the temperature is dropping overall. The caramelisation absorbs some of the heat from the burning gas but not all of it, so the temperature of the pan can continue to increase while the endothermic reaction takes place inside.