What is the best way to write accent?

Hi, I'm trying my hands in writing a story in English as a non native English speaker, and I was hoping I could use accent to give distinction between various languages and ethnic in my fictional world not to mention a bit of flavor to my character. Unfortunately, other than American English and maybe Australian, I had very little experience with other accents outside of maybe a few movies or media I consume.

So far, I wrote them nonchalantly using only my guts as a guide, but this has its issue of reverting to American from time to time. Obviously, I wanted to be as accurate and authentic as I could, whilst being consistent. So my question is what is the best way of doing this? Is there a source for someone to learn about accent in detail?