Feel free to post anything related to theCatAPI.com or theDogAPI.com - or any requests for upcoming Public service APIs
Other people can then post more info, or use it for future reference.
Feel free to email me personally at [email protected]
Feel free to post anything related to theCatAPI.com or theDogAPI.com - or any requests for upcoming Public service APIs
Other people can then post more info, or use it for future reference.
Feel free to email me personally at [email protected]
Hi Aden.
Iām trying to use a new API instead of old one. At this moment I stuck on getting favourites for specific user, my request looks like this:
@Headers(āContent-Type: application/jsonā)
@GET(āv1/favouritesā)
Call favourites(@Header(āx-api-keyā) String apiKey, @Query(āsub_idā) String sub_id);
Iām getting data back with list of image objects, but they donāt contain all necessary data as it was in legacy API. For example, there is no āurlā field, so I canāt display the favourite image itself. They contain only āidā, āuser_idā, "image_id, āsub_idā (why we need it if I passed it to the request already, they are the same) and ācrated_atā. Well, I probably can get the āurlā posting one more request with āimage_idā, but in this case if my user has 100 images favourited I have to make 100 additional requests, which is definitely a bad idea.
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: https://thecatapi.com
And look through the code for it: https://github.com/AdenForshaw/theCatAPI-website
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
Just:
Making an up-vote
{āmessageā:āSUCCESSā,āidā:36496}
Making an down-vote
{āmessageā:āSUCCESSā,āidā:36497}
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 = "https://api.thecatapi.com/v1/votes"
# 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(response.text)
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)
print(response.text)
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: https://thecatapi.com/?id=JdMcWHjhB&sub_id=stepan-test
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.
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={breed.id}
Hereās a live example - https://docs.thecatapi.com/example-by-breed
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. https://trello.com/c/6Rleanhr/90-release-new-codebase-to-thedogapicom
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: https://api.thecatapi.com/v1/images/search?limit=3&page=100&order=DESC. 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?
Troikku
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: https://trello.com/c/IeMsTD8Z/129-add-width-height-of-image-to-response
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 (api.thedogapi.com) has been approved, and service is back as normal.
Anything else just let me know.
Best, Aden