You just used an API. You had already used one before you knew the word, which is the easiest way to learn it.
An API is a doorway a website leaves open on purpose, so that programs can ask it for something instead of people clicking around. A person visits a website and reads a page. A program visits an API and gets back plain facts it can use.
The website you asked is dog.ceo. It keeps a big pile of dog photos and it leaves one doorway open that means "give me a random one". That doorway is the address in your code. You did not ask a human. Your program asked their computer, and their computer answered in about a second.
What the answer actually looked like
The reply did not arrive as a picture. It arrived as a small piece of text, laid out in a shape called JSON, which is just a tidy way of writing facts so a program can find things in it: