I am not confident whenever I try to code a new library or a service. I simply copy-paste, look at other samples in the coding repo, and complete my tasks. How can I be better at coding, without copy-pasting? How can I gain confidence in this?
First, I want to call out that it's not inherently bad to copy/paste, but it sounds like you're using that as a crutch to avoid a deeper understanding of how things work. I have a few suggestions:
Intentionally break things and understand how they break. Instead of calling the API in this order, can you do it in a different order? Can you explain the result of that change?
Land a low-effort code change quickly. Fix a spelling error, modify a comment, or add a unit test. Doing this is a confidence boost, and this gives you some direction around how to explore + test the codebase.