Study of astrophysical transients with the MAGIC telescopes