That API Guy's - API Forum

Questions / Feedback / Bugs for the Cat or Dog APIs?

That is a great question Stepan! I’ve updated the API to include the Image for each Favourite returned via /favourites.

You can see this in action over at the new website:
And look through the code for it:

Any other requests just let me know,

All the best, Aden

Hi Aden,

I’m trying to use your API (dog or cat) to generate some test material for a proof of concept. But I cannot use POST under any circumstances. Even using your Python code from the documentation does not work.

Can you please help me out. All I am getting is:
400 - Unexpected token a in JSON position 14

I have been able to use both API’s but with different code

DOG API Payload:
payload = ‘{“image_id”:“b54”, “value”:“b54”}’
This only works if by some odd chance i put in a value parameter in the JSON. Otherwise I get the message “missing “value” parameter”

CAT API Payload:
payload = ‘{“image_id”:“b54”}’

This one works without the value parameter.

Under no circumstances does your python code in the documentation work.

Sorry to hear that Vypeer,

I’ve just reviewed the /votes documentation and you’re right, there was a mistake in the example. I’ve added a couple more code examples and checked they work in Python.

Here’s an example Python script showing how to Up & Down vote which i’ve testing in 3.7


  • swap out “DEMO-API-KEY” for your own API Key,
  • save the code below into a file called ‘’
  • run it in the terminal/cmd with ‘python’
  • your should see something like…

Making an up-vote
Making an down-vote

Let me me know if you have any other issues, I’m always trying to refine the documentation.

import requests

print("Making an up-vote")

url = ""

# Escape the string charaters - "value":1 means vote up
payload = "{\n\t\"image_id\":\"asf2\",\n\t\"sub_id\": \"my-user-1234\",\n\t\"value\":1\n}"
headers = {
    'Content-Type': "application/json",
    'x-api-key': "DEMO-API-KEY"

response = requests.request("POST", url, data=payload, headers=headers)


print("Making an down-vote")

# Escape the string charaters - "value":0 means vote down
payload = "{\n\t\"image_id\":\"asf2\",\n\t\"sub_id\": \"my-user-1234\",\n\t\"value\":0\n}"
headers = {
    'Content-Type': "application/json",
    'x-api-key': "DEMO-API-KEY"

response = requests.request("POST", url, data=payload, headers=headers)


Thanks for this update.
The next question is, if one of my users (sub_id) does /images/search and gets a list of images I need to know if Image was already favourited by this user, now I can’t see how I can do that. It would be great to add a new field to Image object “favourite_id” which will contain a favourite_id if current user already favourited this image or can be empty if not. What do you think?

Great Question Stepan.

I’ve added both the ‘vote’ and ‘favourite’ objects that match the (account + ‘image_id’ + ‘sub_id’) key to every response from the ‘/images’ routes.

You can see it in action here:

Just Fav/Un-Fav to see the ‘favourite’ little heart icon on the Image added & removed, and Vote Up/ Vote Down, then refresh the page you’ll see the ‘vote’ thumb icon change.

This will work for the ‘/images’ ‘/images/:image_id’ and ‘/images/search’ routes.

Let me know if you need anything else to support your use-case.

1 Like

Is there any way to search for photos of a particular breed on the dog API?
This seems to be in place for the cat API, but not the dog API…

It would be nice to be able to do /breeds/:breed_id/images, or /search, and get image results of that dog breed.

Great question. There absolutely is, both APIs share the same codebase. I just need to update it to the latest version.

As you suggested you’ll be able to search for Dog images by breed in the same way as the Cats via /images/search?breed_id={}

Here’s a live example -

I expect this to be done early next week, once the new /breeds data for theCatApi is complete.

Here’s the Trello ticket to track it.

EDIT: Problem solved, original question below.! I just needed to add a user-agent header to my urllib.request. It’s still weird that the dog API doesn’t require this.

Hey Aden,

I’m trying to search for random cat pictures using your cat API with my Discord bot. Or, I have used it for a few months so far without any issues. Just recently I have noticed this weird issue where the API gives a 200 response code with requested data, as it should, but it also gives an 403 forbidden error as well. I used this as the request, found from the official docs: I also have my API key in the request headers, I even tried requesting a new one and using that but so far no luck.

So, I get a response from the API, but at the same time my request fails with 403 error code. I’m also using your dog API for the same purpose, and it works with pretty much identical code.

EDIT: Also, I’m trying to read the image as bytes for uploading the image directly to Discord. I’m using Python’s urllib.request.urlopen for this. I think this might cause the problem, but I’m using the same solution with the dog API and it’s working there properly.

Do you have any tips what might cause this?


Thanks for posting your issue @Troikku . Really interesting issue, haven’t been able to reproduce it yet, however i have a sneaky suspicion based on what you’ve said that it may be Cloudflare related.

I integrated Cloudflare as a new CDN a few days ago and am still working out the kinks. It’s cut the daily Cloudfront/S3 costs from ~$3 to ~$0.50 a day, but thrown complications into the stack which could be responsible for this odd occurrence

I’ll tweak the settings and let it run for another few days, after which I’ll rollback if there’s still any issues.

Thanks for your patience, and please do let me know if you see any other issues.

Hi Aden

I am creating App by thecatapi. Could I get the image size from the entry?

Could you add two properties, width and height in the Cat object?

Hi Aden,

Loving the cat and dog apis! Quick question on whether there is rate limiting for the REST calls.

Great suggestion, I’ve added it to the roadmap and aim to get to it in the next 2 weeks.

Here’s the ticket for updates:

Great question @chewwwwwwwwww, I try to let people use the API for as many different use-cases as possible. So while there’s no hard limit, there is a soft limit for behaviour flagged as malicious.

There’s plenty of apps using the API that have gone viral and sent massive spikes of traffic, all fine and handled without limits. However if it can’t realistically be attributed to this, of even someone infrequently load testing testing their app, then the rate-limiter could kick in.

For instance behaviour that looks like a DDOS attack, or even more basic patterns like 1000’s of request per second from the same IP without waiting for a response.

If you’re getting erroneously rate-limited (429 or 5XX response code depending on the use-case), then just send me an email with the details and i’ll have a look.

Hi Aden,

I checked that but I’m not getting a “favourite” object inside Image object returned by search, but the picture was already favourited by the user. Could you please check that and by the way update the models in documentation?

Hi Aden,

Recently I got hit with the following error

SSL_connect returned=1 errno=0 state=error: certificate verify failed

I realised that I’ve been hitting your APIs without an API key all along! I’ve tried to sign up for a free API but it’s giving me this error.


Thanks again for this great API and looking forward to the bug fix!

Thanks for the post @chewwwwwwwwww, looks like there was some issues with the SSL cert auto renewal.

Fixed the DNS issue, just waiting for AWS to renew the cert. Should be in the next hour or so. This will fix both the API and signup issues.

Will ping another update once it’s finished.

New cert for the Dog API ( has been approved, and service is back as normal.

Anything else just let me know.

Best, Aden

Hi Aden,

My team is looking to create an app that would involve image recognition of dog photos, and we were excited to find this api! However, we’re having trouble with the endpoint through your website.

We’re putting our API key in the header field x-api-key, checking the box next to Send requests directly from the browser (CORS must be enabled) in Settings, and for the body we’re putting:
“file”: “”,
“sub_id”: “EliasBichon”

However, upon clicking Send, it works on it for about 30 seconds and finally responds with:
“level”: “info”,
“message”: “Cannot read property ‘name’ of undefined”,
“status”: 500

What are we doing wrong? I’ve tried the images/search and it seems to be working fine, so I don’t think the server is down. I’ve also tried using Postman and it doesn’t seem to work either.

Interesting question.

The image/upload method expects an actual file, instead of a url to a file hosted elsewhere.

So quickest way is to download the file first, then use the upload method, either manually or building a little proxy script.

It’s a good feature suggestion though, so i’ll look at adding it as a core feature next week!

Best, Aden

n.b - the Postman collection has been updated to clarify the ‘file’ parameter - apologies, it was definitely not clear. -

Thanks Aden for the quick response! I think updating the documentation will certainly help prevent confusion in the future (although I did notice you only updated The Cat API but not The Dog API documentation, neither on Postman nor website).

Anyway I’ve now got everything working on Postman. Actually before I posted on this forum I did try using Postman to upload a file from my local machine, but I wasn’t able to get it to work. But after you posted the reply I tried troubleshooting again and it turned out the reason it wasn’t working was because I didn’t have TheDogAPI - live set as my environment.