Coder Social home page Coder Social logo

pets_api's Introduction

Pets Api

This is an api that is used in Backend Mod 3 exercise for students to explore api tools including Postman and Faraday.

Versions

Rails 5.2.4.3

Ruby 2.5.3

Exercises

  1. Using Postman, try to get a successful response from each endpoint.

    • If you haven't installed Postman you can do so here
  2. Using Faraday, try to get a successful response from each endpoint.

    • Install the Faraday gem
    • Create a ruby file and require the Faraday library along with a debugger, such as pry
    • In this newly created Ruby file write requests for each endpoint, use your debugger to check the response body

Extra Challenge: Explore how to parse a JSON response here

Endpoints

Request GET https://pets-1.herokuapp.com/api/v1/pets

Example Response

[
  {
    "id": 1,
    "name": "Wile E.",
    "animal_type": "coyote",
    "age": 4,
    "created_at": "2020-05-05T14:41:55.013Z",
    "updated_at": "2020-05-05T14:41:55.013Z"
  },
  {
    "id": 2,
    "name": "Road Runner",
    "animal_type": "bird",
    "age": 1,
    "created_at": "2020-05-05T14:41:55.021Z",
    "updated_at": "2020-05-05T14:41:55.021Z"
  },
  {
    "id": 3,
    "name": "Tweety",
    "animal_type": "bird",
    "age": 15,
    "created_at": "2020-05-05T14:41:55.028Z",
    "updated_at": "2020-05-05T14:41:55.028Z"
  },
  {
    "id": 4,
    "name": "Sylvester",
    "animal_type": "cat",
    "age": 2,
    "created_at": "2020-05-05T14:41:55.037Z",
    "updated_at": "2020-05-05T14:41:55.037Z"
  }
]

Request GET https://pets-1.herokuapp.com/api/v1/pets/:id

Example Response

{
  "id": 1,
  "name": "Wile E.",
  "animal_type": "coyote",
  "age": 4,
  "created_at": "2020-05-05T14:41:55.013Z",
  "updated_at": "2020-05-05T14:41:55.013Z"
}

Request POST https://pets-1.herokuapp.com/api/v1/pets

Request Example with required body

  POST https://pets-1.herokuapp.com/pets
  body: {
          "name": "Bugs",
          "animal_type": "bunny",
          "age": 5
        }

Example Response

{
  "id": 5,
  "name": "Bugs",
  "animal_type": "bunny",
  "age": 5,
  "created_at": "2020-05-05T14:41:55.013Z",
  "updated_at": "2020-05-05T14:41:55.013Z"
}

Request DELETE https://pets-1.herokuapp.com/api/v1/pets/:id

Example Response 204 No Content

Request PUT https://pets-1.herokuapp.com/api/v1/pets/:id

Example Request with body

PUT https://pets-1.herokuapp.com/pets/3
body: {
        "age": 10
      }

Example Response

  {
    "id": 3,
    "name": "Tweety",
    "animal_type": "bird",
    "age": 10,
    "created_at": "2020-05-05T14:41:55.028Z",
    "updated_at": "2020-05-05T17:43:10.736Z"
  }

pets_api's People

Contributors

dionew1 avatar dependabot[bot] avatar

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.