Skip to content

Microservice and REST API for the Questions & Answers module of an ecommerce web application

Notifications You must be signed in to change notification settings

SDC-Madrone/atelier

Repository files navigation

atelier

Microservice and REST API for the Questions & Answers module of an ecommerce web application, built to handle high traffic. Maximum throughput of ~5,000 requests per second.

Authentication

To use this API, you must create a GitHub API Token and attach it in every request as an Authorization header.

Your token must be created with the following scopes: read:org, user, read:user, user:email, user:follow.

List questions

GET /qa/questions

Retrieves a list of questions for a particular product. This list does not include any reported questions.

Query parameters

Parameter Type Description
product_id integer Specifies the product for which to retrieve questions.
page integer Selects the page of results to return. Default 1.
count integer Specifies how many results per page to return. Default 5.

Sample response

Status: 200 OK

{
  "product_id": "5",
  "results": [
    {
      "question_id": 37,
      "question_body": "Why is this product cheaper here than other sites?",
      "question_date": "2018-10-18T00:00:00.000Z",
      "asker_name": "williamsmith",
      "question_helpfulness": 4,
      "reported": false,
      "answers": {
        "68": {
          "id": 68,
          "body": "We are selling it here without any markup from the middleman!",
          "date": "2018-08-18T00:00:00.000Z",
          "answerer_name": "Seller",
          "helpfulness": 4,
          "photos": []
          // ...
        }
      }
    },
    {
      "question_id": 38,
      "question_body": "How long does it last?",
      "question_date": "2019-06-28T00:00:00.000Z",
      "asker_name": "funnygirl",
      "question_helpfulness": 2,
      "reported": false,
      "answers": {
        "70": {
          "id": 70,
          "body": "Some of the seams started splitting the first time I wore it!",
          "date": "2019-11-28T00:00:00.000Z",
          "answerer_name": "sillyguy",
          "helpfulness": 6,
          "photos": []
        },
        "78": {
          "id": 78,
          "body": "9 lives",
          "date": "2019-11-12T00:00:00.000Z",
          "answerer_name": "iluvdogz",
          "helpfulness": 31,
          "photos": []
        }
      }
    }
    // ...
  ]
}

List answers

GET /qa/questions/:question_id/answers

Returns answers for a given question. This list does not include any reported answers.

Path parameters

Parameter Type Description
question_id integer Required ID of the question for wich answers are needed

Query parameters

Parameter Type Description
page integer Selects the page of results to return. Default 1.
count integer Specifies how many results per page to return. Default 5.

Sample response

Status: 200 OK

{
  "question": "1",
  "page": 0,
  "count": 5,
  "results": [
    {
      "answer_id": 8,
      "body": "What a great question!",
      "date": "2018-01-04T00:00:00.000Z",
      "answerer_name": "metslover",
      "helpfulness": 8,
      "photos": []
    },
    {
      "answer_id": 5,
      "body": "Something pretty durable but I can't be sure",
      "date": "2018-01-04T00:00:00.000Z",
      "answerer_name": "metslover",
      "helpfulness": 5,
      "photos": [
        {
          "id": 1,
          "url": "urlplaceholder/answer_5_photo_number_1.jpg"
        },
        {
          "id": 2,
          "url": "urlplaceholder/answer_5_photo_number_2.jpg"
        }
        // ...
      ]
    }
    // ...
  ]
}

Add question

POST /qa/questions

Adds a question for the given product

Body parameters

Parameter Type Description
body text Text of question being asked
name text Username for question asker
email text Email address for question asker
product_id integer Required ID of the Product for which the question is posted

Sample response

Status: 201 CREATED

Add answer

POST /qa/questions/:question_id/answers

Adds an answer for the given question

Path parameters

Parameter Type Description
question_id integer Required ID of the question to which to post the answer

Body Parameters

Parameter Type Description
body text Text of question being asked
name text Username for question asker
email text Email address for question asker
photos [ text ] An array of urls corresponding to images to display

Sample response

Status: 201 CREATED

Mark question as helpful

PUT /qa/questions/:question_id/helpful

Updates a question to show it was found helpful.

Path parameters

Parameter Type Description
question_id integer Required ID of the question to update

Sample response

Status: 204 NO CONTENT

Report question

PUT /qa/questions/:question_id/report

Updates a question to show it was reported. Note, this action does not delete the question, but the question will not be returned in the above GET request.

Path parameters

Parameter Type Description
question_id integer Required ID of the question to update

Sample response

Status: 204 NO CONTENT

Mark answer as helpful

PUT /qa/answers/:answer_id/helpful

Updates an answer to show it was found helpful.

Query parameters

Parameter Type Description
answer_id integer Required ID of the answer to update

Sample response

Status: 204 NO CONTENT

Report answer

PUT /qa/answers/:answer_id/report

Updates an answer to show it has been reported. Note, this action does not delete the answer, but the answer will not be returned in the above GET request.

Path parameters

Parameter Type Description
answer_id integer Required ID of the answer to update

Sample response

Status: 204 NO CONTENT

About

Microservice and REST API for the Questions & Answers module of an ecommerce web application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published