Code Monkey home page Code Monkey logo

dog-ceo-api's Introduction

Dog CEO API

Code Coverage CircleCI Code Style License: MIT Codacy Badge

Info

Examples

Stats

Screenshot of statistics page

Dependencies

  • php 8.1+
  • Symfony 6
  • modules
  • composer
  • run './bin/phpunit' for unit tests (composer dump-env test)
$ composer check-platform-reqs
Checking platform requirements for packages in the vendor dir
composer-plugin-api  2.3.0     success                                       
composer-runtime-api 2.2.2     success                                       
ext-ctype            8.1.12    success                                       
ext-dom              20031129  success                                       
ext-filter           8.1.12    success                                       
ext-iconv            8.1.12    success                                       
ext-json             8.1.12    success                                       
ext-libxml           8.1.12    success                                       
ext-mbstring         *         success provided by symfony/polyfill-mbstring 
ext-phar             8.1.12    success                                       
ext-tokenizer        8.1.12    success                                       
ext-xml              8.1.12    success                                       
ext-xmlwriter        8.1.12    success                                       
ext-yaml             2.2.2     success                                       
php                  8.1.12    success

Setup

  • Clone repo
  • composer install
  • cd public
  • php -S 127.0.0.1:6969

.env.local

DOG_CEO_CACHE_KEY="something-really-secure-lol"
DOG_CEO_LAMBDA_URI=https://example.execute-api.us-east-1.amazonaws.com/dev/

Cache clear:

$ curl -X GET http://127.0.0.1:8000/cache-clear -H 'auth-key: something-really-secure-lol'

Endpoints

/breeds/list/all

List all breed names including sub breeds.

/breeds/list/all/random

Get random breed including any sub breeds.

/breeds/list/all/random/10

Get 10 random breeds including any sub breeds.

/breeds/list

List all master breed names.

/breeds/list/random

Get single random master breed.

/breeds/list/random/10

Get 10 random master breeds.

/breed/{breed}/list

List sub breeds.

/breed/{breed}/list/random

List random sub breed.

/breed/{breed}/list/random/10

List 10 random sub breeds.

/breed/{breed}

Get master breed info (data is incomplete, see content folder).

/breed/{breed}/{breed2}

Get sub breed info (data is incomplete, see content folder).

/breeds/image/random

Random image from any breed.

/breeds/image/random/3

Get 3 random images from any breed (max. 50)

/breed/{breed}/images

Get all breed images.

/breed/{breed}/images/random

Get random image from a breed (and all its sub-breeds).

/breed/{breed}/images/random/4

Get 4 random images from a breed (and all its sub-breeds).

/breed/{breed}/{breed2}/images

Get all images from a sub breed.

/breed/{breed}/{breed2}/images/random

Get random image from a sub breed.

/breed/{breed}/{breed2}/images/random/5

Get 5 random images from a sub breed.

Beta/Unfinished Endpoints

These endpoints might change in the future...

Alt tags (beta)

https://dog.ceo/api/breeds/image/random/alt
https://dog.ceo/api/breeds/image/random/1/alt
https://dog.ceo/api/breeds/image/random/9/alt
https://dog.ceo/api/breed/hound/images/alt
https://dog.ceo/api/breed/hound/images/random/1/alt
https://dog.ceo/api/breed/hound/images/random/9/alt
https://dog.ceo/api/breed/hound/afghan/images/alt
https://dog.ceo/api/breed/hound/afghan/images/random/alt

XML Responses (beta, unfinished)

Add 'Content-Type' request header containing 'application/xml' to any endpoint.

dog-ceo-api's People

Contributors

dependabot[bot] avatar edc0der avatar elliottlandsborough avatar jigsawpieces avatar livelucky avatar mrbrunelli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dog-ceo-api's Issues

[Bug] Dropdown in Breed List is not Sorted.

Describe the bug.
if we navigate to dog-api/breeds-list in the dropdown the list of breeds should be sorted. but it is not.

Screenshot.
Screenshot from 2023-09-28 13-36-18

Fix
Sort the list of breeds when populating it.

A list of breeds with an object of information on each

I wanted to open this as a proposal in case anyone was interested in implementing, may give it a go myself if I have time!

Basically I've been looking for a solid API that could give me back some back data on all possible dog breeds and combinations and each breed is an object with some information.

For example a response could look like:

[
  {
      breed: "Cairn Terrier",
      average_height: 9,
      average_weight: 13,
      bred_for: "Bolting of otter, foxes, other vermin",
      image: "https://d17fnq9dkz9hgj.cloudfront.net/breed-uploads/2018/08/cairn-terrier-detail.jpg?bust=1535565423&width=355"
    },
    { some other dog object }
]

Just an idea I thought would be useful for the API to have!

Endpoint with array of dogs

Could we have an endpoint responding with an array of dog objects with their image src url on them, such as:

{
  "message": [
    { "breed": "affenpinscher", "src": "https://..." },
    { "breed": "pug", "src": "https://..." },
    { "breed": "french bulldog", "src": "https://..." },
    { "breed": "pug", "src": "https://..." }
  ],
  "status": "success"
}

For mocking purposes, 5 or 10 items at a time would be enough for mocking purposes (as I understand, hosting data consumption could be of concern here).

Add endpoint "/breed/{breed}/images/random/{number}"

Hey guys,

First of all, just wanna say that I love this API. I had a lot of fun building small projects using it.

I think we should add this endpoint "/breed/{breed}/images/random/{number}". To me, it seems like a common functionality. Hope somebody can make this happen. Thanks!!

OpenAPI definition file

I love this project, its so amazing. Would you mind if I helped create an OpenAPI definition for your endpoints?

Getting 503

Randomly get status 503 -- Service unavailable

404 Errors don't have CORS headers

If you ping an invalid URL, you don't get a 404, you get a CORS error.

fetch('https://dog.ceo/api/breeds/list/x')
  .then(res => res.json())
  .then(data =>console.log(data));;

Its better if it has an simple text for random dog images

It's better if there is an endpoint where if we request we can get the image URL only. I know there is an endpoint for that but it returns a JSON response. But it would be better a simple text response with just the URL of the image returned.

--
Naveen

Issue with fetching pictures

I tried to make a call to the dalmatian pictures and it says it's there on your website, but I cannot retrieve it.

[Feature] Add autocomplete in dropdown list.

Describe the feature
when selecting breeds from dropdown Breeds List it would be better if there is an auto complete or search bar there so that it can be more user interactive.

Screenshot
Screenshot from 2023-09-28 13-36-18

Fix
Add an auto completer/searchable in the dropdown.

cookie warning

When fetching from the api with JS, the following message is displayed inside chrome console:

A cookie associated with a cross-site resource at http://dog.ceo/ was set without the SameSite attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with SameSite=None and Secure. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.

I could not find any way to resolve this from javascript. Here is a simple example code where this issue occurs.

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Test</title>
</head>
<body>
<div id="content"></div>
<script>
async function getResults(dogbreed) {
  const response = await fetch(`https://dog.ceo/api/breed/${dogbreed}/images`);
  const data = await response.json();
  const image = document.createElement('img');
  image.src = data.message[Math.floor(Math.random() * data.message.length)];
  document.querySelector('#content').appendChild(image);
}
getResults('papillon');
</script>
</body>
</html>

Is this something that can be resolved from the backend?

Some dog images are inaccessible

Sometimes, even though the API returns status === "success", the URL is inaccessible for some reason. A good solution would be a script that periodically checks the entire database and filters out inaccessible images.

Server error

I got server error when fetching from "https://dog.ceo/api/breeds/image/random".

{
"status": "error",
"message": "Server error: GET https:\/\/api.dog.ceo\/breeds\/list\/all resulted in a 502 Bad Gateway response:\n{"message": "Internal server error"}\n with code: 502",
"code": 500
}

Is this a temporary break down?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.