Giter Club home page Giter Club logo

backend_api_1's Introduction

Intro:

https://api.softhouse.rocks
An API that implements jsonplaceholder post and users endpoints, backed by a mongo database.

The purpose for this API is educational and meant as a step between using jsonplaceholder in a UI and implementing your own API.

Posts

The HTTP Methods supported are:

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE

Paths should look like this:

/posts - List of posts
/posts/{postId} - Gets a specific post with Id

Method: GET

Example 1:

curl -i -H "Content-Type:application/json" http://api.softhouse.rocks/posts/1

Gets the information from the specified URI

The result will look like this:

{"_id":"5e806d9f42fbde006b6b9ecf","userId":1,"id":1,"title":"sunt aut facere repellat provident occaecati excepturi optio reprehenderit","body":"quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto","__v":0}

Example 2 with jq and {postId}:

curl http://api.softhouse.rocks/posts/1 | jq .

Gets the information in the specified URI and displays it in JSON format

The result will look like this:

  {
    "_id": "5e9ecdbd3c9c34a2d807ce9d",
    "id": 1,
    "__v": 0,
    "body": "string",
    "title": "string",
    "userId": 1
  }

Method: POST

Example 1:

curl -i -X POST -H "Content-Type:application/json" http://api.softhouse.rocks/posts -d '{"title":"Hi, World", "body":"Fresh as morning dew", "userId": "1"}' 

Posts the information you give to the Object

The result will look like this:

{"_id":"5e9eb17e09cee0002106f314","body":"Fresh as morning dew","title":"Hi, World","userId":1,"id":811,"__v":0}

Example 2 with jq:

{
  "_id": "5e9eadf3a8eb15002609e47b",
  "body": "Fresh as morning dew",
  "title": "Hi, World",
  "userId": 1,
  "id": 807,
  "__v": 0
}

Method: PUT

Example 1

curl -i -X PUT http://api.softhouse.rocks/posts/3 -H "Content-Type:application/json" -d  '{
  "body": "NewBody", "title": "NewTitle", "userId": "1337"}'

Replaces the information on the specified path, with the provided data

Result:

Status: 200 OK

Returns body with the old information, should look like this

{"_id":"5e9ed8353c9c34a2d807f465","id":3,"__v":0,"body":"OldBody","title":"OldTitle","userId":13}

With jq:

{
  "_id": "5ea14af48e9e2e7dc0da885c",
  "id": 3,
  "__v": 0,
  "body": "NewBody",
  "title": "NewTitle",
  "userId": 1337
}

Method: PATCH

Example:

curl -i -X PATCH http://api.softhouse.rocks/posts/3 -H "Content-Type:application/json" -d  '{
  "body": "newBody", "userId": "3"}'

Updates a part of the object on the specified path, depending on the provided data

Result:

Status: 200 OK

Returns body with the updated information

{"body": "newBody", "title": "oldTitle", userId": "3"}

Method: DELETE

Example:

curl -i -X DELETE http://api.softhouse.rocks/posts/1

Deletes an object or endpoint at the specified path

Result:

Status: 
200 OK - Path found, was deleted

204 No Content - Path not found, nothing changed

Users

The HTTP Methods supported are:

  • GET
  • POST
  • PUT - Must have specific user Id

Paths should look like this:

/users - List of users
/users/{userId} - Gets a specific user with users Id

Method: GET

Example 1:

curl -i -H "Content-Type:application/json" http://api.softhouse.rocks/users/1

Gets the information from the specified URI.

Result will look like this:

{"address":{"geo":{"lat":-37.3159,"lng":81.1496},"street":"Kulas Light","suite":"Apt. 556","city":"Gwenborough","zipcode":"92998-3874"},"_id":"5e806d9f42fbde006b6b9ec5","id":1,"name":"Leanne Graham","username":"Bret","email":"[email protected]","__v":0}

Example 2 with jq:

curl -X GET http://api.softhouse.rocks/users/1 | jq .<br>
{
  "address": {
    "geo": {
      "lat": -37.3159,
      "lng": 81.1496
    },
    "street": "Kulas Light",
    "suite": "Apt. 556",
    "city": "Gwenborough",
    "zipcode": "92998-3874"
  },
  "_id": "5e806d9f42fbde006b6b9ec5",
  "id": 1,
  "name": "Leanne Graham",
  "username": "Bret",
  "email": "[email protected]",
  "__v": 0
}

Gets the information in the specified URI and displays it in JSON format.

backend_api_1's People

Contributors

katalinapalma avatar antman94 avatar karwang94 avatar

Watchers

 avatar

Forkers

karwang94

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.