Order Prediction API
The API gets the prediction of the order made. This is intended to be used by the Admins to monitor the performace and analyse the Statistics.
API Endpoint
The request is a GET request to the /api/predictions/orders endpoint.
Request Structure
GET /api/predictions/orders HTTP/1.1{data: {name: "<name>",email: "<email>",phone: "<phone_number>",address: "<home_address>",products: [{product_sku_id: "<sku_id>",amount: "<amount>",qty: "<quantity>"}],order_id: "<order_id>",total_amount: "<total_amount>",discount: "<discount>",total_qty: "<total_quantity>",refferral_code: "<refferral_code>",user_id: "<user_id>",subscript_points: true}}
Query
| Key | Required | Schema | Description |
|---|---|---|---|
| name | true | String | Name of the person |
| true | String | Email Id | |
| phone | false | String | Mobile Number |
| address | false | String | Location |
| products | true | JSON Value | Array of product details |
| order_id | true | String | Id of the order ordered |
| total_amount | true | Integer | Amount of the Order |
| discount | true | Integer | Discount offered |
| total_qty | false | Integer | Total quantity offered |
| refferral_code | true | String | Refferral Code for getting benefits |
| user_id | true | String | Unique ID offered to the user |
| subscript_points | false | Boolean | Subscript Points |
Sample Request
- cURL
- PHP-cUrl
- Node-Axios
- C#-RestSharp
- Python-http.client
- Java-OkHttp
- Go
- Ruby
- C
- PowerShell
curl --location --request GET 'localhost:8000/api/predictions/orders' --header 'token: U78FtRBfsMAnecq_q3i8J' --header 'Content-Type: application/json' --data-raw '{"data": {"name": "Abhay","phone": "7666804987","address": "address 1","products": [{"product_sku_id": "sku_9","amount": "25","qty": "1"},{"product_sku_id": "sku_10","amount": "35","qty": "1"},{"product_sku_id": "sku_13","amount": "33","qty": "1"},{"product_sku_id": "sku_14","amount": "105","qty": "6"}],"order_id": "ID88","total_amount": "215","discount": "15","total_qty": "9","refferral_code": "EV78G55H","user_id": "88","subscript_points": true}}'
<?php$curl = curl_init();curl_setopt_array($curl, array(CURLOPT_URL => 'localhost:8000/api/predictions/orders',CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => '',CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 0,CURLOPT_FOLLOWLOCATION => true,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => 'GET',CURLOPT_POSTFIELDS =>'{"data": {"name": "Abhay","email": "[email protected]","phone": "7666804987","address": "address 1","products": [{"product_sku_id": "sku_9","amount": "25","qty": "1"},{"product_sku_id": "sku_10","amount": "35","qty": "1"},{"product_sku_id": "sku_13","amount": "33","qty": "1"},{"product_sku_id": "sku_14","amount": "105","qty": "6"}],"order_id": "ID88","total_amount": "215","discount": "15","total_qty": "9","refferral_code": "EV78G55H","user_id": "88","subscript_points": true}}',CURLOPT_HTTPHEADER => array('token: U78FtRBfsMAnecq_q3i8J','Content-Type: application/json'),));$response = curl_exec($curl);curl_close($curl);echo $response;
var axios = require('axios');var data = JSON.stringify({"data": {"name": "Abhay","phone": "7666804987","address": "address 1","products": [{"product_sku_id": "sku_9","amount": "25","qty": "1"},{"product_sku_id": "sku_10","amount": "35","qty": "1"},{"product_sku_id": "sku_13","amount": "33","qty": "1"},{"product_sku_id": "sku_14","amount": "105","qty": "6"}],"order_id": "ID88","total_amount": "215","discount": "15","total_qty": "9","refferral_code": "EV78G55H","user_id": "88","subscript_points": true}});var config = {method: 'get',url: 'localhost:8000/api/predictions/orders',headers: {'token': 'U78FtRBfsMAnecq_q3i8J','Content-Type': 'application/json'},data : data};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
var client = new RestClient("localhost:8000/api/predictions/orders");client.Timeout = -1;var request = new RestRequest(Method.GET);request.AddHeader("token", "U78FtRBfsMAnecq_q3i8J");request.AddHeader("Content-Type", "application/json");var body = @"{" + "" +@" ""data"": {" + "" +@" ""name"": ""Abhay""," + "" +@" ""email"": ""[email protected]""," + "" +@" ""phone"": ""7666804987""," + "" +@" ""address"": ""address 1""," + "" +@" ""products"": [" + "" +@" {" + "" +@" ""product_sku_id"": ""sku_9""," + "" +@" ""amount"": ""25""," + "" +@" ""qty"": ""1""" + "" +@" }," + "" +@" {" + "" +@" ""product_sku_id"": ""sku_10""," + "" +@" ""amount"": ""35""," + "" +@" ""qty"": ""1""" + "" +@" }," + "" +@" {" + "" +@" ""product_sku_id"": ""sku_13""," + "" +@" ""amount"": ""33""," + "" +@" ""qty"": ""1""" + "" +@" }," + "" +@" {" + "" +@" ""product_sku_id"": ""sku_14""," + "" +@" ""amount"": ""105""," + "" +@" ""qty"": ""6""" + "" +@" }" + "" +@" ]," + "" +@" ""order_id"": ""ID88""," + "" +@" ""total_amount"": ""215""," + "" +@" ""discount"": ""15""," + "" +@" ""total_qty"": ""9""," + "" +@" ""refferral_code"": ""EV78G55H""," + "" +@" ""user_id"": ""88""," + "" +@" ""subscript_points"": true" + "" +@" }" + "" +@"}";request.AddParameter("application/json", body, ParameterType.RequestBody);IRestResponse response = client.Execute(request);Console.WriteLine(response.Content);
import http.clientimport jsonconn = http.client.HTTPSConnection("localhost", undefined)payload = json.dumps({"data": {"name": "Abhay","phone": "7666804987","address": "address 1","products": [{"product_sku_id": "sku_9","amount": "25","qty": "1"},{"product_sku_id": "sku_10","amount": "35","qty": "1"},{"product_sku_id": "sku_13","amount": "33","qty": "1"},{"product_sku_id": "sku_14","amount": "105","qty": "6"}],"order_id": "ID88","total_amount": "215","discount": "15","total_qty": "9","refferral_code": "EV78G55H","user_id": "88","subscript_points": True}})headers = {'token': 'U78FtRBfsMAnecq_q3i8J','Content-Type': 'application/json'}conn.request("GET", "/api/predictions/orders", payload, headers)res = conn.getresponse()data = res.read()print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder().build();Request request = new Request.Builder().url("localhost:8000/api/predictions/orders").method("GET", null).addHeader("token", "U78FtRBfsMAnecq_q3i8J").addHeader("Content-Type", "application/json").build();Response response = client.newCall(request).execute();
package mainimport ("fmt""strings""net/http""io/ioutil")func main() {url := "localhost:8000/api/predictions/orders"method := "GET"payload := strings.NewReader(`{`+""+`"data": {`+""+`"name": "Abhay",`+""+`"+`"phone": "7666804987",`+""+`"address": "address 1",`+""+`"products": [`+""+`{`+""+`"product_sku_id": "sku_9",`+""+`"amount": "25",`+""+`"qty": "1"`+""+`},`+""+`{`+""+`"product_sku_id": "sku_10",`+""+`"amount": "35",`+""+`"qty": "1"`+""+`},`+""+`{`+""+`"product_sku_id": "sku_13",`+""+`"amount": "33",`+""+`"qty": "1"`+""+`},`+""+`{`+""+`"product_sku_id": "sku_14",`+""+`"amount": "105",`+""+`"qty": "6"`+""+`}`+""+`],`+""+`"order_id": "ID88",`+""+`"total_amount": "215",`+""+`"discount": "15",`+""+`"total_qty": "9",`+""+`"refferral_code": "EV78G55H",`+""+`"user_id": "88",`+""+`"subscript_points": true`+""+`}`+""+`}`)client := &http.Client {}req, err := http.NewRequest(method, url, payload)if err != nil {fmt.Println(err)return}req.Header.Add("token", "U78FtRBfsMAnecq_q3i8J")req.Header.Add("Content-Type", "application/json")res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := ioutil.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
require "uri"require "json"require "net/http"url = URI("localhost:8000/api/predictions/orders")http = Net::HTTP.new(url.host, url.port);request = Net::HTTP::Get.new(url)request["token"] = "U78FtRBfsMAnecq_q3i8J"request["Content-Type"] = "application/json"request.body = JSON.dump({"data": {"name": "Abhay","email": "[email protected]","phone": "7666804987","address": "address 1","products": [{"product_sku_id": "sku_9","amount": "25","qty": "1"},{"product_sku_id": "sku_10","amount": "35","qty": "1"},{"product_sku_id": "sku_13","amount": "33","qty": "1"},{"product_sku_id": "sku_14","amount": "105","qty": "6"}],"order_id": "ID88","total_amount": "215","discount": "15","total_qty": "9","refferral_code": "EV78G55H","user_id": "88","subscript_points": true}})response = http.request(request)puts response.read_body
CURL *curl;CURLcode res;curl = curl_easy_init();if(curl) {curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");curl_easy_setopt(curl, CURLOPT_URL, "localhost:8000/api/predictions/orders");curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");struct curl_slist *headers = NULL;headers = curl_slist_append(headers, "token: U78FtRBfsMAnecq_q3i8J");headers = curl_slist_append(headers, "Content-Type: application/json");curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);const char *data = "{"data": {"name": "Abhay","phone": "7666804987","address": "address 1","products": [{"product_sku_id": "sku_9","amount": "25","qty": "1"},{"product_sku_id": "sku_10","amount": "35","qty": "1"},{"product_sku_id": "sku_13","amount": "33","qty": "1"},{"product_sku_id": "sku_14","amount": "105","qty": "6"}],"order_id": "ID88","total_amount": "215","discount": "15","total_qty": "9","refferral_code": "EV78G55H","user_id": "88","subscript_points": true}}";curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);res = curl_easy_perform(curl);}curl_easy_cleanup(curl);
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"$headers.Add("token", "U78FtRBfsMAnecq_q3i8J")$headers.Add("Content-Type", "application/json")$body = "{`n `"data`": {`n `"name`": `"Abhay`",`n `"email`": `"[email protected]`",`n `"phone`": `"7666804987`",`n `"address`": `"address 1`",`n `"products`": [`n {`n `"product_sku_id`": `"sku_9`",`n `"amount`": `"25`",`n `"qty`": `"1`"`n },`n {`n `"product_sku_id`": `"sku_10`",`n `"amount`": `"35`",`n `"qty`": `"1`"`n },`n {`n `"product_sku_id`": `"sku_13`",`n `"amount`": `"33`",`n `"qty`": `"1`"`n },`n {`n `"product_sku_id`": `"sku_14`",`n `"amount`": `"105`",`n `"qty`": `"6`"`n }`n ],`n `"order_id`": `"ID88`",`n `"total_amount`": `"215`",`n `"discount`": `"15`",`n `"total_qty`": `"9`",`n `"refferral_code`": `"EV78G55H`",`n `"user_id`": `"88`",`n `"subscript_points`": true`n }`n}"$response = Invoke-RestMethod 'localhost:8000/api/predictions/orders' -Method 'GET' -Headers $headers -Body $body$response | ConvertTo-Json
Sample Response
GET /api/predictions/orders HTTP/1.1{message: "You will get 4 points and you will be upgraded to warrior level after purchasing this item(s).",total_points: 4}
Error Codes
| Status Code | Description | Response Structure |
|---|---|---|
| 200 | Success | Request Based Response |
| 400 | Bad Request | { "path": "String", "error": "String" } |
| 401 | Unauthorized | { "error": "String" } |
| 500 | Internal server error | { "error": "String" } |