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

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?

1 Like

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.

image

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 (api.thedogapi.com) 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 https://api.thedogapi.com/v1/images/upload 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”: “https://live.staticflickr.com/65535/47698046842_78ef1be8b7_b.jpg”,
“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. - https://documenter.getpostman.com/view/5578104/RWgqUxxh

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 thedogapi.com 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.

Hello @Aden ,

I’m playing with Dog Api and have been very funny. My Suggestion is include a thumb url on body of Breeds Model, (Maybe the first image related or null ?) so we can have a preview of that breed without make an extra request.

I’m building an app that show the breeds and would be awesome to show the image thumb on a list, like pinterest or something.

Thanks for your project, its very well documented and fun !

Hi @Aden,

First I gotta say, love the api! Thanks!

I’ve implemented a python wrapper for thecatapi (catapi.py if you’re curious), and I have some questions on what a few parameters are for and feedback on the api at the moment.

Questions:
On docs.thecatapi.com/api-reference/breeds/breeds-list , what is the attach_breed parameter for? I couldn’t find anything on it.

What mime_types are available when searching for an image? How are the mime_types used? Do you have an example url that would show how to pass an array in for a parameter? Any attempts I’ve made at using mime_types have failed.

Feedback:
The image analysis data returned from /images/{image_id}/analysis doesn’t seem to match the example response shown. Rather than getting [image, labels, moderation labels, vendor, approved, rejected] attributes back, I get [image, labels, moderation labels, vendor, created at] without any approved/rejected status.

There’s a misspelling on images-search page in the docs, Iterate should only have one t.

Thanks again for the api!

Hi Aden,

When trying to get a specific image i don’t get the vote and favourite.
GET images/<IMG_ID>?image_id=<IMG_ID>&sub_id=<SUB_ID>

Atfer looking at the documentation, it appears that these properties are only returned if i’m the owner of the image, which i guess means that i uploaded it.

“If you are the owner then the full Image response will be present, and any Vote or Favourite matching your account & sub_id will be attached.”

Would it be possible to have these properties on the object event if i’m not the owner, like it’s already done on the route “GET /images/search” ?

Thanks !

Hey, just found your API! It’s cool, but I had a question:

If I have a list like this (attached image), I’d like to have an image of the breed to the left of the name.

Currently, the breed list doesn’t provide an image url.

Would it be possible to add one to the Breed model? Like a “cover photo”. I’d prefer not to make 50+ GET requests for an image for each list item :slight_smile:

Thanks!

34

Do I need API key to access any of the CAT API ? It seems endpoints - /images/search/ & /breeds is working without the key?

Hi @gpalanis,

Good question. You’re right, you don’t need an API to get data from most of the API endpoints.

The API key is only required to save data to the API, so that data stays with your Account - e.g. Votes, Favourites, Uploaded images etc.

You can then retrieve that data via the API using that same API key. Once i get time to turn on Analytics, you’ll be able to get your request counts using the key too.

All the best, Aden

Hello. I’ve ran into an issue today that I just can’t seem to fix by my own:
I am writing a python script that downloads pictures from this API.
It sends a GET request to https://api.thecatapi.com/v1/images/search, it then grabs the image URL, and tries to download it using wget.
The problem is that when I try to download it (via wget or urllib.requests), I always get HTTP Error 403: Forbidden, and the image isn’t downloaded.

I saw that someone was having the same issue here on this post, and they fixed it by adding a user agent, but it just doesn’t seem to work for me, no matter what user-agent i try to use.

Do you have any idea what could be causing this, or a pointer as to what I could do to possibly fix the issue?

Thank you

Interesting question @Kaiyazaki. My assumption is the same as yours - the user-agent isn’t being applied for some reason…

Here’s a quick Python example i’ve tested this morning. Let me know if it doesn’t work for you.


import requests
import shutil

api_response = requests.get("https://api.thecatapi.com/v1/images/search")

image_url = api_response.json()[0]['url']
image_filename = image_url[image_url.rfind("/")+1:]

headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'}

response = requests.get(image_url, headers=headers, stream=True)
with open(image_filename, 'wb') as out_file:
    shutil.copyfileobj(response.raw, out_file)
del response

Stepping through the code it:

  • makes a request for a random image from theCatApi
  • gets the URL of the image from the first element of the Array in the JSON response
  • gets the name of the file by splitting the URL on the ‘/’ character into an Array, and using the last element
  • defines a fake user-agent to use
  • requests the Image using the URL and the fake user-agent, with the stream parameter set to true
  • opens a new local file
  • saves the raw Image response to that file
  • cleans up the memory

Hope that helps, Aden

1 Like

Hello! This link: https://cdn2.thecatapi.com/images/dhu.jpg don’t return a cat image

Hello, I try write mobile app for on android. But if I send request I get in serponse ““message”:“Cannot read property ‘name’ of undefined”,“status”:500,“level”:“info”” what it does mean. I’m don’t understant. What I do not this way. Because in postman all queries work correctly. Help me please :slight_smile:
If you need code snipens for example i will send them. :’(

@rvyZ Please start a new thread, instead of hijacking this one. Include as many code samples as possible, and ensure your question pertains to the Cat API or the Dog API

@frexuz -this feature has just been released to both TheCatAPI and TheDogAPI.

Each “breed” in the ./breeds response now contains an “image” object - with a url to it’s picture.

Let me know if you have any issues.

All the best, Aden

Yay @Aden, awesome! :smiley:

1 Like