🐶 Dog API by kinduff

The Dog API provides dog data as a service!

Dog breeds, groups, facts and pictures as a free JSON API

Hi, I'm kinduff. This is a free API with dog breeds, breed groups and facts. I've kept it running since 2016, mostly because people learning to code keep finding it useful. No key, no sign up, nothing to pay.

Zorba, an English mastiff, is the biggest dog ever recorded. He weighed 343 pounds and measured 8’ 3" from his nose to his tail. a fact this API served when you loaded the page

Right now it holds 283 breeds with their life spans and weights, 9 breed groups, 483 dog facts, and 2,354 pictures of dogs. It answers about 60,000 requests on an average day, from universities, bootcamps, home labs and a lot of people poking at it on a Saturday.

Try it

Nothing to install. Paste this into a terminal, or press the button and watch what comes back.

Terminal
curl -s "https://dogapi.dog/api/v2/facts?limit=1"
Try it
Runs against this site.

Dog facts API

That request is the facts endpoint. /api/v2/facts hands back a random dog fact each time, and ?limit= asks for up to five at once. There are 483 of them, so repeats take a while.

A dog image API in one tag

Pictures need even less than that. The image endpoint redirects straight to a file, so an img tag can point at it and nothing else is needed:

A dog, in one tag
<img src="https://dogapi.dog/api/v2/breeds/image">

No id means any dog. Add one — /api/v2/breeds/<id>/image — and you get that breed, which is where the pictures at the top of this page come from.

When you want the rest, the docs explain every endpoint, and the breeds pages let you browse all of them from the page.

If you're teaching with it

Go ahead — course, workshop, tutorial, video, paid or free. You don't need to ask me and you don't need to credit me, though I always like hearing about it.

A few things worth knowing before you put it in front of a class. There's no key, so nobody can leak one in a public repo or a screen share. It works straight from the browser, so fetch() in a static page or a CodePen is fine. The rate limit is 300 requests per minute per IP, which a whole room sharing one connection stays well under, and there's no monthly quota to run out of halfway through a lesson.

If it breaks in the middle of a class, email me at [email protected] and I'll look at it.

Things to build with it

In case you need somewhere to start: show a random fact and add a button that fetches another one. List every breed and filter them with a search box. Walk through the pages with page[number]. Pick a group and follow its breeds to fetch each one. Ask for a breed that doesn't exist and handle the 404 without breaking the page. Chart the life spans across a group and argue about what the numbers actually mean.

If you make something with it, send it over. Seeing what people build is the reason this is still online.

There's more on this, with exercises by level and starter code you can paste into a lesson, in Teaching with the Dog API.

3 pugs with glasses in front of a computer in an office, digital art

Questions I get

Is the Dog API free?

Yes. There's no paid plan and no monthly quota. It's mostly used for learning and for fun, and I've paid for it myself this long without it hurting. If you feel like helping with the bill, you can buy me a coffee.

Do I need an API key?

No, and I don't plan to require one. If that ever changes, whatever you've already built will keep working.

Does it work from the browser?

Yes. The API sends CORS headers that allow any origin, so fetch() from a static page, a CodePen or a local file works without a proxy.

How do I get a random dog picture?

Request https://dogapi.dog/api/v2/breeds/image. It redirects to a picture of a random dog, so you can use it as the src of an img tag directly.

What's the rate limit?

300 requests per minute per IP. A whole classroom sharing one connection stays well under it.

Which version should I use?

v2. I wrote v1 without following any standard and it doesn't grow well. v2 follows JSON:API and is where breeds, groups and anything new lives. v1 still answers, and I'm not going to switch it off, but it's deprecated.

Where's the Slack button?

I lost ownership of the Slack app to a policy change and couldn't get it back.

Is this the official dogapi.dog?

Yes. It's mine, kinduff, and I've run it since 2016. I like building silly things and putting them online. The code is on GitHub, MIT licensed, and pull requests are welcome.

Dog API - JSON API with information on dog breeds and fun facts | Product Hunt