Skip to content

An api to get information about cat breeds from CatAPI and to keep track of the most searched ones.

Notifications You must be signed in to change notification settings

sukcinitas/dc-cat-wiki-api

Repository files navigation

DC Cat Wiki Api

An api to get information about cat breeds from CatAPI and to keep track of the most searched ones. Complementary to dc-cat-wiki. You can find the application example here (it might take a little while for the server to wake up). Api can be tried here https://elemental-oil-tin.glitch.me/api/.


Built with

  • TypeScript
  • Express 4
  • Axios
APIs
  • CatAPI
Testing
  • Mocha & Chai
Linting
  • ESLint
Compiling
  • Babel 7

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

ORIGIN, API_KEY


Setup

  • Clone this repository - git clone https://github.com/sukcinitas/dc-cat-wiki-api.git, install dependencies cd dc-cat-wiki-api, npm install (you will need npm and node installed globally);

    • npm start - to run the app on localhost:8080
    • npm run dev - to run the app on localhost:8080 using nodemon
    • npm run lint - to lint
    • npm run test - to run tests
    • npm run build - to build

Endpoints

Note: in "development" mode unsuccessful responses have additional properties: error and stack.

URL & HTTP method Parameters | req body Response
/api/cats/ GET none Success response:
  • 200 { success: true, mostPopularBreeds: [CatBreedSearchedData]}
Error response:
  • 500 { success: false, message: 'Something went wrong!'}
CatBreedSearchedData
      {
        weight: {
          imperial: string,
          metric: string,
        }
        id: string,
        name: string,
        cfa_url: string,
        vetstreet_url: string,
        vcahospitals_url: string,
        temperament: string,
        origin: string,
        country_codes: string,
        country_code: string,
        description: string,
        life_span: string,
        indoor: number,
        lap: number,
        alt_names: string,
        adaptability: number,
        affection_level: number,
        child_friendly: number,
        dog_friendly: number,
        energy_level: number,
        grooming: number,
        health_issues: number,
        intelligence: number,
        shedding_level: number,
        social_needs: number,
        stranger_friendly: number,
        vocalisation: number,
        experimental: number,
        hairless: number,
        natural: number,
        rare: number,
        rex: number,
        suppressed_tail: number,
        short_legs: number,
        wikipedia_url: string,
        hypoallergenic: number,
        reference_image_id: string,
        image: {
          id?: string,
          url: string,
          width?: number,
          height?: number,
        },
        searched: number
      }
      
URL & HTTP method Parameters | req body Response
/api/cats/search GET Query parameters:
  • q string required
Success response:
  • 200 { success: true, searchList: [SearchedData]}
Error responses:
  • 400 { success: false, message: 'Parameter "q" is required for request!'} if recieves no q parameter
  • 500 { success: false, message: 'Something went wrong!'} if otherwise fails
SearchedData
        {
          id: string,
          name: string,
        }
        
URL & HTTP method Parameters | req body Response
/api/cats/images GET Query parameters:
  • breedId string required
  • limit integer optional
Success response:
  • 200 { success: true, catInfo: [CatBreedImageData]}
Error responses:
  • 400 { success: false, message: 'Parameter "breedId" is required for request!'} if recieves no breedId parameter
  • 500 { success: false, message: 'Something went wrong!'} if otherwise fails
CatBreedImageData
        {
          breeds: [
              weight: {
              imperial: string,
              metric: string,
            }
            id: string,
            name: string,
            cfa_url: string,
            vetstreet_url: string,
            vcahospitals_url: string,
            temperament: string,
            origin: string,
            country_codes: string,
            country_code: string,
            description: string,
            life_span: string,
            indoor: number,
            lap: number,
            alt_names: string,
            adaptability: number,
            affection_level: number,
            child_friendly: number,
            dog_friendly: number,
            energy_level: number,
            grooming: number,
            health_issues: number,
            intelligence: number,
            shedding_level: number,
            social_needs: number,
            stranger_friendly: number,
            vocalisation: number,
            experimental: number,
            hairless: number,
            natural: number,
            rare: number,
            rex: number,
            suppressed_tail: number,
            short_legs: number,
            wikipedia_url: string,
            hypoallergenic: number,
            reference_image_id: string,
          ],
          id: string,
          url: string,
          width: number,
          height: number
        }
        
URL & HTTP method Parameters | req body Response
/api/cats/breeds/:breedId GET none Success response:
  • 200 { success: true, catInfo: CatBreedImageData}
Error response:
  • 500 { success: false, message: 'Something went wrong!'}
CatBreedImageData
        {
          breeds: [
              weight: {
              imperial: string,
              metric: string,
            }
            id: string,
            name: string,
            cfa_url: string,
            vetstreet_url: string,
            vcahospitals_url: string,
            temperament: string,
            origin: string,
            country_codes: string,
            country_code: string,
            description: string,
            life_span: string,
            indoor: number,
            lap: number,
            alt_names: string,
            adaptability: number,
            affection_level: number,
            child_friendly: number,
            dog_friendly: number,
            energy_level: number,
            grooming: number,
            health_issues: number,
            intelligence: number,
            shedding_level: number,
            social_needs: number,
            stranger_friendly: number,
            vocalisation: number,
            experimental: number,
            hairless: number,
            natural: number,
            rare: number,
            rex: number,
            suppressed_tail: number,  
            short_legs: number,
            wikipedia_url: string,
            hypoallergenic: number,
            reference_image_id: string,
          ],
          id: string,
          url: string,
          width: number,
          height: number
        }
        

About

An api to get information about cat breeds from CatAPI and to keep track of the most searched ones.

Resources

Stars

Watchers

Forks