OPENCART GRAPHQL APIs
Opencart graphql API is fully integrated with the opencart. This allows interact with your Opencart site by sending and receiving data as JSON (JavaScript Object Notation) objects. Using the Opencart Graphql API API you can create users, edit user and it provides data access to the content of users like which is publicly accessible via API. while private content, password-protected content, user details, order details, return details and user's personal data is only available with authentication etc.
APIs Requirements
To use the Opencart GraphQl APIs Addon, you must be using:
This Addon requirements are following:
- Opencart 3xDownload
Request/Response format
APIs response format is JSON. Requests contains the status, errors, message and data keys. Successful requests will return a true status.
Example
{
"data": {
"customerByEmail": {
"firstname": "user1",
"lastname": "11",
"email": "user1@test.com"
}
}
}
Pagination
You may also specify the offset from the first resource using the
orders($start:Int,$limit:Int){ parameter:
Example
query orders($start:Int,$limit:Int){
orders(start:$start,limit:$limit){
order_id
}
}
Opencart user login API
The login user API allow you to login user and generate the token which is Encoded by JWT Authentication RS256 Encryption method.
Here {{site_url}} will be your website url ex.
https://xyz.com , and
/index.php?route=lets_graphql/lets_graphql is a start url of our APIs, this will
be used in all APIs related to Opencart Graphql APIs.
POST: {{site_url}}/index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
string |
Body |
Required |
allow email. | |
| password | string |
Body |
Required |
Password allows Aa-Zz,0-9,Special charactors. |
| Parameter | |
|---|---|
| Type | string |
| Position | Body |
| # | Required |
| Description | user email allows. |
| Parameter | password |
| Type | string |
| Position | Body |
| # | Required |
| Description | Password allows Aa-Zz,0-9,Special charactors. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '{{site_url}}/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation loginuser($email:String!,$password:String!){login(email:$email,password:$password){ letscms_token user_data{ firstname lastname email} }}","variables":{"email":"user1@test.com","password":"2233"}}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Cookie: OCSESSID=b4eb1e217a78831795b8af3c54; currency=EUR; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "{{site_url}}/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Cookie": "OCSESSID=b4eb1e217a78831795b8af3c54; currency=EUR; language=en-gb"
},
"data": JSON.stringify({
query: "mutation loginuser($email:String!,$password:String!){login(email:$email,password:$password){ letscms_token user_data{firstname lastname email}}}",
variables: {"email":"user1@test.com","password":"2233"}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': '{{site_url}}/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=b4eb1e217a78831795b8af3c54; currency=EUR; language=en-gb'
},
body: JSON.stringify({
query: `mutation loginuser($email:String!,$password:String!){login(email:$email,password:$password){ letscms_token user_data{firstname lastname email}}}`,
variables: {"email":"user1@test.com","password":"2233"}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
var request = require('request');
var options = {
'method': 'POST',
'url': '{{site_url}}/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=b4eb1e217a78831795b8af3c54; currency=EUR; language=en-gb'
},
body: JSON.stringify({
query: `mutation loginuser($email:String!,$password:String!){login(email:$email,password:$password){ letscms_token user_data{firstname lastname email}}}`,
variables: {"email":"user1@test.com","password":"2233"}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
var client = new RestClient("{{site_url}}/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=b4eb1e217a78831795b8af3c54; currency=EUR; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation loginuser($email:String!,$password:String!){login(email:$email,password:$password){ letscms_token user_data{firstname lastname email}}}\",\"variables\":{\"email\":\"user1@test.com\",\"password\":\"2233\"}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST '{{site_url}}/index.php?route=lets_graphql/lets_graphql' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=b4eb1e217a78831795b8af3c54; currency=EUR; language=en-gb' \
--data-raw '{"query":"mutation loginuser($email:String!,$password:String!){login(email:$email,password:$password){ letscms_token user_data{firstname lastname email}}}","variables":{"email":"user1@test.com","password":"2233"}}'
require "uri"
require "json"
require "net/http"
url = URI("{{site_url}}/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=b4eb1e217a78831795b8af3c54; currency=EUR; language=en-gb"
request.body = "{\"query\":\"mutation loginuser($email:String!,$password:String!){login(email:$email,password:$password){ letscms_token user_data{firstname lastname email}}}\",\"variables\":{\"email\":\"user1@test.com\",\"password\":\"2233\"}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"login": {
"letscms_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMTQyNDk3LCJuYmYiOjE2NjMxNDI1MDIsImV4cCI6MTY2MzE0MzI5NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.HBQ7MiWZngDCNUjwVpu3M5ACHu-tGMXEwzW5To7kuO0",
"user_data": {
"firstname": "user1",
"lastname": "11",
"email": "user1@test.com"
}
}
}
}
Opencart user register API
The register user API allow you to register user.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| customer_group_id | Integer |
Body |
Required |
Customer group id is belongs to user's Name |
| firstname | string |
Body |
Required |
First name is belongs to user's first name |
| lastname | string |
Body |
Required |
Last name is belongs to user's surname |
string |
Body |
Required |
Each user must have the unique email address same email address not allowed. | |
| telephone | integer |
Body |
Required |
telephone number of user. |
| address_1 | string |
Body |
Required |
Address 1 is user's residence location. |
| address_2 | string |
Body |
Required |
Address 2 is user's residence location. |
| city | string |
Body |
Required |
city is user's city. |
| country_id | integer |
Body |
Required |
country id. |
| zone_id | integer |
Body |
Required |
zone id. |
| password | string |
Body |
Required |
Password allows Aa-Zz,0-9 and Special charactors. |
| confirm | string |
Body |
Required |
confirm allows Aa-Zz,0-9 and Special charactors. |
| agree | boolean |
Body |
Required |
company term and condition. |
| fax | string |
Body |
Required |
user fax number. |
| company | string |
Body |
Required |
user company name. |
| postcode | integer |
Body |
Required |
user city post code. |
| Parameter | customer_group_id |
|---|---|
| Type | Integer |
| Position | Body |
| # | Required |
| Description | Customer group id is belongs to user's Name |
| Parameter | firstname |
| Type | string |
| Position | Body |
| # | Required |
| Description | First name is belongs to user's first name |
| Parameter | lastname |
| Type | string |
| Position | Body |
| # | Required |
| Description | Last name is belongs to user's surname. |
| Parameter | |
| Type | string |
| Position | Body |
| # | Required |
| Description | Each user must have the unique email address same email address not allowed. |
| Parameter | telephone |
| Type | integer |
| Position | Body |
| # | Required |
| Description | telephone number of user. |
| Parameter | address_1 |
| Type | string |
| Position | Body |
| # | Required |
| Description | Address 1 is user's residence location. |
| Parameter | address_2 |
| Type | string |
| Position | Body |
| # | Required |
| Description | Address 2 is user's residence location. |
| Parameter | city |
| Type | string |
| Position | Body |
| # | Required |
| Description | city is user's city. |
| Parameter | country_id |
| Type | integer |
| Position | Body |
| # | Required |
| Description | country id. |
| Parameter | zone_id |
| Type | integer |
| Position | Body |
| # | Required |
| Description | zone id. |
| Parameter | password |
| Type | string |
| Position | Body |
| # | Required |
| Description | Password allows Aa-Zz,0-9 and Special charactors. |
| Parameter | confirm |
| Type | string |
| Position | Body |
| # | Required |
| Description | confirm allows Aa-Zz,0-9 and Special charactors. |
| Parameter | agree |
| Type | string |
| Position | Body |
| # | Required |
| Description | company term and condition. |
| Parameter | fax |
| Type | string |
| Position | Body |
| # | Required |
| Description | user fax number. |
| Parameter | company |
| Type | string |
| Position | Body |
| # | Required |
| Description | user company name. |
| Parameter | postcode |
| Type | integer |
| Position | Body |
| # | Required |
| Description | >user city post code. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation register($customerdata:CustomerInput){register(input:$customerdata)}","variables":{"customerdata":{"customer_group_id":1,"firstname":"test","lastname":"22","email":"test9@test.com","telephone":"98989898998","address_1":"abc1","address_2":"abc2","city":"aligarh","country_id":99,"zone_id":1505,"password":"1122","confirm":"1122","agree":true,"fax":"656545645","company":"abcdef","postcode":"202001"}}}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Cookie: OCSESSID=619d0197e28ec484fe748a4f72; currency=EUR; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Cookie": "OCSESSID=619d0197e28ec484fe748a4f72; currency=EUR; language=en-gb"
},
"data": JSON.stringify({
query: "mutation register($customerdata:CustomerInput){register(input:$customerdata)}",
variables: {"customerdata":{"customer_group_id":1,"firstname":"test","lastname":"22","email":"test9@test.com","telephone":"98989898998","address_1":"abc1","address_2":"abc2","city":"aligarh","country_id":99,"zone_id":1505,"password":"1122","confirm":"1122","agree":true,"fax":"656545645","company":"abcdef","postcode":"202001"}}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=619d0197e28ec484fe748a4f72; currency=EUR; language=en-gb'
},
body: JSON.stringify({
query: `mutation register($customerdata:CustomerInput){register(input:$customerdata)}`,
variables: {"customerdata":{"customer_group_id":1,"firstname":"test","lastname":"22","email":"test9@test.com","telephone":"98989898998","address_1":"abc1","address_2":"abc2","city":"aligarh","country_id":99,"zone_id":1505,"password":"1122","confirm":"1122","agree":true,"fax":"656545645","company":"abcdef","postcode":"202001"}}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation register($customerdata:CustomerInput){register(input:$customerdata)}\",\"variables\":{\"customerdata\":{\"customer_group_id\":1,\"firstname\":\"test\",\"lastname\":\"22\",\"email\":\"test9@test.com\",\"telephone\":\"98989898998\",\"address_1\":\"abc1\",\"address_2\":\"abc2\",\"city\":\"aligarh\",\"country_id\":99,\"zone_id\":1505,\"password\":\"1122\",\"confirm\":\"1122\",\"agree\":true,\"fax\":\"656545645\",\"company\":\"abcdef\",\"postcode\":\"202001\"}}}"
headers = {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=619d0197e28ec484fe748a4f72; currency=EUR; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=619d0197e28ec484fe748a4f72; currency=EUR; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation register($customerdata:CustomerInput){register(input:$customerdata)}\",\"variables\":{\"customerdata\":{\"customer_group_id\":1,\"firstname\":\"test\",\"lastname\":\"22\",\"email\":\"test9@test.com\",\"telephone\":\"98989898998\",\"address_1\":\"abc1\",\"address_2\":\"abc2\",\"city\":\"aligarh\",\"country_id\":99,\"zone_id\":1505,\"password\":\"1122\",\"confirm\":\"1122\",\"agree\":true,\"fax\":\"656545645\",\"company\":\"abcdef\",\"postcode\":\"202001\"}}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=619d0197e28ec484fe748a4f72; currency=EUR; language=en-gb' \
--data-raw '{"query":"mutation register($customerdata:CustomerInput){register(input:$customerdata)}","variables":{"customerdata":{"customer_group_id":1,"firstname":"test","lastname":"22","email":"test9@test.com","telephone":"98989898998","address_1":"abc1","address_2":"abc2","city":"aligarh","country_id":99,"zone_id":1505,"password":"1122","confirm":"1122","agree":true,"fax":"656545645","company":"abcdef","postcode":"202001"}}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation register($customerdata:CustomerInput){register(input:$customerdata)}\",\"variables\":{\"customerdata\":{\"customer_group_id\":1,\"firstname\":\"test\",\"lastname\":\"22\",\"email\":\"test9@test.com\",\"telephone\":\"98989898998\",\"address_1\":\"abc1\",\"address_2\":\"abc2\",\"city\":\"aligarh\",\"country_id\":99,\"zone_id\":1505,\"password\":\"1122\",\"confirm\":\"1122\",\"agree\":true,\"fax\":\"656545645\",\"company\":\"abcdef\",\"postcode\":\"202001\"}}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=619d0197e28ec484fe748a4f72; currency=EUR; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=619d0197e28ec484fe748a4f72; currency=EUR; language=en-gb"
request.body = "{\"query\":\"mutation register($customerdata:CustomerInput){register(input:$customerdata)}\",\"variables\":{\"customerdata\":{\"customer_group_id\":1,\"firstname\":\"test\",\"lastname\":\"22\",\"email\":\"test9@test.com\",\"telephone\":\"98989898998\",\"address_1\":\"abc1\",\"address_2\":\"abc2\",\"city\":\"aligarh\",\"country_id\":99,\"zone_id\":1505,\"password\":\"1122\",\"confirm\":\"1122\",\"agree\":true,\"fax\":\"656545645\",\"company\":\"abcdef\",\"postcode\":\"202001\"}}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"register": true
}
}
Opencart add to cart API
The cart add API allow you product add to cart.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| Token | string |
Authorization |
Required |
Bearer token |
| product_id | ID |
Body GRAPHQL VARIABLES
|
Required |
product id to add in cart |
| quantity | integer |
Body GRAPHQL VARIABLES
|
Required |
product quantity |
| recurring_id | ID |
Body GRAPHQL VARIABLES
|
Required |
product recurring_id |
| optiona | ||||
| option_id | ID |
Body GRAPHQL VARIABLES
|
Required |
option id |
| value | string |
Body GRAPHQL VARIABLES
|
Required |
option value |
| Parameter | Token |
|---|---|
| Type | string |
| Position | Authorization |
| # | Required |
| Description | Brearer Token |
| Parameter | product_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | product id to add in cart |
| Parameter | quantity |
| Type | integer |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | product quantity |
| Parameter | recurring_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | product recurring_id |
| Options | |
| Parameter | option_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | product option_id |
| Parameter | value |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | option value |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation addtocart($product:CartProductInput!){\\r\\n addProductToCart(input:$product){\\r\\n weight tax total subtotal coupon_discount coupon_code has_stock has_shipping has_download totals{title value} items{ cart_id product_id name model shipping image option{option_id name value } download{download_id name} quantity minimum subtract stock price total reward points tax_class_id weight weight_class_id length width height length_class_id } \\r\\n \\r\\n }\\r\\n}","variables":{"product":{"product_id":40,"quantity":1,"options":{}}}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE4OTI2LCJuYmYiOjE2NjM0MTg5MzEsImV4cCI6MTY2MzQxOTcyNiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.0aMPZMKpENAHyIjWSCIVNhSJXC0xe9j9OdqRU_0_Kfw',
'Content-Type: application/json',
'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE4OTI2LCJuYmYiOjE2NjM0MTg5MzEsImV4cCI6MTY2MzQxOTcyNiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.0aMPZMKpENAHyIjWSCIVNhSJXC0xe9j9OdqRU_0_Kfw",
"Content-Type": "application/json",
"Cookie": "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation addtocart($product:CartProductInput!){\r\n addProductToCart(input:$product){\r\n weight tax total subtotal coupon_discount coupon_code has_stock has_shipping has_download totals{title value} items{ cart_id product_id name model shipping image option{option_id name value } download{download_id name} quantity minimum subtract stock price total reward points tax_class_id weight weight_class_id length width height length_class_id } \r\n \r\n }\r\n}",
variables: {"product":{"product_id":40,"quantity":1,"options":{}}}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE4OTI2LCJuYmYiOjE2NjM0MTg5MzEsImV4cCI6MTY2MzQxOTcyNiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.0aMPZMKpENAHyIjWSCIVNhSJXC0xe9j9OdqRU_0_Kfw',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation addtocart($product:CartProductInput!){
addProductToCart(input:$product){
weight tax total subtotal coupon_discount coupon_code has_stock has_shipping has_download totals{title value} items{ cart_id product_id name model shipping image option{option_id name value } download{download_id name} quantity minimum subtract stock price total reward points tax_class_id weight weight_class_id length width height length_class_id }
}
}`,
variables: {"product":{"product_id":40,"quantity":1,"options":{}}}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation addtocart($product:CartProductInput!){\\r\\n addProductToCart(input:$product){\\r\\n weight tax total subtotal coupon_discount coupon_code has_stock has_shipping has_download totals{title value} items{ cart_id product_id name model shipping image option{option_id name value } download{download_id name} quantity minimum subtract stock price total reward points tax_class_id weight weight_class_id length width height length_class_id } \\r\\n \\r\\n }\\r\\n}\",\"variables\":{\"product\":{\"product_id\":40,\"quantity\":1,\"options\":{}}}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE4OTI2LCJuYmYiOjE2NjM0MTg5MzEsImV4cCI6MTY2MzQxOTcyNiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.0aMPZMKpENAHyIjWSCIVNhSJXC0xe9j9OdqRU_0_Kfw',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE4OTI2LCJuYmYiOjE2NjM0MTg5MzEsImV4cCI6MTY2MzQxOTcyNiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.0aMPZMKpENAHyIjWSCIVNhSJXC0xe9j9OdqRU_0_Kfw");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation addtocart($product:CartProductInput!){\\r\\n addProductToCart(input:$product){\\r\\n weight tax total subtotal coupon_discount coupon_code has_stock has_shipping has_download totals{title value} items{ cart_id product_id name model shipping image option{option_id name value } download{download_id name} quantity minimum subtract stock price total reward points tax_class_id weight weight_class_id length width height length_class_id } \\r\\n \\r\\n }\\r\\n}\",\"variables\":{\"product\":{\"product_id\":40,\"quantity\":1,\"options\":{}}}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE4OTI2LCJuYmYiOjE2NjM0MTg5MzEsImV4cCI6MTY2MzQxOTcyNiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.0aMPZMKpENAHyIjWSCIVNhSJXC0xe9j9OdqRU_0_Kfw' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation addtocart($product:CartProductInput!){\r\n addProductToCart(input:$product){\r\n weight tax total subtotal coupon_discount coupon_code has_stock has_shipping has_download totals{title value} items{ cart_id product_id name model shipping image option{option_id name value } download{download_id name} quantity minimum subtract stock price total reward points tax_class_id weight weight_class_id length width height length_class_id } \r\n \r\n }\r\n}","variables":{"product":{"product_id":40,"quantity":1,"options":{}}}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation addtocart($product:CartProductInput!){\\r\\n addProductToCart(input:$product){\\r\\n weight tax total subtotal coupon_discount coupon_code has_stock has_shipping has_download totals{title value} items{ cart_id product_id name model shipping image option{option_id name value } download{download_id name} quantity minimum subtract stock price total reward points tax_class_id weight weight_class_id length width height length_class_id } \\r\\n \\r\\n }\\r\\n}\",\"variables\":{\"product\":{\"product_id\":40,\"quantity\":1,\"options\":{}}}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE4OTI2LCJuYmYiOjE2NjM0MTg5MzEsImV4cCI6MTY2MzQxOTcyNiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.0aMPZMKpENAHyIjWSCIVNhSJXC0xe9j9OdqRU_0_Kfw")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE4OTI2LCJuYmYiOjE2NjM0MTg5MzEsImV4cCI6MTY2MzQxOTcyNiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.0aMPZMKpENAHyIjWSCIVNhSJXC0xe9j9OdqRU_0_Kfw"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation addtocart($product:CartProductInput!){\\r\\n addProductToCart(input:$product){\\r\\n weight tax total subtotal coupon_discount coupon_code has_stock has_shipping has_download totals{title value} items{ cart_id product_id name model shipping image option{option_id name value } download{download_id name} quantity minimum subtract stock price total reward points tax_class_id weight weight_class_id length width height length_class_id } \\r\\n \\r\\n }\\r\\n}\",\"variables\":{\"product\":{\"product_id\":40,\"quantity\":1,\"options\":{}}}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"addProductToCart": {
"weight": 20,
"tax": 44.4,
"total": 246.4,
"subtotal": 202,
"coupon_discount": 0,
"coupon_code": "",
"has_stock": true,
"has_shipping": true,
"has_download": false,
"totals": [
{
"title": "Sub-Total",
"value": 202
},
{
"title": "Eco Tax (-2.00)",
"value": 4
},
{
"title": "VAT (20%)",
"value": 40.4
},
{
"title": "Total",
"value": 246.4
}
],
"items": [
{
"cart_id": "18",
"product_id": "40",
"name": "iPhone",
"model": "product 11",
"shipping": "1",
"image": "catalog/demo/iphone_1.jpg",
"option": [],
"download": [],
"quantity": 2,
"minimum": 1,
"subtract": 1,
"stock": 965,
"price": 101,
"total": 202,
"reward": 0,
"points": 0,
"tax_class_id": "9",
"weight": 20,
"weight_class_id": "1",
"length": 0,
"width": 0,
"height": 0,
"length_class_id": "1"
}
]
}
}
}
Opencart update cart API
The cart update API allow you product quantity update in cart.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| Token | string |
Authorization |
Required |
Bearer token |
| cart_id | ID |
Body GRAPHQL VARIABLES
|
Required |
cart id to update cart |
| quantity | integer |
Body GRAPHQL VARIABLES
|
Required |
product quantity |
| Parameter | Token |
|---|---|
| Type | string |
| Position | Authorization |
| # | Required |
| Description | Brearer Token |
| Parameter | cart_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | cart id to update cart |
| Parameter | quantity |
| Type | integer |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | product quantity |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation updatecart($cart_id:ID!,$qty:Int!){\\r\\n updateCartProduct(cart_id:$cart_id,quantity:$qty)\\r\\n}","variables":{"cart_id":3,"qty":5}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDc2OTA2LCJuYmYiOjE2NjM0NzY5MTEsImV4cCI6MTY2MzQ3NzcwNiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.-gmfCUgM4d-x_Q27-cqdTosV-GVpceFbUqtvM8pHAxo',
'Content-Type: application/json',
'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDc2OTA2LCJuYmYiOjE2NjM0NzY5MTEsImV4cCI6MTY2MzQ3NzcwNiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.-gmfCUgM4d-x_Q27-cqdTosV-GVpceFbUqtvM8pHAxo",
"Content-Type": "application/json",
"Cookie": "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation updatecart($cart_id:ID!,$qty:Int!){\r\n updateCartProduct(cart_id:$cart_id,quantity:$qty)\r\n}",
variables: {"cart_id":3,"qty":5}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDc2OTA2LCJuYmYiOjE2NjM0NzY5MTEsImV4cCI6MTY2MzQ3NzcwNiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.-gmfCUgM4d-x_Q27-cqdTosV-GVpceFbUqtvM8pHAxo',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation updatecart($cart_id:ID!,$qty:Int!){
updateCartProduct(cart_id:$cart_id,quantity:$qty)
}`,
variables: {"cart_id":3,"qty":5}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation updatecart($cart_id:ID!,$qty:Int!){\\r\\n updateCartProduct(cart_id:$cart_id,quantity:$qty)\\r\\n}\",\"variables\":{\"cart_id\":3,\"qty\":5}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDc2OTA2LCJuYmYiOjE2NjM0NzY5MTEsImV4cCI6MTY2MzQ3NzcwNiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.-gmfCUgM4d-x_Q27-cqdTosV-GVpceFbUqtvM8pHAxo',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDc2OTA2LCJuYmYiOjE2NjM0NzY5MTEsImV4cCI6MTY2MzQ3NzcwNiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.-gmfCUgM4d-x_Q27-cqdTosV-GVpceFbUqtvM8pHAxo");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation updatecart($cart_id:ID!,$qty:Int!){\\r\\n updateCartProduct(cart_id:$cart_id,quantity:$qty)\\r\\n}\",\"variables\":{\"cart_id\":3,\"qty\":5}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDc2OTA2LCJuYmYiOjE2NjM0NzY5MTEsImV4cCI6MTY2MzQ3NzcwNiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.-gmfCUgM4d-x_Q27-cqdTosV-GVpceFbUqtvM8pHAxo' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation updatecart($cart_id:ID!,$qty:Int!){\r\n updateCartProduct(cart_id:$cart_id,quantity:$qty)\r\n}","variables":{"cart_id":3,"qty":5}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation updatecart($cart_id:ID!,$qty:Int!){\\r\\n updateCartProduct(cart_id:$cart_id,quantity:$qty)\\r\\n}\",\"variables\":{\"cart_id\":3,\"qty\":5}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDc2OTA2LCJuYmYiOjE2NjM0NzY5MTEsImV4cCI6MTY2MzQ3NzcwNiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.-gmfCUgM4d-x_Q27-cqdTosV-GVpceFbUqtvM8pHAxo")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDc2OTA2LCJuYmYiOjE2NjM0NzY5MTEsImV4cCI6MTY2MzQ3NzcwNiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.-gmfCUgM4d-x_Q27-cqdTosV-GVpceFbUqtvM8pHAxo"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation updatecart($cart_id:ID!,$qty:Int!){\\r\\n updateCartProduct(cart_id:$cart_id,quantity:$qty)\\r\\n}\",\"variables\":{\"cart_id\":3,\"qty\":5}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"updateCartProduct": true
}
}
Opencart remove product from cart API
The remove product from cart API allow you remove product in cart.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| Token | string |
Authorization |
Required |
Bearer token |
| cart_id | ID |
Body GRAPHQL VARIABLES
|
Required |
cart id to remove product |
| Parameter | Token |
|---|---|
| Type | string |
| Position | Authorization |
| # | Required |
| Description | Brearer Token |
| Parameter | cart_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | cart id to remove product |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation deletecartproduct($id:ID!){\\r\\n deleteCartProduct(cart_id:$id)\\r\\n}","variables":{"id":3}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDc3ODAyLCJuYmYiOjE2NjM0Nzc4MDcsImV4cCI6MTY2MzQ3ODYwMiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.xA2gOUQ731AAiOmVwJ9XJht3OzpYUjohr1EeVH_tm5E',
'Content-Type: application/json',
'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDc3ODAyLCJuYmYiOjE2NjM0Nzc4MDcsImV4cCI6MTY2MzQ3ODYwMiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.xA2gOUQ731AAiOmVwJ9XJht3OzpYUjohr1EeVH_tm5E",
"Content-Type": "application/json",
"Cookie": "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation deletecartproduct($id:ID!){\r\n deleteCartProduct(cart_id:$id)\r\n}",
variables: {"id":3}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDc3ODAyLCJuYmYiOjE2NjM0Nzc4MDcsImV4cCI6MTY2MzQ3ODYwMiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.xA2gOUQ731AAiOmVwJ9XJht3OzpYUjohr1EeVH_tm5E',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation deletecartproduct($id:ID!){
deleteCartProduct(cart_id:$id)
}`,
variables: {"id":3}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation deletecartproduct($id:ID!){\\r\\n deleteCartProduct(cart_id:$id)\\r\\n}\",\"variables\":{\"id\":3}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDc3ODAyLCJuYmYiOjE2NjM0Nzc4MDcsImV4cCI6MTY2MzQ3ODYwMiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.xA2gOUQ731AAiOmVwJ9XJht3OzpYUjohr1EeVH_tm5E',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDc3ODAyLCJuYmYiOjE2NjM0Nzc4MDcsImV4cCI6MTY2MzQ3ODYwMiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.xA2gOUQ731AAiOmVwJ9XJht3OzpYUjohr1EeVH_tm5E");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation deletecartproduct($id:ID!){\\r\\n deleteCartProduct(cart_id:$id)\\r\\n}\",\"variables\":{\"id\":3}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDc3ODAyLCJuYmYiOjE2NjM0Nzc4MDcsImV4cCI6MTY2MzQ3ODYwMiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.xA2gOUQ731AAiOmVwJ9XJht3OzpYUjohr1EeVH_tm5E' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation deletecartproduct($id:ID!){\r\n deleteCartProduct(cart_id:$id)\r\n}","variables":{"id":3}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation deletecartproduct($id:ID!){\\r\\n deleteCartProduct(cart_id:$id)\\r\\n}\",\"variables\":{\"id\":3}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDc3ODAyLCJuYmYiOjE2NjM0Nzc4MDcsImV4cCI6MTY2MzQ3ODYwMiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.xA2gOUQ731AAiOmVwJ9XJht3OzpYUjohr1EeVH_tm5E")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDc3ODAyLCJuYmYiOjE2NjM0Nzc4MDcsImV4cCI6MTY2MzQ3ODYwMiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.xA2gOUQ731AAiOmVwJ9XJht3OzpYUjohr1EeVH_tm5E"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation deletecartproduct($id:ID!){\\r\\n deleteCartProduct(cart_id:$id)\\r\\n}\",\"variables\":{\"id\":3}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"deleteCartProduct": true
}
}
Opencart apply coupon cart API
Apply coupon discount to cart cart.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| Token | string |
Authorization |
Required |
Bearer token |
| code | ID |
Body GRAPHQL VARIABLES
|
Required |
coupon code |
| Parameter | Token |
|---|---|
| Type | string |
| Position | Authorization |
| # | Required |
| Description | Brearer Token |
| Parameter | code |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | coupon code |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation addcoupon($code:ID!){\\r\\n addCoupon(code:$code){\\r\\n tax total subtotal coupon_discount coupon_code totals{title value sort_order}\\r\\n }\\r\\n}","variables":{"code":2222}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTc0ODc2LCJuYmYiOjE2NjM1NzQ4ODEsImV4cCI6MTY2MzU3NTY3NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.nnmIAaLYdcj8BOzvVHL1Wu2JvZaD_xheyYZI0kOM_Rs',
'Content-Type: application/json',
'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTc0ODc2LCJuYmYiOjE2NjM1NzQ4ODEsImV4cCI6MTY2MzU3NTY3NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.nnmIAaLYdcj8BOzvVHL1Wu2JvZaD_xheyYZI0kOM_Rs",
"Content-Type": "application/json",
"Cookie": "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation addcoupon($code:ID!){\r\n addCoupon(code:$code){\r\n tax total subtotal coupon_discount coupon_code totals{title value sort_order}\r\n }\r\n}",
variables: {"code":2222}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTc0ODc2LCJuYmYiOjE2NjM1NzQ4ODEsImV4cCI6MTY2MzU3NTY3NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.nnmIAaLYdcj8BOzvVHL1Wu2JvZaD_xheyYZI0kOM_Rs',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation addcoupon($code:ID!){
addCoupon(code:$code){
tax total subtotal coupon_discount coupon_code totals{title value sort_order}
}
}`,
variables: {"code":2222}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation addcoupon($code:ID!){\\r\\n addCoupon(code:$code){\\r\\n tax total subtotal coupon_discount coupon_code totals{title value sort_order}\\r\\n }\\r\\n}\",\"variables\":{\"code\":2222}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTc0ODc2LCJuYmYiOjE2NjM1NzQ4ODEsImV4cCI6MTY2MzU3NTY3NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.nnmIAaLYdcj8BOzvVHL1Wu2JvZaD_xheyYZI0kOM_Rs',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTc0ODc2LCJuYmYiOjE2NjM1NzQ4ODEsImV4cCI6MTY2MzU3NTY3NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.nnmIAaLYdcj8BOzvVHL1Wu2JvZaD_xheyYZI0kOM_Rs");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation addcoupon($code:ID!){\\r\\n addCoupon(code:$code){\\r\\n tax total subtotal coupon_discount coupon_code totals{title value sort_order}\\r\\n }\\r\\n}\",\"variables\":{\"code\":2222}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTc0ODc2LCJuYmYiOjE2NjM1NzQ4ODEsImV4cCI6MTY2MzU3NTY3NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.nnmIAaLYdcj8BOzvVHL1Wu2JvZaD_xheyYZI0kOM_Rs' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation addcoupon($code:ID!){\r\n addCoupon(code:$code){\r\n tax total subtotal coupon_discount coupon_code totals{title value sort_order}\r\n }\r\n}","variables":{"code":2222}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation addcoupon($code:ID!){\\r\\n addCoupon(code:$code){\\r\\n tax total subtotal coupon_discount coupon_code totals{title value sort_order}\\r\\n }\\r\\n}\",\"variables\":{\"code\":2222}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTc0ODc2LCJuYmYiOjE2NjM1NzQ4ODEsImV4cCI6MTY2MzU3NTY3NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.nnmIAaLYdcj8BOzvVHL1Wu2JvZaD_xheyYZI0kOM_Rs")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTc0ODc2LCJuYmYiOjE2NjM1NzQ4ODEsImV4cCI6MTY2MzU3NTY3NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.nnmIAaLYdcj8BOzvVHL1Wu2JvZaD_xheyYZI0kOM_Rs"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation addcoupon($code:ID!){\\r\\n addCoupon(code:$code){\\r\\n tax total subtotal coupon_discount coupon_code totals{title value sort_order}\\r\\n }\\r\\n}\",\"variables\":{\"code\":2222}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"addCoupon": {
"tax": 22.2,
"total": 111.08000000000001,
"subtotal": 101,
"coupon_discount": -10.1,
"coupon_code": "2222",
"totals": [
{
"title": "Sub-Total",
"value": 101,
"sort_order": 1
},
{
"title": "Coupon (2222)",
"value": -10.1,
"sort_order": 4
},
{
"title": "Eco Tax (-2.00)",
"value": 2,
"sort_order": 5
},
{
"title": "VAT (20%)",
"value": 18.18,
"sort_order": 5
},
{
"title": "Total",
"value": 111.08000000000001,
"sort_order": 9
}
]
}
}
}
Opencart Empty cart API
Empty cart.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| Token | string |
Authorization |
Required |
Bearer token |
| Parameter | Token |
|---|---|
| Type | string |
| Position | Authorization |
| # | Required |
| Description | Brearer Token |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation emptycart{\\r\\n emptyCart\\r\\n}","variables":{}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDgwMTQwLCJuYmYiOjE2NjM0ODAxNDUsImV4cCI6MTY2MzQ4MDk0MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.BLVz2M36kTiGQneR6Q9t8Sr-plE8Yu07BQ1HYmS8EhA',
'Content-Type: application/json',
'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDgwMTQwLCJuYmYiOjE2NjM0ODAxNDUsImV4cCI6MTY2MzQ4MDk0MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.BLVz2M36kTiGQneR6Q9t8Sr-plE8Yu07BQ1HYmS8EhA",
"Content-Type": "application/json",
"Cookie": "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation emptycart{\r\n emptyCart\r\n}",
variables: {}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDgwMTQwLCJuYmYiOjE2NjM0ODAxNDUsImV4cCI6MTY2MzQ4MDk0MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.BLVz2M36kTiGQneR6Q9t8Sr-plE8Yu07BQ1HYmS8EhA',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation emptycart{
emptyCart
}`,
variables: {}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation emptycart{\\r\\n emptyCart\\r\\n}\",\"variables\":{}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDgwMTQwLCJuYmYiOjE2NjM0ODAxNDUsImV4cCI6MTY2MzQ4MDk0MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.BLVz2M36kTiGQneR6Q9t8Sr-plE8Yu07BQ1HYmS8EhA',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDgwMTQwLCJuYmYiOjE2NjM0ODAxNDUsImV4cCI6MTY2MzQ4MDk0MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.BLVz2M36kTiGQneR6Q9t8Sr-plE8Yu07BQ1HYmS8EhA");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation emptycart{\\r\\n emptyCart\\r\\n}\",\"variables\":{}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDgwMTQwLCJuYmYiOjE2NjM0ODAxNDUsImV4cCI6MTY2MzQ4MDk0MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.BLVz2M36kTiGQneR6Q9t8Sr-plE8Yu07BQ1HYmS8EhA' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation emptycart{\r\n emptyCart\r\n}","variables":{}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation emptycart{\\r\\n emptyCart\\r\\n}\",\"variables\":{}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDgwMTQwLCJuYmYiOjE2NjM0ODAxNDUsImV4cCI6MTY2MzQ4MDk0MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.BLVz2M36kTiGQneR6Q9t8Sr-plE8Yu07BQ1HYmS8EhA")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDgwMTQwLCJuYmYiOjE2NjM0ODAxNDUsImV4cCI6MTY2MzQ4MDk0MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.BLVz2M36kTiGQneR6Q9t8Sr-plE8Yu07BQ1HYmS8EhA"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation emptycart{\\r\\n emptyCart\\r\\n}\",\"variables\":{}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"emptyCart": true
}
}
Opencart user edit API
The edit user API allow you to edit user.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| Token | string |
Authorization |
Required |
Bearer token |
| firstname | string |
Body |
Required |
First name is belongs to user's first name |
| lastname | string |
Body |
Required |
Last name is belongs to user's surname |
string |
Body |
Required |
Each user must have the unique email address same email address not allowed. | |
| telephone | integer |
Body |
Required |
telephone number of user. |
| fax | string |
Body |
Required |
user fax number. |
| custom_field | string |
Body |
Optional |
user custom_field. |
| Parameter | Token |
|---|---|
| Type | string |
| Position | Authorization |
| # | Required |
| Description | Brearer Token |
| Parameter | firstname |
| Type | string |
| Position | Body |
| # | Required |
| Description | First name is belongs to user's first name |
| Parameter | lastname |
| Type | string |
| Position | Body |
| # | Required |
| Description | Last name is belongs to user's surname. |
| Parameter | |
| Type | string |
| Position | Body |
| # | Required |
| Description | Each user must have the unique email address same email address not allowed. |
| Parameter | telephone |
| Type | integer |
| Position | Body |
| # | Required |
| Description | telephone number of user. |
| Parameter | fax |
| Type | string |
| Position | Body |
| # | Required |
| Description | user fax number. |
| Parameter | custom_field |
| Type | string |
| Position | Body |
| # | Optional |
| Description | user custom_field. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation edit_customer($customer_data : CustomerEdit!){\\r\\n editCustomer(input:$customer_data)\\r\\n}","variables":{"customer_data":{"firstname":"user1","lastname":"11","email":"user1@test.com","telephone":"8888888888","fax":"676767","custom_field":""}}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMjM0ODAxLCJuYmYiOjE2NjMyMzQ4MDYsImV4cCI6MTY2MzIzNTYwMSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.23pUsa2Vn3-dQwL84M5ZN7dIgAzQzzlp3YhLVpkynP4',
'Content-Type: application/json',
'Cookie: OCSESSID=53d60509bdbc26bd5e97f9a973; currency=EUR; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMjM0ODAxLCJuYmYiOjE2NjMyMzQ4MDYsImV4cCI6MTY2MzIzNTYwMSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.23pUsa2Vn3-dQwL84M5ZN7dIgAzQzzlp3YhLVpkynP4",
"Content-Type": "application/json",
"Cookie": "OCSESSID=53d60509bdbc26bd5e97f9a973; currency=EUR; language=en-gb"
},
"data": JSON.stringify({
query: "mutation edit_customer($customer_data : CustomerEdit!){\r\n editCustomer(input:$customer_data)\r\n}",
variables: {"customer_data":{"firstname":"user1","lastname":"11","email":"user1@test.com","telephone":"8888888888","fax":"676767","custom_field":""}}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMjM0ODAxLCJuYmYiOjE2NjMyMzQ4MDYsImV4cCI6MTY2MzIzNTYwMSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.23pUsa2Vn3-dQwL84M5ZN7dIgAzQzzlp3YhLVpkynP4',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=53d60509bdbc26bd5e97f9a973; currency=EUR; language=en-gb'
},
body: JSON.stringify({
query: `mutation edit_customer($customer_data : CustomerEdit!){
editCustomer(input:$customer_data)
}`,
variables: {"customer_data":{"firstname":"user1","lastname":"11","email":"user1@test.com","telephone":"8888888888","fax":"676767","custom_field":""}}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation edit_customer($customer_data : CustomerEdit!){\\r\\n editCustomer(input:$customer_data)\\r\\n}\",\"variables\":{\"customer_data\":{\"firstname\":\"user1\",\"lastname\":\"11\",\"email\":\"user1@test.com\",\"telephone\":\"8888888888\",\"fax\":\"676767\",\"custom_field\":\"\"}}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMjM0ODAxLCJuYmYiOjE2NjMyMzQ4MDYsImV4cCI6MTY2MzIzNTYwMSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.23pUsa2Vn3-dQwL84M5ZN7dIgAzQzzlp3YhLVpkynP4',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=53d60509bdbc26bd5e97f9a973; currency=EUR; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMjM0ODAxLCJuYmYiOjE2NjMyMzQ4MDYsImV4cCI6MTY2MzIzNTYwMSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.23pUsa2Vn3-dQwL84M5ZN7dIgAzQzzlp3YhLVpkynP4");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=53d60509bdbc26bd5e97f9a973; currency=EUR; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation edit_customer($customer_data : CustomerEdit!){\\r\\n editCustomer(input:$customer_data)\\r\\n}\",\"variables\":{\"customer_data\":{\"firstname\":\"user1\",\"lastname\":\"11\",\"email\":\"user1@test.com\",\"telephone\":\"8888888888\",\"fax\":\"676767\",\"custom_field\":\"\"}}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMjM0ODAxLCJuYmYiOjE2NjMyMzQ4MDYsImV4cCI6MTY2MzIzNTYwMSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.23pUsa2Vn3-dQwL84M5ZN7dIgAzQzzlp3YhLVpkynP4' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=53d60509bdbc26bd5e97f9a973; currency=EUR; language=en-gb' \
--data-raw '{"query":"mutation edit_customer($customer_data : CustomerEdit!){\r\n editCustomer(input:$customer_data)\r\n}","variables":{"customer_data":{"firstname":"user1","lastname":"11","email":"user1@test.com","telephone":"8888888888","fax":"676767","custom_field":""}}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation edit_customer($customer_data : CustomerEdit!){\\r\\n editCustomer(input:$customer_data)\\r\\n}\",\"variables\":{\"customer_data\":{\"firstname\":\"user1\",\"lastname\":\"11\",\"email\":\"user1@test.com\",\"telephone\":\"2222222222\",\"fax\":\"676767\",\"custom_field\":\"\"}}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMjM0ODAxLCJuYmYiOjE2NjMyMzQ4MDYsImV4cCI6MTY2MzIzNTYwMSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.23pUsa2Vn3-dQwL84M5ZN7dIgAzQzzlp3YhLVpkynP4")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=53d60509bdbc26bd5e97f9a973; currency=EUR; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMjM0ODAxLCJuYmYiOjE2NjMyMzQ4MDYsImV4cCI6MTY2MzIzNTYwMSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.23pUsa2Vn3-dQwL84M5ZN7dIgAzQzzlp3YhLVpkynP4"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=53d60509bdbc26bd5e97f9a973; currency=EUR; language=en-gb"
request.body = "{\"query\":\"mutation edit_customer($customer_data : CustomerEdit!){\\r\\n editCustomer(input:$customer_data)\\r\\n}\",\"variables\":{\"customer_data\":{\"firstname\":\"user1\",\"lastname\":\"11\",\"email\":\"user1@test.com\",\"telephone\":\"8938818287\",\"fax\":\"676767\",\"custom_field\":\"\"}}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"editCustomer": true
}
}
Opencart password edit API
The password user API allow you to change user password.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| Token | string |
Authorization |
Required |
Bearer token |
| firstname | string |
Body |
Required |
First name is belongs to user's first name |
| lastname | string |
Body |
Required |
Last name is belongs to user's surname |
| Parameter | Token |
|---|---|
| Type | string |
| Position | Authorization |
| # | Required |
| Description | Brearer Token |
| Parameter | password |
| Type | string |
| Position | Body |
| # | Required |
| Description | user password |
| Parameter | confirm |
| Type | string |
| Position | Body |
| # | Required |
| Description | confirm password. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation edit_password($password:String!,$confirm:String!){\\r\\n editPassword(password:$password,confirm:$confirm)\\r\\n}","variables":{"password":"2233","confirm":"2233"}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTA0MzYzLCJuYmYiOjE2NjM1MDQzNjgsImV4cCI6MTY2MzUwNTE2MywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.GBLfbfCnD1jP_dLGrIMz-dsQbK0eYAUyJ341WnAGZXQ',
'Content-Type: application/json',
'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTA0MzYzLCJuYmYiOjE2NjM1MDQzNjgsImV4cCI6MTY2MzUwNTE2MywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.GBLfbfCnD1jP_dLGrIMz-dsQbK0eYAUyJ341WnAGZXQ",
"Content-Type": "application/json",
"Cookie": "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation edit_password($password:String!,$confirm:String!){\r\n editPassword(password:$password,confirm:$confirm)\r\n}",
variables: {"password":"2233","confirm":"2233"}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTA0MzYzLCJuYmYiOjE2NjM1MDQzNjgsImV4cCI6MTY2MzUwNTE2MywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.GBLfbfCnD1jP_dLGrIMz-dsQbK0eYAUyJ341WnAGZXQ',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation edit_password($password:String!,$confirm:String!){
editPassword(password:$password,confirm:$confirm)
}`,
variables: {"password":"2233","confirm":"2233"}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation edit_password($password:String!,$confirm:String!){\\r\\n editPassword(password:$password,confirm:$confirm)\\r\\n}\",\"variables\":{\"password\":\"2233\",\"confirm\":\"2233\"}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTA0MzYzLCJuYmYiOjE2NjM1MDQzNjgsImV4cCI6MTY2MzUwNTE2MywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.GBLfbfCnD1jP_dLGrIMz-dsQbK0eYAUyJ341WnAGZXQ',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTA0MzYzLCJuYmYiOjE2NjM1MDQzNjgsImV4cCI6MTY2MzUwNTE2MywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.GBLfbfCnD1jP_dLGrIMz-dsQbK0eYAUyJ341WnAGZXQ");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation edit_password($password:String!,$confirm:String!){\\r\\n editPassword(password:$password,confirm:$confirm)\\r\\n}\",\"variables\":{\"password\":\"2233\",\"confirm\":\"2233\"}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTA0MzYzLCJuYmYiOjE2NjM1MDQzNjgsImV4cCI6MTY2MzUwNTE2MywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.GBLfbfCnD1jP_dLGrIMz-dsQbK0eYAUyJ341WnAGZXQ' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation edit_password($password:String!,$confirm:String!){\r\n editPassword(password:$password,confirm:$confirm)\r\n}","variables":{"password":"2233","confirm":"2233"}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation edit_password($password:String!,$confirm:String!){\\r\\n editPassword(password:$password,confirm:$confirm)\\r\\n}\",\"variables\":{\"password\":\"2233\",\"confirm\":\"2233\"}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTA0MzYzLCJuYmYiOjE2NjM1MDQzNjgsImV4cCI6MTY2MzUwNTE2MywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.GBLfbfCnD1jP_dLGrIMz-dsQbK0eYAUyJ341WnAGZXQ")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTA0MzYzLCJuYmYiOjE2NjM1MDQzNjgsImV4cCI6MTY2MzUwNTE2MywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.GBLfbfCnD1jP_dLGrIMz-dsQbK0eYAUyJ341WnAGZXQ"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation edit_password($password:String!,$confirm:String!){\\r\\n editPassword(password:$password,confirm:$confirm)\\r\\n}\",\"variables\":{\"password\":\"2233\",\"confirm\":\"2233\"}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"editPassword": true
}
}
Opencart user add address API
The add user address API allow you add address.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| Token | string |
Authorization |
Required |
Bearer token |
| firstname | string |
Body GRAPHQL VARIABLES
|
Required |
First name is belongs to user's first name |
| lastname | string |
Body GRAPHQL VARIABLES
|
Required |
Last name is belongs to user's surname |
| company | string |
Body GRAPHQL VARIABLES
|
Required |
User company name. |
| address_1 | string |
Body GRAPHQL VARIABLES
|
Required |
User address. |
| address_2 | string |
Body GRAPHQL VARIABLES
|
Required |
User address. |
| postcode | string |
Body GRAPHQL VARIABLES
|
Required |
User postcode. |
| city | string |
Body GRAPHQL VARIABLES
|
Required |
User city. |
| zone_id | ID |
Body GRAPHQL VARIABLES
|
Required |
User zone id. |
| country_id | ID |
Body GRAPHQL VARIABLES
|
Required |
User country id. |
| custom_field | string |
Body GRAPHQL VARIABLES
|
Optional |
user custom_field. |
| default | boolean |
Body GRAPHQL VARIABLES
|
Optional |
user default address. |
| Parameter | Token |
|---|---|
| Type | string |
| Position | Authorization |
| # | Required |
| Description | Brearer Token |
| Parameter | firstname |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | First name is belongs to user's first name |
| Parameter | lastname |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | Last name is belongs to user's surname. |
| Parameter | company |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User company name. |
| Parameter | address_1 |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User address. |
| Parameter | address_2 |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User address. |
| Parameter | postcode |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User postcode. |
| Parameter | city |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User city. |
| Parameter | zone_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User zone id. |
| Parameter | country_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User country id. |
| Parameter | custom_field |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user custom_field. |
| Parameter | default |
| Type | boolean |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user default address. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation addaddress($address:AddressInput!){\\r\\n addAddress(input:$address){\\r\\n status\\r\\n address_id\\r\\n message\\r\\n }\\r\\n}","variables":{"address":{"firstname":"test","lastname":"2","company":"abvfg","address_1":"tytytytyty","address_2":"yyuuyy","postcode":"202001","city":"aligarh","zone_id":"2","country_id":"33","custom_field":""}}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzkxODY3LCJuYmYiOjE2NjMzOTE4NzIsImV4cCI6MTY2MzM5MjY2NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.65dLKLTzsOVrg6ax4W8LiAzVZcatqsEuHUfufE91Oi4',
'Content-Type: application/json',
'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzkxODY3LCJuYmYiOjE2NjMzOTE4NzIsImV4cCI6MTY2MzM5MjY2NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.65dLKLTzsOVrg6ax4W8LiAzVZcatqsEuHUfufE91Oi4",
"Content-Type": "application/json",
"Cookie": "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation addaddress($address:AddressInput!){\r\n addAddress(input:$address){\r\n status\r\n address_id\r\n message\r\n }\r\n}",
variables: {"address":{"firstname":"test","lastname":"2","company":"abvfg","address_1":"tytytytyty","address_2":"yyuuyy","postcode":"202001","city":"aligarh","zone_id":"2","country_id":"33","custom_field":""}}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzkxODY3LCJuYmYiOjE2NjMzOTE4NzIsImV4cCI6MTY2MzM5MjY2NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.65dLKLTzsOVrg6ax4W8LiAzVZcatqsEuHUfufE91Oi4',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation addaddress($address:AddressInput!){
addAddress(input:$address){
status
address_id
message
}
}`,
variables: {"address":{"firstname":"test","lastname":"2","company":"abvfg","address_1":"tytytytyty","address_2":"yyuuyy","postcode":"202001","city":"aligarh","zone_id":"2","country_id":"33","custom_field":""}}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation addaddress($address:AddressInput!){\\r\\n addAddress(input:$address){\\r\\n status\\r\\n address_id\\r\\n message\\r\\n }\\r\\n}\",\"variables\":{\"address\":{\"firstname\":\"test\",\"lastname\":\"2\",\"company\":\"abvfg\",\"address_1\":\"tytytytyty\",\"address_2\":\"yyuuyy\",\"postcode\":\"202001\",\"city\":\"aligarh\",\"zone_id\":\"2\",\"country_id\":\"33\",\"custom_field\":\"\"}}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzkxODY3LCJuYmYiOjE2NjMzOTE4NzIsImV4cCI6MTY2MzM5MjY2NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.65dLKLTzsOVrg6ax4W8LiAzVZcatqsEuHUfufE91Oi4',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzkxODY3LCJuYmYiOjE2NjMzOTE4NzIsImV4cCI6MTY2MzM5MjY2NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.65dLKLTzsOVrg6ax4W8LiAzVZcatqsEuHUfufE91Oi4");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation addaddress($address:AddressInput!){\\r\\n addAddress(input:$address){\\r\\n status\\r\\n address_id\\r\\n message\\r\\n }\\r\\n}\",\"variables\":{\"address\":{\"firstname\":\"test\",\"lastname\":\"2\",\"company\":\"abvfg\",\"address_1\":\"tytytytyty\",\"address_2\":\"yyuuyy\",\"postcode\":\"202001\",\"city\":\"aligarh\",\"zone_id\":\"2\",\"country_id\":\"33\",\"custom_field\":\"\"}}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzkxODY3LCJuYmYiOjE2NjMzOTE4NzIsImV4cCI6MTY2MzM5MjY2NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.65dLKLTzsOVrg6ax4W8LiAzVZcatqsEuHUfufE91Oi4' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation addaddress($address:AddressInput!){\r\n addAddress(input:$address){\r\n status\r\n address_id\r\n message\r\n }\r\n}","variables":{"address":{"firstname":"test","lastname":"2","company":"abvfg","address_1":"tytytytyty","address_2":"yyuuyy","postcode":"202001","city":"aligarh","zone_id":"2","country_id":"33","custom_field":""}}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation addaddress($address:AddressInput!){\\r\\n addAddress(input:$address){\\r\\n status\\r\\n address_id\\r\\n message\\r\\n }\\r\\n}\",\"variables\":{\"address\":{\"firstname\":\"test\",\"lastname\":\"2\",\"company\":\"abvfg\",\"address_1\":\"tytytytyty\",\"address_2\":\"yyuuyy\",\"postcode\":\"202001\",\"city\":\"aligarh\",\"zone_id\":\"2\",\"country_id\":\"33\",\"custom_field\":\"\"}}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzkxODY3LCJuYmYiOjE2NjMzOTE4NzIsImV4cCI6MTY2MzM5MjY2NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.65dLKLTzsOVrg6ax4W8LiAzVZcatqsEuHUfufE91Oi4")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzkxODY3LCJuYmYiOjE2NjMzOTE4NzIsImV4cCI6MTY2MzM5MjY2NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.65dLKLTzsOVrg6ax4W8LiAzVZcatqsEuHUfufE91Oi4"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation addaddress($address:AddressInput!){\\r\\n addAddress(input:$address){\\r\\n status\\r\\n address_id\\r\\n message\\r\\n }\\r\\n}\",\"variables\":{\"address\":{\"firstname\":\"test\",\"lastname\":\"2\",\"company\":\"abvfg\",\"address_1\":\"tytytytyty\",\"address_2\":\"yyuuyy\",\"postcode\":\"202001\",\"city\":\"aligarh\",\"zone_id\":\"2\",\"country_id\":\"33\",\"custom_field\":\"\"}}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"addAddress": {
"status": 1,
"address_id": 14,
"message": "Address added successfully"
}
}
}
Opencart user edit address API
The edit user address API allow you edit address.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| Token | string |
Authorization |
Required |
Bearer token |
| address_id | ID |
Body GRAPHQL VARIABLES
|
Required |
Address id to edit |
| firstname | string |
Body GRAPHQL VARIABLES
|
Required |
First name is belongs to user's first name |
| lastname | string |
Body GRAPHQL VARIABLES
|
Required |
Last name is belongs to user's surname |
| company | string |
Body GRAPHQL VARIABLES
|
Required |
User company name. |
| address_1 | string |
Body GRAPHQL VARIABLES
|
Required |
User address. |
| address_2 | string |
Body GRAPHQL VARIABLES
|
Required |
User address. |
| postcode | string |
Body GRAPHQL VARIABLES
|
Required |
User postcode. |
| city | string |
Body GRAPHQL VARIABLES
|
Required |
User city. |
| zone_id | ID |
Body GRAPHQL VARIABLES
|
Required |
User zone id. |
| country_id | ID |
Body GRAPHQL VARIABLES
|
Required |
User country id. |
| custom_field | string |
Body GRAPHQL VARIABLES
|
Optional |
user custom_field. |
| default | boolean |
Body GRAPHQL VARIABLES
|
Optional |
user default address. |
| Parameter | Token |
|---|---|
| Type | string |
| Position | Authorization |
| # | Required |
| Description | Brearer Token |
| Parameter | address_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | Address id to edit |
| Parameter | firstname |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | First name is belongs to user's first name |
| Parameter | lastname |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | Last name is belongs to user's surname. |
| Parameter | company |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User company name. |
| Parameter | address_1 |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User address. |
| Parameter | address_2 |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User address. |
| Parameter | postcode |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User postcode. |
| Parameter | city |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User city. |
| Parameter | zone_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User zone id. |
| Parameter | country_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User country id. |
| Parameter | custom_field |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user custom_field. |
| Parameter | default |
| Type | boolean |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user default address. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation editaddress($address_id:ID!,$address_data:AddressInput!){\\r\\n editAddress(address_id:$address_id,input:$address_data){\\r\\n status\\r\\n }\\r\\n}","variables":{"address_id":"11","address_data":{"firstname":"test","lastname":"32","company":"yyyy","address_1":"zzzzz","address_2":"yyubbbbbbuyy","postcode":"202001","city":"ttttttt","zone_id":"2","country_id":"33","custom_field":"","default":false}}}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk1MjU2LCJuYmYiOjE2NjMzOTUyNjEsImV4cCI6MTY2MzM5NjA1NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.hKSO4rdmgUWhyHC-67fWVNoUV_xqf2aVaD1AQv1TUcc',
'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk1MjU2LCJuYmYiOjE2NjMzOTUyNjEsImV4cCI6MTY2MzM5NjA1NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.hKSO4rdmgUWhyHC-67fWVNoUV_xqf2aVaD1AQv1TUcc",
"Cookie": "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation editaddress($address_id:ID!,$address_data:AddressInput!){\r\n editAddress(address_id:$address_id,input:$address_data){\r\n status\r\n }\r\n}",
variables: {"address_id":"11","address_data":{"firstname":"test","lastname":"32","company":"yyyy","address_1":"zzzzz","address_2":"yyubbbbbbuyy","postcode":"202001","city":"ttttttt","zone_id":"2","country_id":"33","custom_field":"","default":false}}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Content-Type': 'application/json',
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk1MjU2LCJuYmYiOjE2NjMzOTUyNjEsImV4cCI6MTY2MzM5NjA1NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.hKSO4rdmgUWhyHC-67fWVNoUV_xqf2aVaD1AQv1TUcc',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation editaddress($address_id:ID!,$address_data:AddressInput!){
editAddress(address_id:$address_id,input:$address_data){
status
}
}`,
variables: {"address_id":"11","address_data":{"firstname":"test","lastname":"32","company":"yyyy","address_1":"zzzzz","address_2":"yyubbbbbbuyy","postcode":"202001","city":"ttttttt","zone_id":"2","country_id":"33","custom_field":"","default":false}}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation editaddress($address_id:ID!,$address_data:AddressInput!){\\r\\n editAddress(address_id:$address_id,input:$address_data){\\r\\n status\\r\\n }\\r\\n}\",\"variables\":{\"address_id\":\"11\",\"address_data\":{\"firstname\":\"test\",\"lastname\":\"32\",\"company\":\"yyyy\",\"address_1\":\"zzzzz\",\"address_2\":\"yyubbbbbbuyy\",\"postcode\":\"202001\",\"city\":\"ttttttt\",\"zone_id\":\"2\",\"country_id\":\"33\",\"custom_field\":\"\",\"default\":false}}}"
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk1MjU2LCJuYmYiOjE2NjMzOTUyNjEsImV4cCI6MTY2MzM5NjA1NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.hKSO4rdmgUWhyHC-67fWVNoUV_xqf2aVaD1AQv1TUcc',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk1MjU2LCJuYmYiOjE2NjMzOTUyNjEsImV4cCI6MTY2MzM5NjA1NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.hKSO4rdmgUWhyHC-67fWVNoUV_xqf2aVaD1AQv1TUcc");
request.AddHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation editaddress($address_id:ID!,$address_data:AddressInput!){\\r\\n editAddress(address_id:$address_id,input:$address_data){\\r\\n status\\r\\n }\\r\\n}\",\"variables\":{\"address_id\":\"11\",\"address_data\":{\"firstname\":\"test\",\"lastname\":\"32\",\"company\":\"yyyy\",\"address_1\":\"zzzzz\",\"address_2\":\"yyubbbbbbuyy\",\"postcode\":\"202001\",\"city\":\"ttttttt\",\"zone_id\":\"2\",\"country_id\":\"33\",\"custom_field\":\"\",\"default\":false}}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk1MjU2LCJuYmYiOjE2NjMzOTUyNjEsImV4cCI6MTY2MzM5NjA1NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.hKSO4rdmgUWhyHC-67fWVNoUV_xqf2aVaD1AQv1TUcc' \
--header 'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation editaddress($address_id:ID!,$address_data:AddressInput!){\r\n editAddress(address_id:$address_id,input:$address_data){\r\n status\r\n }\r\n}","variables":{"address_id":"11","address_data":{"firstname":"test","lastname":"32","company":"yyyy","address_1":"zzzzz","address_2":"yyubbbbbbuyy","postcode":"202001","city":"ttttttt","zone_id":"2","country_id":"33","custom_field":"","default":false}}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation editaddress($address_id:ID!,$address_data:AddressInput!){\\r\\n editAddress(address_id:$address_id,input:$address_data){\\r\\n status\\r\\n }\\r\\n}\",\"variables\":{\"address_id\":\"11\",\"address_data\":{\"firstname\":\"test\",\"lastname\":\"32\",\"company\":\"yyyy\",\"address_1\":\"zzzzz\",\"address_2\":\"yyubbbbbbuyy\",\"postcode\":\"202001\",\"city\":\"ttttttt\",\"zone_id\":\"2\",\"country_id\":\"33\",\"custom_field\":\"\",\"default\":false}}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk1MjU2LCJuYmYiOjE2NjMzOTUyNjEsImV4cCI6MTY2MzM5NjA1NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.hKSO4rdmgUWhyHC-67fWVNoUV_xqf2aVaD1AQv1TUcc")
.addHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk1MjU2LCJuYmYiOjE2NjMzOTUyNjEsImV4cCI6MTY2MzM5NjA1NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.hKSO4rdmgUWhyHC-67fWVNoUV_xqf2aVaD1AQv1TUcc"
request["Cookie"] = "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation editaddress($address_id:ID!,$address_data:AddressInput!){\\r\\n editAddress(address_id:$address_id,input:$address_data){\\r\\n status\\r\\n }\\r\\n}\",\"variables\":{\"address_id\":\"11\",\"address_data\":{\"firstname\":\"test\",\"lastname\":\"32\",\"company\":\"yyyy\",\"address_1\":\"zzzzz\",\"address_2\":\"yyubbbbbbuyy\",\"postcode\":\"202001\",\"city\":\"ttttttt\",\"zone_id\":\"2\",\"country_id\":\"33\",\"custom_field\":\"\",\"default\":false}}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"editAddress": {
"status": 1
}
}
}
Opencart user delete address API
The delete user address API allow you delete address.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| Token | string |
Authorization |
Required |
Bearer token |
| address_id | ID |
Body GRAPHQL VARIABLES
|
Required |
Address id to delete |
| Parameter | Token |
|---|---|
| Type | string |
| Position | Authorization |
| # | Required |
| Description | Brearer Token |
| Parameter | address_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | Address id to delete |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation deleteaddress($address_id:ID!){\\r\\n deleteAddress(address_id:$address_id){\\r\\n status\\r\\n }\\r\\n}","variables":{"address_id":"11"}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk3MDQ1LCJuYmYiOjE2NjMzOTcwNTAsImV4cCI6MTY2MzM5Nzg0NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.9v-9BQJk0B_PZ0wd-CRaOZDQHZwK-Rv-KjKsHwI6-K4',
'Content-Type: application/json',
'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk3MDQ1LCJuYmYiOjE2NjMzOTcwNTAsImV4cCI6MTY2MzM5Nzg0NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.9v-9BQJk0B_PZ0wd-CRaOZDQHZwK-Rv-KjKsHwI6-K4",
"Content-Type": "application/json",
"Cookie": "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation deleteaddress($address_id:ID!){\r\n deleteAddress(address_id:$address_id){\r\n status\r\n }\r\n}",
variables: {"address_id":"11"}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk3MDQ1LCJuYmYiOjE2NjMzOTcwNTAsImV4cCI6MTY2MzM5Nzg0NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.9v-9BQJk0B_PZ0wd-CRaOZDQHZwK-Rv-KjKsHwI6-K4',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation deleteaddress($address_id:ID!){
deleteAddress(address_id:$address_id){
status
}
}`,
variables: {"address_id":"11"}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation deleteaddress($address_id:ID!){\\r\\n deleteAddress(address_id:$address_id){\\r\\n status\\r\\n }\\r\\n}\",\"variables\":{\"address_id\":\"11\"}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk3MDQ1LCJuYmYiOjE2NjMzOTcwNTAsImV4cCI6MTY2MzM5Nzg0NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.9v-9BQJk0B_PZ0wd-CRaOZDQHZwK-Rv-KjKsHwI6-K4',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk3MDQ1LCJuYmYiOjE2NjMzOTcwNTAsImV4cCI6MTY2MzM5Nzg0NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.9v-9BQJk0B_PZ0wd-CRaOZDQHZwK-Rv-KjKsHwI6-K4");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation deleteaddress($address_id:ID!){\\r\\n deleteAddress(address_id:$address_id){\\r\\n status\\r\\n }\\r\\n}\",\"variables\":{\"address_id\":\"11\"}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk3MDQ1LCJuYmYiOjE2NjMzOTcwNTAsImV4cCI6MTY2MzM5Nzg0NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.9v-9BQJk0B_PZ0wd-CRaOZDQHZwK-Rv-KjKsHwI6-K4' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation deleteaddress($address_id:ID!){\r\n deleteAddress(address_id:$address_id){\r\n status\r\n }\r\n}","variables":{"address_id":"11"}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation deleteaddress($address_id:ID!){\\r\\n deleteAddress(address_id:$address_id){\\r\\n status\\r\\n }\\r\\n}\",\"variables\":{\"address_id\":\"11\"}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk3MDQ1LCJuYmYiOjE2NjMzOTcwNTAsImV4cCI6MTY2MzM5Nzg0NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.9v-9BQJk0B_PZ0wd-CRaOZDQHZwK-Rv-KjKsHwI6-K4")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk3MDQ1LCJuYmYiOjE2NjMzOTcwNTAsImV4cCI6MTY2MzM5Nzg0NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.9v-9BQJk0B_PZ0wd-CRaOZDQHZwK-Rv-KjKsHwI6-K4"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation deleteaddress($address_id:ID!){\\r\\n deleteAddress(address_id:$address_id){\\r\\n status\\r\\n }\\r\\n}\",\"variables\":{\"address_id\":\"11\"}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"deleteAddress": {
"status": 1
}
}
}
Opencart user add order API
The add user order API allow you add order.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| token | string |
Authorization |
Required |
Bearer token |
| invoice_prefix | string |
Body GRAPHQL VARIABLES |
Optional |
Order invoice prefix |
| store_id | ID |
Body GRAPHQL VARIABLES
|
Optional |
Store id |
| store_name | string |
Body GRAPHQL VARIABLES
|
Required |
Store name |
| store_url | string |
Body GRAPHQL VARIABLES
|
Optional |
Store url |
| customer_id | ID |
Body GRAPHQL VARIABLES
|
Required |
User id. |
| customer_group_id | ID |
Body GRAPHQL VARIABLES
|
Optional |
Customer group id. |
| firstname | string |
Body GRAPHQL VARIABLES
|
Required |
First name is belongs to user's first name |
| lastname | string |
Body GRAPHQL VARIABLES
|
Required |
Last name is belongs to user's surname |
string |
Body GRAPHQL VARIABLES
|
Required |
User email. | |
| telephone | string |
Body GRAPHQL VARIABLES
|
Required |
User telephone. |
| fax | string |
Body GRAPHQL VARIABLES
|
Required |
User fax. |
| custom_field | string |
Body GRAPHQL VARIABLES
|
Optional |
user custom_field. |
| payment_firstname | string |
Body GRAPHQL VARIABLES
|
Required |
User payment first name. |
| payment_lastname | string |
Body GRAPHQL VARIABLES
|
Required |
User payment last name. |
| payment_company | string |
Body GRAPHQL VARIABLES
|
Required |
User payment company name. |
| payment_address_1 | string |
Body GRAPHQL VARIABLES
|
Required |
User payment address. |
| payment_address_2 | string |
Body GRAPHQL VARIABLES
|
Required |
User payment address. |
| payment_city | string |
Body GRAPHQL VARIABLES
|
Required |
User payment city. |
| payment_postcode | string |
Body GRAPHQL VARIABLES
|
Required |
User payment postcode. |
| payment_country | string |
Body GRAPHQL VARIABLES
|
Required |
User payment country. |
| payment_country_id | ID |
Body GRAPHQL VARIABLES
|
Required |
User payment country id. |
| payment_zone | string |
Body GRAPHQL VARIABLES
|
Required |
User payment zone. |
| payment_zone_id | ID |
Body GRAPHQL VARIABLES
|
Required |
User payment zone id. |
| payment_custom_field | ID |
Body GRAPHQL VARIABLES
|
Optional |
User payment custom_field. |
| payment_method | string |
Body GRAPHQL VARIABLES
|
Required |
User payment method. |
| payment_code | string |
Body GRAPHQL VARIABLES
|
Required |
User payment method code. |
| shipping_firstname | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping first name. |
| shipping_lastname | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping last name. |
| shipping_company | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping company name. |
| shipping_address_1 | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping address. |
| shipping_address_2 | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping address. |
| shipping_city | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping city. |
| shipping_postcode | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping postcode. |
| shipping_country | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping country. |
| shipping_country_id | ID |
Body GRAPHQL VARIABLES
|
Required |
User shipping country id. |
| shipping_zone | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping zone. |
| shipping_zone_id | ID |
Body GRAPHQL VARIABLES
|
Required |
User shipping zone id. |
| shipping_custom_field | ID |
Body GRAPHQL VARIABLES
|
Optional |
User shipping custom_field. |
| shipping_method | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping method. |
| shipping_code | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping method code. |
| comment | string |
Body GRAPHQL VARIABLES
|
Optional |
User comment. |
| total | string |
Body GRAPHQL VARIABLES
|
Optional |
User order total. |
| affiliate_id | ID |
Body GRAPHQL VARIABLES
|
Optional |
User affiliate_id. |
| commission | float |
Body GRAPHQL VARIABLES
|
Optional |
User commission. |
| marketing_id | ID |
Body GRAPHQL VARIABLES
|
Optional |
User marketing_id. |
| tracking | string |
Body GRAPHQL VARIABLES
|
Optional |
User tracking. |
| language_id | ID |
Body GRAPHQL VARIABLES
|
Optional |
User language_id. |
| currency_id | ID |
Body GRAPHQL VARIABLES
|
Optional |
User currency_id. |
| currency_code | float |
Body GRAPHQL VARIABLES
|
Optional |
User currency code. |
| currency_value | string |
Body GRAPHQL VARIABLES
|
Optional |
User currency value. |
| currency_value | string |
Body GRAPHQL VARIABLES
|
Optional |
User currency value. |
| ip | string |
Body GRAPHQL VARIABLES
|
Optional |
User ip. |
| products | OrderProductInput |
Body GRAPHQL VARIABLES
|
Optional |
User order product. |
| Parameter | Token |
|---|---|
| Type | string |
| Position | Authorization |
| # | Required |
| Description | Brearer Token |
| Parameter | invoice_prefix |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | Order invoice prefix |
| Parameter | store_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | Store name |
| Parameter | store_url |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | Store url. |
| Parameter | customer_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User id. |
| Parameter | customer_group_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | Customer group id. |
| Parameter | firstname |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | First name is belongs to user's first name. |
| Parameter | lastname |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User lastname. |
| Parameter | |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User email. |
| Parameter | telephone |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User telephone. |
| Parameter | fax |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User fax. |
| Parameter | custom_field |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | User custom_field. |
| Parameter | payment_firstname |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User payment first name. |
| Parameter | payment_lastname |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User payment lastname. |
| Parameter | payment_company |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user payment company. |
| Parameter | payment_address_1 |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user payment address. |
| Parameter | payment_address_2 |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user payment address. |
| Parameter | payment_city |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | userpayment city. |
| Parameter | payment_postcode |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user payment postcode. |
| Parameter | payment_country |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user payment country. |
| Parameter | payment_country_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user payment country id. |
| Parameter | payment_zone |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user payment zone. |
| Parameter | payment_zone_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user payment zone id. |
| Parameter | payment_custom_field |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user payment custom field. |
| Parameter | payment_method |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user payment method. |
| Parameter | payment_code |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user payment code. |
| Parameter | shipping_firstname |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User shipping first name. |
| Parameter | shipping_lastname |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User shipping lastname. |
| Parameter | shipping_company |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user shipping company. |
| Parameter | shipping_address_1 |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user shipping address. |
| Parameter | shipping_address_2 |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user shipping address. |
| Parameter | shipping_city |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user shipping city. |
| Parameter | shipping_postcode |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user shipping postcode. |
| Parameter | shipping_country |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user shipping country. |
| Parameter | shipping_country_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user shipping country id. |
| Parameter | shipping_zone |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user shipping zone. |
| Parameter | shipping_zone_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user shipping zone id. |
| Parameter | shipping_custom_field |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user shipping custom field. |
| Parameter | shipping_method |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user shipping method. |
| Parameter | shipping_code |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user shipping code. |
| Parameter | comment |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user comment. |
| Parameter | total |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user total. |
| Parameter | affiliate_id |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user affiliate id. |
| Parameter | commission |
| Type | float |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user commission. |
| Parameter | marketing_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user marketing id. |
| Parameter | tracking |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user tracking. |
| Parameter | language_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user language id. |
| Parameter | currency_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user currency id. |
| Parameter | currency_code |
| Type | Float |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user currency code. |
| Parameter | currency_value |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user currency value. |
| Parameter | ip |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user ip. |
| products | ip |
| Type | OrderProductInput |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user order products. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation addOrder($order_data:OrderInput!){\\r\\n addOrder(input:$order_data){\\r\\n status\\r\\n message\\r\\n order_id\\r\\n }\\r\\n}","variables":{"order_data":{"invoice_prefix":"INV-2022-00","store_id":"1","store_name":"Your Store","store_url":"rererereer","customer_id":"1","firstname":"user","lastname":"1","email":"user1@test.com","telephone":"9898989898","fax":"rrrr","payment_firstname":"user1","payment_lastname":"1","payment_company":"abc","payment_address_1":"uyuyuy","payment_address_2":"hjhkjhgbjhy","payment_city":"alg","payment_postcode":"343434","payment_country":"india","payment_country_id":"99","payment_zone":"Uttar Pradesh","payment_zone_id":"1505","payment_address_format":"eeee","payment_method":"Cash On Delivery","payment_code":"cod","shipping_firstname":"user","shipping_lastname":"1","shipping_company":"abc","shipping_address_1":"addresss1","shipping_address_2":"rrr","shipping_city":"aligarh","shipping_postcode":"202001","shipping_country":"India","shipping_country_id":"99","shipping_zone":"Uttar Pradesh","shipping_zone_id":"1505","shipping_address_format":"tttt","shipping_method":"Flat Rate Shipping","shipping_code":"flat.flat","comment":"ddddd","user_agent":"yttyty","products":{"OrderProductInput":{"product_id":"30","name":"Canon EOS 5D","model":"Product 3","quantity":1,"price":100,"total":100,"tax":0,"reward":0,"option":{"OrderProductOptionInput":{"product_option_id":"226","product_option_value_id":"1","name":"select","value":"red","type":"select"}}}}}}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDAzMDk1LCJuYmYiOjE2NjM0MDMxMDAsImV4cCI6MTY2MzQwMzg5NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.ERcWxiPRDe7yAEBAUKxrxaUFXTv5D7YTrN5ZBP7JUAs',
'Content-Type: application/json',
'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDAzMDk1LCJuYmYiOjE2NjM0MDMxMDAsImV4cCI6MTY2MzQwMzg5NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.ERcWxiPRDe7yAEBAUKxrxaUFXTv5D7YTrN5ZBP7JUAs",
"Content-Type": "application/json",
"Cookie": "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation addOrder($order_data:OrderInput!){\r\n addOrder(input:$order_data){\r\n status\r\n message\r\n order_id\r\n }\r\n}",
variables: {"order_data":{"invoice_prefix":"INV-2022-00","store_id":"1","store_name":"Your Store","store_url":"rererereer","customer_id":"1","firstname":"user","lastname":"1","email":"user1@test.com","telephone":"9898989898","fax":"rrrr","payment_firstname":"user1","payment_lastname":"1","payment_company":"abc","payment_address_1":"uyuyuy","payment_address_2":"hjhkjhgbjhy","payment_city":"alg","payment_postcode":"343434","payment_country":"india","payment_country_id":"99","payment_zone":"Uttar Pradesh","payment_zone_id":"1505","payment_address_format":"eeee","payment_method":"Cash On Delivery","payment_code":"cod","shipping_firstname":"user","shipping_lastname":"1","shipping_company":"abc","shipping_address_1":"addresss1","shipping_address_2":"rrr","shipping_city":"aligarh","shipping_postcode":"202001","shipping_country":"India","shipping_country_id":"99","shipping_zone":"Uttar Pradesh","shipping_zone_id":"1505","shipping_address_format":"tttt","shipping_method":"Flat Rate Shipping","shipping_code":"flat.flat","comment":"ddddd","user_agent":"yttyty","products":{"OrderProductInput":{"product_id":"30","name":"Canon EOS 5D","model":"Product 3","quantity":1,"price":100,"total":100,"tax":0,"reward":0,"option":{"OrderProductOptionInput":{"product_option_id":"226","product_option_value_id":"1","name":"select","value":"red","type":"select"}}}}}}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDAzMDk1LCJuYmYiOjE2NjM0MDMxMDAsImV4cCI6MTY2MzQwMzg5NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.ERcWxiPRDe7yAEBAUKxrxaUFXTv5D7YTrN5ZBP7JUAs',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation addOrder($order_data:OrderInput!){
addOrder(input:$order_data){
status
message
order_id
}
}`,
variables: {"order_data":{"invoice_prefix":"INV-2022-00","store_id":"1","store_name":"Your Store","store_url":"rererereer","customer_id":"1","firstname":"user","lastname":"1","email":"user1@test.com","telephone":"9898989898","fax":"rrrr","payment_firstname":"user1","payment_lastname":"1","payment_company":"abc","payment_address_1":"uyuyuy","payment_address_2":"hjhkjhgbjhy","payment_city":"alg","payment_postcode":"343434","payment_country":"india","payment_country_id":"99","payment_zone":"Uttar Pradesh","payment_zone_id":"1505","payment_address_format":"eeee","payment_method":"Cash On Delivery","payment_code":"cod","shipping_firstname":"user","shipping_lastname":"1","shipping_company":"abc","shipping_address_1":"addresss1","shipping_address_2":"rrr","shipping_city":"aligarh","shipping_postcode":"202001","shipping_country":"India","shipping_country_id":"99","shipping_zone":"Uttar Pradesh","shipping_zone_id":"1505","shipping_address_format":"tttt","shipping_method":"Flat Rate Shipping","shipping_code":"flat.flat","comment":"ddddd","user_agent":"yttyty","products":{"OrderProductInput":{"product_id":"30","name":"Canon EOS 5D","model":"Product 3","quantity":1,"price":100,"total":100,"tax":0,"reward":0,"option":{"OrderProductOptionInput":{"product_option_id":"226","product_option_value_id":"1","name":"select","value":"red","type":"select"}}}}}}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation addOrder($order_data:OrderInput!){\\r\\n addOrder(input:$order_data){\\r\\n status\\r\\n message\\r\\n order_id\\r\\n }\\r\\n}\",\"variables\":{\"order_data\":{\"invoice_prefix\":\"INV-2022-00\",\"store_id\":\"1\",\"store_name\":\"Your Store\",\"store_url\":\"rererereer\",\"customer_id\":\"1\",\"firstname\":\"user\",\"lastname\":\"1\",\"email\":\"user1@test.com\",\"telephone\":\"9898989898\",\"fax\":\"rrrr\",\"payment_firstname\":\"user1\",\"payment_lastname\":\"1\",\"payment_company\":\"abc\",\"payment_address_1\":\"uyuyuy\",\"payment_address_2\":\"hjhkjhgbjhy\",\"payment_city\":\"alg\",\"payment_postcode\":\"343434\",\"payment_country\":\"india\",\"payment_country_id\":\"99\",\"payment_zone\":\"Uttar Pradesh\",\"payment_zone_id\":\"1505\",\"payment_address_format\":\"eeee\",\"payment_method\":\"Cash On Delivery\",\"payment_code\":\"cod\",\"shipping_firstname\":\"user\",\"shipping_lastname\":\"1\",\"shipping_company\":\"abc\",\"shipping_address_1\":\"addresss1\",\"shipping_address_2\":\"rrr\",\"shipping_city\":\"aligarh\",\"shipping_postcode\":\"202001\",\"shipping_country\":\"India\",\"shipping_country_id\":\"99\",\"shipping_zone\":\"Uttar Pradesh\",\"shipping_zone_id\":\"1505\",\"shipping_address_format\":\"tttt\",\"shipping_method\":\"Flat Rate Shipping\",\"shipping_code\":\"flat.flat\",\"comment\":\"ddddd\",\"user_agent\":\"yttyty\",\"products\":{\"OrderProductInput\":{\"product_id\":\"30\",\"name\":\"Canon EOS 5D\",\"model\":\"Product 3\",\"quantity\":1,\"price\":100,\"total\":100,\"tax\":0,\"reward\":0,\"option\":{\"OrderProductOptionInput\":{\"product_option_id\":\"226\",\"product_option_value_id\":\"1\",\"name\":\"select\",\"value\":\"red\",\"type\":\"select\"}}}}}}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDAzMDk1LCJuYmYiOjE2NjM0MDMxMDAsImV4cCI6MTY2MzQwMzg5NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.ERcWxiPRDe7yAEBAUKxrxaUFXTv5D7YTrN5ZBP7JUAs',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDAzMDk1LCJuYmYiOjE2NjM0MDMxMDAsImV4cCI6MTY2MzQwMzg5NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.ERcWxiPRDe7yAEBAUKxrxaUFXTv5D7YTrN5ZBP7JUAs");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation addOrder($order_data:OrderInput!){\\r\\n addOrder(input:$order_data){\\r\\n status\\r\\n message\\r\\n order_id\\r\\n }\\r\\n}\",\"variables\":{\"order_data\":{\"invoice_prefix\":\"INV-2022-00\",\"store_id\":\"1\",\"store_name\":\"Your Store\",\"store_url\":\"rererereer\",\"customer_id\":\"1\",\"firstname\":\"user\",\"lastname\":\"1\",\"email\":\"user1@test.com\",\"telephone\":\"9898989898\",\"fax\":\"rrrr\",\"payment_firstname\":\"user1\",\"payment_lastname\":\"1\",\"payment_company\":\"abc\",\"payment_address_1\":\"uyuyuy\",\"payment_address_2\":\"hjhkjhgbjhy\",\"payment_city\":\"alg\",\"payment_postcode\":\"343434\",\"payment_country\":\"india\",\"payment_country_id\":\"99\",\"payment_zone\":\"Uttar Pradesh\",\"payment_zone_id\":\"1505\",\"payment_address_format\":\"eeee\",\"payment_method\":\"Cash On Delivery\",\"payment_code\":\"cod\",\"shipping_firstname\":\"user\",\"shipping_lastname\":\"1\",\"shipping_company\":\"abc\",\"shipping_address_1\":\"addresss1\",\"shipping_address_2\":\"rrr\",\"shipping_city\":\"aligarh\",\"shipping_postcode\":\"202001\",\"shipping_country\":\"India\",\"shipping_country_id\":\"99\",\"shipping_zone\":\"Uttar Pradesh\",\"shipping_zone_id\":\"1505\",\"shipping_address_format\":\"tttt\",\"shipping_method\":\"Flat Rate Shipping\",\"shipping_code\":\"flat.flat\",\"comment\":\"ddddd\",\"user_agent\":\"yttyty\",\"products\":{\"OrderProductInput\":{\"product_id\":\"30\",\"name\":\"Canon EOS 5D\",\"model\":\"Product 3\",\"quantity\":1,\"price\":100,\"total\":100,\"tax\":0,\"reward\":0,\"option\":{\"OrderProductOptionInput\":{\"product_option_id\":\"226\",\"product_option_value_id\":\"1\",\"name\":\"select\",\"value\":\"red\",\"type\":\"select\"}}}}}}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDAzMDk1LCJuYmYiOjE2NjM0MDMxMDAsImV4cCI6MTY2MzQwMzg5NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.ERcWxiPRDe7yAEBAUKxrxaUFXTv5D7YTrN5ZBP7JUAs' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation addOrder($order_data:OrderInput!){\r\n addOrder(input:$order_data){\r\n status\r\n message\r\n order_id\r\n }\r\n}","variables":{"order_data":{"invoice_prefix":"INV-2022-00","store_id":"1","store_name":"Your Store","store_url":"rererereer","customer_id":"1","firstname":"user","lastname":"1","email":"user1@test.com","telephone":"9898989898","fax":"rrrr","payment_firstname":"user1","payment_lastname":"1","payment_company":"abc","payment_address_1":"uyuyuy","payment_address_2":"hjhkjhgbjhy","payment_city":"alg","payment_postcode":"343434","payment_country":"india","payment_country_id":"99","payment_zone":"Uttar Pradesh","payment_zone_id":"1505","payment_address_format":"eeee","payment_method":"Cash On Delivery","payment_code":"cod","shipping_firstname":"user","shipping_lastname":"1","shipping_company":"abc","shipping_address_1":"addresss1","shipping_address_2":"rrr","shipping_city":"aligarh","shipping_postcode":"202001","shipping_country":"India","shipping_country_id":"99","shipping_zone":"Uttar Pradesh","shipping_zone_id":"1505","shipping_address_format":"tttt","shipping_method":"Flat Rate Shipping","shipping_code":"flat.flat","comment":"ddddd","user_agent":"yttyty","products":{"OrderProductInput":{"product_id":"30","name":"Canon EOS 5D","model":"Product 3","quantity":1,"price":100,"total":100,"tax":0,"reward":0,"option":{"OrderProductOptionInput":{"product_option_id":"226","product_option_value_id":"1","name":"select","value":"red","type":"select"}}}}}}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation addOrder($order_data:OrderInput!){\\r\\n addOrder(input:$order_data){\\r\\n status\\r\\n message\\r\\n order_id\\r\\n }\\r\\n}\",\"variables\":{\"order_data\":{\"invoice_prefix\":\"INV-2022-00\",\"store_id\":\"1\",\"store_name\":\"Your Store\",\"store_url\":\"rererereer\",\"customer_id\":\"1\",\"firstname\":\"user\",\"lastname\":\"1\",\"email\":\"user1@test.com\",\"telephone\":\"9898989898\",\"fax\":\"rrrr\",\"payment_firstname\":\"user1\",\"payment_lastname\":\"1\",\"payment_company\":\"abc\",\"payment_address_1\":\"uyuyuy\",\"payment_address_2\":\"hjhkjhgbjhy\",\"payment_city\":\"alg\",\"payment_postcode\":\"343434\",\"payment_country\":\"india\",\"payment_country_id\":\"99\",\"payment_zone\":\"Uttar Pradesh\",\"payment_zone_id\":\"1505\",\"payment_address_format\":\"eeee\",\"payment_method\":\"Cash On Delivery\",\"payment_code\":\"cod\",\"shipping_firstname\":\"user\",\"shipping_lastname\":\"1\",\"shipping_company\":\"abc\",\"shipping_address_1\":\"addresss1\",\"shipping_address_2\":\"rrr\",\"shipping_city\":\"aligarh\",\"shipping_postcode\":\"202001\",\"shipping_country\":\"India\",\"shipping_country_id\":\"99\",\"shipping_zone\":\"Uttar Pradesh\",\"shipping_zone_id\":\"1505\",\"shipping_address_format\":\"tttt\",\"shipping_method\":\"Flat Rate Shipping\",\"shipping_code\":\"flat.flat\",\"comment\":\"ddddd\",\"user_agent\":\"yttyty\",\"products\":{\"OrderProductInput\":{\"product_id\":\"30\",\"name\":\"Canon EOS 5D\",\"model\":\"Product 3\",\"quantity\":1,\"price\":100,\"total\":100,\"tax\":0,\"reward\":0,\"option\":{\"OrderProductOptionInput\":{\"product_option_id\":\"226\",\"product_option_value_id\":\"1\",\"name\":\"select\",\"value\":\"red\",\"type\":\"select\"}}}}}}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDAzMDk1LCJuYmYiOjE2NjM0MDMxMDAsImV4cCI6MTY2MzQwMzg5NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.ERcWxiPRDe7yAEBAUKxrxaUFXTv5D7YTrN5ZBP7JUAs")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDAzMDk1LCJuYmYiOjE2NjM0MDMxMDAsImV4cCI6MTY2MzQwMzg5NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.ERcWxiPRDe7yAEBAUKxrxaUFXTv5D7YTrN5ZBP7JUAs"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation addOrder($order_data:OrderInput!){\\r\\n addOrder(input:$order_data){\\r\\n status\\r\\n message\\r\\n order_id\\r\\n }\\r\\n}\",\"variables\":{\"order_data\":{\"invoice_prefix\":\"INV-2022-00\",\"store_id\":\"1\",\"store_name\":\"Your Store\",\"store_url\":\"rererereer\",\"customer_id\":\"1\",\"firstname\":\"user\",\"lastname\":\"1\",\"email\":\"user1@test.com\",\"telephone\":\"9898989898\",\"fax\":\"rrrr\",\"payment_firstname\":\"user1\",\"payment_lastname\":\"1\",\"payment_company\":\"abc\",\"payment_address_1\":\"uyuyuy\",\"payment_address_2\":\"hjhkjhgbjhy\",\"payment_city\":\"alg\",\"payment_postcode\":\"343434\",\"payment_country\":\"india\",\"payment_country_id\":\"99\",\"payment_zone\":\"Uttar Pradesh\",\"payment_zone_id\":\"1505\",\"payment_address_format\":\"eeee\",\"payment_method\":\"Cash On Delivery\",\"payment_code\":\"cod\",\"shipping_firstname\":\"user\",\"shipping_lastname\":\"1\",\"shipping_company\":\"abc\",\"shipping_address_1\":\"addresss1\",\"shipping_address_2\":\"rrr\",\"shipping_city\":\"aligarh\",\"shipping_postcode\":\"202001\",\"shipping_country\":\"India\",\"shipping_country_id\":\"99\",\"shipping_zone\":\"Uttar Pradesh\",\"shipping_zone_id\":\"1505\",\"shipping_address_format\":\"tttt\",\"shipping_method\":\"Flat Rate Shipping\",\"shipping_code\":\"flat.flat\",\"comment\":\"ddddd\",\"user_agent\":\"yttyty\",\"products\":{\"OrderProductInput\":{\"product_id\":\"30\",\"name\":\"Canon EOS 5D\",\"model\":\"Product 3\",\"quantity\":1,\"price\":100,\"total\":100,\"tax\":0,\"reward\":0,\"option\":{\"OrderProductOptionInput\":{\"product_option_id\":\"226\",\"product_option_value_id\":\"1\",\"name\":\"select\",\"value\":\"red\",\"type\":\"select\"}}}}}}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"addOrder": {
"status": 1,
"message": "order created successfully",
"order_id": 10
}
}
}
Opencart user edit order API
The edit user order API allow you edit order.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| token | string |
Authorization |
Required |
Bearer token |
| order_id | ID |
Body GRAPHQL VARIABLES |
Required |
user order id to edit |
| invoice_prefix | string |
Body GRAPHQL VARIABLES |
Optional |
Order invoice prefix |
| store_id | ID |
Body GRAPHQL VARIABLES
|
Optional |
Store id |
| store_name | string |
Body GRAPHQL VARIABLES
|
Required |
Store name |
| store_url | string |
Body GRAPHQL VARIABLES
|
Optional |
Store url |
| customer_id | ID |
Body GRAPHQL VARIABLES
|
Required |
User id. |
| customer_group_id | ID |
Body GRAPHQL VARIABLES
|
Optional |
Customer group id. |
| firstname | string |
Body GRAPHQL VARIABLES
|
Required |
First name is belongs to user's first name |
| lastname | string |
Body GRAPHQL VARIABLES
|
Required |
Last name is belongs to user's surname |
string |
Body GRAPHQL VARIABLES
|
Required |
User email. | |
| telephone | string |
Body GRAPHQL VARIABLES
|
Required |
User telephone. |
| fax | string |
Body GRAPHQL VARIABLES
|
Required |
User fax. |
| custom_field | string |
Body GRAPHQL VARIABLES
|
Optional |
user custom_field. |
| payment_firstname | string |
Body GRAPHQL VARIABLES
|
Required |
User payment first name. |
| payment_lastname | string |
Body GRAPHQL VARIABLES
|
Required |
User payment last name. |
| payment_company | string |
Body GRAPHQL VARIABLES
|
Required |
User payment company name. |
| payment_address_1 | string |
Body GRAPHQL VARIABLES
|
Required |
User payment address. |
| payment_address_2 | string |
Body GRAPHQL VARIABLES
|
Required |
User payment address. |
| payment_city | string |
Body GRAPHQL VARIABLES
|
Required |
User payment city. |
| payment_postcode | string |
Body GRAPHQL VARIABLES
|
Required |
User payment postcode. |
| payment_country | string |
Body GRAPHQL VARIABLES
|
Required |
User payment country. |
| payment_country_id | ID |
Body GRAPHQL VARIABLES
|
Required |
User payment country id. |
| payment_zone | string |
Body GRAPHQL VARIABLES
|
Required |
User payment zone. |
| payment_zone_id | ID |
Body GRAPHQL VARIABLES
|
Required |
User payment zone id. |
| payment_custom_field | ID |
Body GRAPHQL VARIABLES
|
Optional |
User payment custom_field. |
| payment_method | string |
Body GRAPHQL VARIABLES
|
Required |
User payment method. |
| payment_code | string |
Body GRAPHQL VARIABLES
|
Required |
User payment method code. |
| shipping_firstname | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping first name. |
| shipping_lastname | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping last name. |
| shipping_company | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping company name. |
| shipping_address_1 | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping address. |
| shipping_address_2 | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping address. |
| shipping_city | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping city. |
| shipping_postcode | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping postcode. |
| shipping_country | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping country. |
| shipping_country_id | ID |
Body GRAPHQL VARIABLES
|
Required |
User shipping country id. |
| shipping_zone | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping zone. |
| shipping_zone_id | ID |
Body GRAPHQL VARIABLES
|
Required |
User shipping zone id. |
| shipping_custom_field | ID |
Body GRAPHQL VARIABLES
|
Optional |
User shipping custom_field. |
| shipping_method | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping method. |
| shipping_code | string |
Body GRAPHQL VARIABLES
|
Required |
User shipping method code. |
| comment | string |
Body GRAPHQL VARIABLES
|
Optional |
User comment. |
| total | string |
Body GRAPHQL VARIABLES
|
Optional |
User order total. |
| affiliate_id | ID |
Body GRAPHQL VARIABLES
|
Optional |
User affiliate_id. |
| commission | float |
Body GRAPHQL VARIABLES
|
Optional |
User commission. |
| marketing_id | ID |
Body GRAPHQL VARIABLES
|
Optional |
User marketing_id. |
| tracking | string |
Body GRAPHQL VARIABLES
|
Optional |
User tracking. |
| language_id | ID |
Body GRAPHQL VARIABLES
|
Optional |
User language_id. |
| currency_id | ID |
Body GRAPHQL VARIABLES
|
Optional |
User currency_id. |
| currency_code | float |
Body GRAPHQL VARIABLES
|
Optional |
User currency code. |
| currency_value | string |
Body GRAPHQL VARIABLES
|
Optional |
User currency value. |
| currency_value | string |
Body GRAPHQL VARIABLES
|
Optional |
User currency value. |
| ip | string |
Body GRAPHQL VARIABLES
|
Optional |
User ip. |
| products | OrderProductInput |
Body GRAPHQL VARIABLES
|
Optional |
User order product. |
| Parameter | Token |
|---|---|
| Type | string |
| Position | Authorization |
| # | Required |
| Description | Brearer Token |
| Parameter | order_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user order id to edit order |
| Parameter | invoice_prefix |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | Order invoice prefix |
| Parameter | store_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | Store name |
| Parameter | store_url |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | Store url. |
| Parameter | customer_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User id. |
| Parameter | customer_group_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | Customer group id. |
| Parameter | firstname |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | First name is belongs to user's first name. |
| Parameter | lastname |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User lastname. |
| Parameter | |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User email. |
| Parameter | telephone |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User telephone. |
| Parameter | fax |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User fax. |
| Parameter | custom_field |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | User custom_field. |
| Parameter | payment_firstname |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User payment first name. |
| Parameter | payment_lastname |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User payment lastname. |
| Parameter | payment_company |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user payment company. |
| Parameter | payment_address_1 |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user payment address. |
| Parameter | payment_address_2 |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user payment address. |
| Parameter | payment_city |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | userpayment city. |
| Parameter | payment_postcode |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user payment postcode. |
| Parameter | payment_country |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user payment country. |
| Parameter | payment_country_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user payment country id. |
| Parameter | payment_zone |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user payment zone. |
| Parameter | payment_zone_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user payment zone id. |
| Parameter | payment_custom_field |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user payment custom field. |
| Parameter | payment_method |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user payment method. |
| Parameter | payment_code |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user payment code. |
| Parameter | shipping_firstname |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User shipping first name. |
| Parameter | shipping_lastname |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | User shipping lastname. |
| Parameter | shipping_company |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user shipping company. |
| Parameter | shipping_address_1 |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user shipping address. |
| Parameter | shipping_address_2 |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user shipping address. |
| Parameter | shipping_city |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user shipping city. |
| Parameter | shipping_postcode |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user shipping postcode. |
| Parameter | shipping_country |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user shipping country. |
| Parameter | shipping_country_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user shipping country id. |
| Parameter | shipping_zone |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user shipping zone. |
| Parameter | shipping_zone_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user shipping zone id. |
| Parameter | shipping_custom_field |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user shipping custom field. |
| Parameter | shipping_method |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user shipping method. |
| Parameter | shipping_code |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | user shipping code. |
| Parameter | comment |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user comment. |
| Parameter | total |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user total. |
| Parameter | affiliate_id |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user affiliate id. |
| Parameter | commission |
| Type | float |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user commission. |
| Parameter | marketing_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user marketing id. |
| Parameter | tracking |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user tracking. |
| Parameter | language_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user language id. |
| Parameter | currency_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user currency id. |
| Parameter | currency_code |
| Type | Float |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user currency code. |
| Parameter | currency_value |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user currency value. |
| Parameter | ip |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user ip. |
| products | ip |
| Type | OrderProductInput |
| Position | Body GRAPHQL VARIABLES |
| # | Optional |
| Description | user order products. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation editorder($order_id:ID!, $order_data:OrderInput!){\\r\\n editOrder(order_id:$order_id,input:$order_data){\\r\\n order_id\\r\\n status\\r\\n message\\r\\n }\\r\\n}","variables":{"order_id":"9","order_data":{"invoice_prefix":"INV-2022-00","store_id":"1","store_name":"Your Store","store_url":"tttttttt","customer_id":"1","customer_group_id":"1","firstname":"user","lastname":"1","email":"user15@test.com","telephone":"9898989898","fax":"rrrr","custom_field":"","payment_firstname":"user1","payment_lastname":"1","payment_company":"abc","payment_address_1":"uyuyuy","payment_address_2":"hjhkjhgbjhy","payment_city":"alg","payment_postcode":"343434","payment_country":"india","payment_country_id":"99","payment_zone":"Uttar Pradesh","payment_zone_id":"1505","payment_address_format":"eeee","payment_method":"Cash On Delivery","payment_code":"cod","payment_custom_field":"","shipping_firstname":"user","shipping_lastname":"1","shipping_company":"abc","shipping_address_1":"addresss1","shipping_address_2":"rrr","shipping_city":"aligarh","shipping_postcode":"202001","shipping_country":"India","shipping_country_id":"99","shipping_zone":"Uttar Pradesh","shipping_zone_id":"1505","shipping_address_format":"tttt","shipping_method":"Flat Rate Shipping","shipping_code":"flat.flat","shipping_custom_field":"","comment":"ddddd","user_agent":"yttyty","total":100,"affiliate_id":"","commission":0,"products":{"OrderProductInput":{"product_id":"30","name":"Canon EOS 5D","model":"Product 3","quantity":1,"price":100,"total":100,"tax":0,"reward":0,"option":{"OrderProductOptionInput":{"product_option_id":"226","product_option_value_id":"1","name":"select","value":"red","type":"select"}}}}}}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDA2MTY0LCJuYmYiOjE2NjM0MDYxNjksImV4cCI6MTY2MzQwNjk2NCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.3xt3RKSrTFXIJpI6QYsDTO8ThtMIC-P0ek0MO3w0JPQ',
'Content-Type: application/json',
'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDA2MTY0LCJuYmYiOjE2NjM0MDYxNjksImV4cCI6MTY2MzQwNjk2NCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.3xt3RKSrTFXIJpI6QYsDTO8ThtMIC-P0ek0MO3w0JPQ",
"Content-Type": "application/json",
"Cookie": "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation editorder($order_id:ID!, $order_data:OrderInput!){\r\n editOrder(order_id:$order_id,input:$order_data){\r\n order_id\r\n status\r\n message\r\n }\r\n}",
variables: {"order_id":"9","order_data":{"invoice_prefix":"INV-2022-00","store_id":"1","store_name":"Your Store","store_url":"tttttttt","customer_id":"1","customer_group_id":"1","firstname":"user","lastname":"1","email":"user15@test.com","telephone":"9898989898","fax":"rrrr","custom_field":"","payment_firstname":"user1","payment_lastname":"1","payment_company":"abc","payment_address_1":"uyuyuy","payment_address_2":"hjhkjhgbjhy","payment_city":"alg","payment_postcode":"343434","payment_country":"india","payment_country_id":"99","payment_zone":"Uttar Pradesh","payment_zone_id":"1505","payment_address_format":"eeee","payment_method":"Cash On Delivery","payment_code":"cod","payment_custom_field":"","shipping_firstname":"user","shipping_lastname":"1","shipping_company":"abc","shipping_address_1":"addresss1","shipping_address_2":"rrr","shipping_city":"aligarh","shipping_postcode":"202001","shipping_country":"India","shipping_country_id":"99","shipping_zone":"Uttar Pradesh","shipping_zone_id":"1505","shipping_address_format":"tttt","shipping_method":"Flat Rate Shipping","shipping_code":"flat.flat","shipping_custom_field":"","comment":"ddddd","user_agent":"yttyty","total":100,"affiliate_id":"","commission":0,"products":{"OrderProductInput":{"product_id":"30","name":"Canon EOS 5D","model":"Product 3","quantity":1,"price":100,"total":100,"tax":0,"reward":0,"option":{"OrderProductOptionInput":{"product_option_id":"226","product_option_value_id":"1","name":"select","value":"red","type":"select"}}}}}}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDA2MTY0LCJuYmYiOjE2NjM0MDYxNjksImV4cCI6MTY2MzQwNjk2NCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.3xt3RKSrTFXIJpI6QYsDTO8ThtMIC-P0ek0MO3w0JPQ',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation editorder($order_id:ID!, $order_data:OrderInput!){
editOrder(order_id:$order_id,input:$order_data){
order_id
status
message
}
}`,
variables: {"order_id":"9","order_data":{"invoice_prefix":"INV-2022-00","store_id":"1","store_name":"Your Store","store_url":"tttttttt","customer_id":"1","customer_group_id":"1","firstname":"user","lastname":"1","email":"user15@test.com","telephone":"9898989898","fax":"rrrr","custom_field":"","payment_firstname":"user1","payment_lastname":"1","payment_company":"abc","payment_address_1":"uyuyuy","payment_address_2":"hjhkjhgbjhy","payment_city":"alg","payment_postcode":"343434","payment_country":"india","payment_country_id":"99","payment_zone":"Uttar Pradesh","payment_zone_id":"1505","payment_address_format":"eeee","payment_method":"Cash On Delivery","payment_code":"cod","payment_custom_field":"","shipping_firstname":"user","shipping_lastname":"1","shipping_company":"abc","shipping_address_1":"addresss1","shipping_address_2":"rrr","shipping_city":"aligarh","shipping_postcode":"202001","shipping_country":"India","shipping_country_id":"99","shipping_zone":"Uttar Pradesh","shipping_zone_id":"1505","shipping_address_format":"tttt","shipping_method":"Flat Rate Shipping","shipping_code":"flat.flat","shipping_custom_field":"","comment":"ddddd","user_agent":"yttyty","total":100,"affiliate_id":"","commission":0,"products":{"OrderProductInput":{"product_id":"30","name":"Canon EOS 5D","model":"Product 3","quantity":1,"price":100,"total":100,"tax":0,"reward":0,"option":{"OrderProductOptionInput":{"product_option_id":"226","product_option_value_id":"1","name":"select","value":"red","type":"select"}}}}}}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation editorder($order_id:ID!, $order_data:OrderInput!){\\r\\n editOrder(order_id:$order_id,input:$order_data){\\r\\n order_id\\r\\n status\\r\\n message\\r\\n }\\r\\n}\",\"variables\":{\"order_id\":\"9\",\"order_data\":{\"invoice_prefix\":\"INV-2022-00\",\"store_id\":\"1\",\"store_name\":\"Your Store\",\"store_url\":\"tttttttt\",\"customer_id\":\"1\",\"customer_group_id\":\"1\",\"firstname\":\"user\",\"lastname\":\"1\",\"email\":\"user15@test.com\",\"telephone\":\"9898989898\",\"fax\":\"rrrr\",\"custom_field\":\"\",\"payment_firstname\":\"user1\",\"payment_lastname\":\"1\",\"payment_company\":\"abc\",\"payment_address_1\":\"uyuyuy\",\"payment_address_2\":\"hjhkjhgbjhy\",\"payment_city\":\"alg\",\"payment_postcode\":\"343434\",\"payment_country\":\"india\",\"payment_country_id\":\"99\",\"payment_zone\":\"Uttar Pradesh\",\"payment_zone_id\":\"1505\",\"payment_address_format\":\"eeee\",\"payment_method\":\"Cash On Delivery\",\"payment_code\":\"cod\",\"payment_custom_field\":\"\",\"shipping_firstname\":\"user\",\"shipping_lastname\":\"1\",\"shipping_company\":\"abc\",\"shipping_address_1\":\"addresss1\",\"shipping_address_2\":\"rrr\",\"shipping_city\":\"aligarh\",\"shipping_postcode\":\"202001\",\"shipping_country\":\"India\",\"shipping_country_id\":\"99\",\"shipping_zone\":\"Uttar Pradesh\",\"shipping_zone_id\":\"1505\",\"shipping_address_format\":\"tttt\",\"shipping_method\":\"Flat Rate Shipping\",\"shipping_code\":\"flat.flat\",\"shipping_custom_field\":\"\",\"comment\":\"ddddd\",\"user_agent\":\"yttyty\",\"total\":100,\"affiliate_id\":\"\",\"commission\":0,\"products\":{\"OrderProductInput\":{\"product_id\":\"30\",\"name\":\"Canon EOS 5D\",\"model\":\"Product 3\",\"quantity\":1,\"price\":100,\"total\":100,\"tax\":0,\"reward\":0,\"option\":{\"OrderProductOptionInput\":{\"product_option_id\":\"226\",\"product_option_value_id\":\"1\",\"name\":\"select\",\"value\":\"red\",\"type\":\"select\"}}}}}}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDA2MTY0LCJuYmYiOjE2NjM0MDYxNjksImV4cCI6MTY2MzQwNjk2NCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.3xt3RKSrTFXIJpI6QYsDTO8ThtMIC-P0ek0MO3w0JPQ',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDA2MTY0LCJuYmYiOjE2NjM0MDYxNjksImV4cCI6MTY2MzQwNjk2NCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.3xt3RKSrTFXIJpI6QYsDTO8ThtMIC-P0ek0MO3w0JPQ");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation editorder($order_id:ID!, $order_data:OrderInput!){\\r\\n editOrder(order_id:$order_id,input:$order_data){\\r\\n order_id\\r\\n status\\r\\n message\\r\\n }\\r\\n}\",\"variables\":{\"order_id\":\"9\",\"order_data\":{\"invoice_prefix\":\"INV-2022-00\",\"store_id\":\"1\",\"store_name\":\"Your Store\",\"store_url\":\"tttttttt\",\"customer_id\":\"1\",\"customer_group_id\":\"1\",\"firstname\":\"user\",\"lastname\":\"1\",\"email\":\"user15@test.com\",\"telephone\":\"9898989898\",\"fax\":\"rrrr\",\"custom_field\":\"\",\"payment_firstname\":\"user1\",\"payment_lastname\":\"1\",\"payment_company\":\"abc\",\"payment_address_1\":\"uyuyuy\",\"payment_address_2\":\"hjhkjhgbjhy\",\"payment_city\":\"alg\",\"payment_postcode\":\"343434\",\"payment_country\":\"india\",\"payment_country_id\":\"99\",\"payment_zone\":\"Uttar Pradesh\",\"payment_zone_id\":\"1505\",\"payment_address_format\":\"eeee\",\"payment_method\":\"Cash On Delivery\",\"payment_code\":\"cod\",\"payment_custom_field\":\"\",\"shipping_firstname\":\"user\",\"shipping_lastname\":\"1\",\"shipping_company\":\"abc\",\"shipping_address_1\":\"addresss1\",\"shipping_address_2\":\"rrr\",\"shipping_city\":\"aligarh\",\"shipping_postcode\":\"202001\",\"shipping_country\":\"India\",\"shipping_country_id\":\"99\",\"shipping_zone\":\"Uttar Pradesh\",\"shipping_zone_id\":\"1505\",\"shipping_address_format\":\"tttt\",\"shipping_method\":\"Flat Rate Shipping\",\"shipping_code\":\"flat.flat\",\"shipping_custom_field\":\"\",\"comment\":\"ddddd\",\"user_agent\":\"yttyty\",\"total\":100,\"affiliate_id\":\"\",\"commission\":0,\"products\":{\"OrderProductInput\":{\"product_id\":\"30\",\"name\":\"Canon EOS 5D\",\"model\":\"Product 3\",\"quantity\":1,\"price\":100,\"total\":100,\"tax\":0,\"reward\":0,\"option\":{\"OrderProductOptionInput\":{\"product_option_id\":\"226\",\"product_option_value_id\":\"1\",\"name\":\"select\",\"value\":\"red\",\"type\":\"select\"}}}}}}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDA2MTY0LCJuYmYiOjE2NjM0MDYxNjksImV4cCI6MTY2MzQwNjk2NCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.3xt3RKSrTFXIJpI6QYsDTO8ThtMIC-P0ek0MO3w0JPQ' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation editorder($order_id:ID!, $order_data:OrderInput!){\r\n editOrder(order_id:$order_id,input:$order_data){\r\n order_id\r\n status\r\n message\r\n }\r\n}","variables":{"order_id":"9","order_data":{"invoice_prefix":"INV-2022-00","store_id":"1","store_name":"Your Store","store_url":"tttttttt","customer_id":"1","customer_group_id":"1","firstname":"user","lastname":"1","email":"user15@test.com","telephone":"9898989898","fax":"rrrr","custom_field":"","payment_firstname":"user1","payment_lastname":"1","payment_company":"abc","payment_address_1":"uyuyuy","payment_address_2":"hjhkjhgbjhy","payment_city":"alg","payment_postcode":"343434","payment_country":"india","payment_country_id":"99","payment_zone":"Uttar Pradesh","payment_zone_id":"1505","payment_address_format":"eeee","payment_method":"Cash On Delivery","payment_code":"cod","payment_custom_field":"","shipping_firstname":"user","shipping_lastname":"1","shipping_company":"abc","shipping_address_1":"addresss1","shipping_address_2":"rrr","shipping_city":"aligarh","shipping_postcode":"202001","shipping_country":"India","shipping_country_id":"99","shipping_zone":"Uttar Pradesh","shipping_zone_id":"1505","shipping_address_format":"tttt","shipping_method":"Flat Rate Shipping","shipping_code":"flat.flat","shipping_custom_field":"","comment":"ddddd","user_agent":"yttyty","total":100,"affiliate_id":"","commission":0,"products":{"OrderProductInput":{"product_id":"30","name":"Canon EOS 5D","model":"Product 3","quantity":1,"price":100,"total":100,"tax":0,"reward":0,"option":{"OrderProductOptionInput":{"product_option_id":"226","product_option_value_id":"1","name":"select","value":"red","type":"select"}}}}}}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation editorder($order_id:ID!, $order_data:OrderInput!){\\r\\n editOrder(order_id:$order_id,input:$order_data){\\r\\n order_id\\r\\n status\\r\\n message\\r\\n }\\r\\n}\",\"variables\":{\"order_id\":\"9\",\"order_data\":{\"invoice_prefix\":\"INV-2022-00\",\"store_id\":\"1\",\"store_name\":\"Your Store\",\"store_url\":\"tttttttt\",\"customer_id\":\"1\",\"customer_group_id\":\"1\",\"firstname\":\"user\",\"lastname\":\"1\",\"email\":\"user15@test.com\",\"telephone\":\"9898989898\",\"fax\":\"rrrr\",\"custom_field\":\"\",\"payment_firstname\":\"user1\",\"payment_lastname\":\"1\",\"payment_company\":\"abc\",\"payment_address_1\":\"uyuyuy\",\"payment_address_2\":\"hjhkjhgbjhy\",\"payment_city\":\"alg\",\"payment_postcode\":\"343434\",\"payment_country\":\"india\",\"payment_country_id\":\"99\",\"payment_zone\":\"Uttar Pradesh\",\"payment_zone_id\":\"1505\",\"payment_address_format\":\"eeee\",\"payment_method\":\"Cash On Delivery\",\"payment_code\":\"cod\",\"payment_custom_field\":\"\",\"shipping_firstname\":\"user\",\"shipping_lastname\":\"1\",\"shipping_company\":\"abc\",\"shipping_address_1\":\"addresss1\",\"shipping_address_2\":\"rrr\",\"shipping_city\":\"aligarh\",\"shipping_postcode\":\"202001\",\"shipping_country\":\"India\",\"shipping_country_id\":\"99\",\"shipping_zone\":\"Uttar Pradesh\",\"shipping_zone_id\":\"1505\",\"shipping_address_format\":\"tttt\",\"shipping_method\":\"Flat Rate Shipping\",\"shipping_code\":\"flat.flat\",\"shipping_custom_field\":\"\",\"comment\":\"ddddd\",\"user_agent\":\"yttyty\",\"total\":100,\"affiliate_id\":\"\",\"commission\":0,\"products\":{\"OrderProductInput\":{\"product_id\":\"30\",\"name\":\"Canon EOS 5D\",\"model\":\"Product 3\",\"quantity\":1,\"price\":100,\"total\":100,\"tax\":0,\"reward\":0,\"option\":{\"OrderProductOptionInput\":{\"product_option_id\":\"226\",\"product_option_value_id\":\"1\",\"name\":\"select\",\"value\":\"red\",\"type\":\"select\"}}}}}}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDA2MTY0LCJuYmYiOjE2NjM0MDYxNjksImV4cCI6MTY2MzQwNjk2NCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.3xt3RKSrTFXIJpI6QYsDTO8ThtMIC-P0ek0MO3w0JPQ")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDA2MTY0LCJuYmYiOjE2NjM0MDYxNjksImV4cCI6MTY2MzQwNjk2NCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.3xt3RKSrTFXIJpI6QYsDTO8ThtMIC-P0ek0MO3w0JPQ"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation editorder($order_id:ID!, $order_data:OrderInput!){\\r\\n editOrder(order_id:$order_id,input:$order_data){\\r\\n order_id\\r\\n status\\r\\n message\\r\\n }\\r\\n}\",\"variables\":{\"order_id\":\"9\",\"order_data\":{\"invoice_prefix\":\"INV-2022-00\",\"store_id\":\"1\",\"store_name\":\"Your Store\",\"store_url\":\"tttttttt\",\"customer_id\":\"1\",\"customer_group_id\":\"1\",\"firstname\":\"user\",\"lastname\":\"1\",\"email\":\"user15@test.com\",\"telephone\":\"9898989898\",\"fax\":\"rrrr\",\"custom_field\":\"\",\"payment_firstname\":\"user1\",\"payment_lastname\":\"1\",\"payment_company\":\"abc\",\"payment_address_1\":\"uyuyuy\",\"payment_address_2\":\"hjhkjhgbjhy\",\"payment_city\":\"alg\",\"payment_postcode\":\"343434\",\"payment_country\":\"india\",\"payment_country_id\":\"99\",\"payment_zone\":\"Uttar Pradesh\",\"payment_zone_id\":\"1505\",\"payment_address_format\":\"eeee\",\"payment_method\":\"Cash On Delivery\",\"payment_code\":\"cod\",\"payment_custom_field\":\"\",\"shipping_firstname\":\"user\",\"shipping_lastname\":\"1\",\"shipping_company\":\"abc\",\"shipping_address_1\":\"addresss1\",\"shipping_address_2\":\"rrr\",\"shipping_city\":\"aligarh\",\"shipping_postcode\":\"202001\",\"shipping_country\":\"India\",\"shipping_country_id\":\"99\",\"shipping_zone\":\"Uttar Pradesh\",\"shipping_zone_id\":\"1505\",\"shipping_address_format\":\"tttt\",\"shipping_method\":\"Flat Rate Shipping\",\"shipping_code\":\"flat.flat\",\"shipping_custom_field\":\"\",\"comment\":\"ddddd\",\"user_agent\":\"yttyty\",\"total\":100,\"affiliate_id\":\"\",\"commission\":0,\"products\":{\"OrderProductInput\":{\"product_id\":\"30\",\"name\":\"Canon EOS 5D\",\"model\":\"Product 3\",\"quantity\":1,\"price\":100,\"total\":100,\"tax\":0,\"reward\":0,\"option\":{\"OrderProductOptionInput\":{\"product_option_id\":\"226\",\"product_option_value_id\":\"1\",\"name\":\"select\",\"value\":\"red\",\"type\":\"select\"}}}}}}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"editOrder": {
"order_id": 9,
"status": 1,
"message": "order edit successfully"
}
}
}
Opencart user delete address API
The delete user address API allow you delete address.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| Token | string |
Authorization |
Required |
Bearer token |
| order_id | ID |
Body GRAPHQL VARIABLES
|
Required |
Order id to delete |
| Parameter | Token |
|---|---|
| Type | string |
| Position | Authorization |
| # | Required |
| Description | Brearer Token |
| Parameter | order_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | Order id to delete |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation deleteorder($order:ID!){\\r\\n deleteOrder(order_id:$order){\\r\\n order_id\\r\\n }\\r\\n}","variables":{"order":"9"}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDA2Nzg1LCJuYmYiOjE2NjM0MDY3OTAsImV4cCI6MTY2MzQwNzU4NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.MuqI5LItPJ4p_N1FvUiWHCbZMcLm0MvX6NefzBLAbgs',
'Content-Type: application/json',
'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk3MDQ1LCJuYmYiOjE2NjMzOTcwNTAsImV4cCI6MTY2MzM5Nzg0NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.9v-9BQJk0B_PZ0wd-CRaOZDQHZwK-Rv-KjKsHwI6-K4",
"Content-Type": "application/json",
"Cookie": "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation deleteaddress($address_id:ID!){\r\n deleteAddress(address_id:$address_id){\r\n status\r\n }\r\n}",
variables: {"address_id":"11"}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDA2Nzg1LCJuYmYiOjE2NjM0MDY3OTAsImV4cCI6MTY2MzQwNzU4NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.MuqI5LItPJ4p_N1FvUiWHCbZMcLm0MvX6NefzBLAbgs',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation deleteorder($order:ID!){
deleteOrder(order_id:$order){
order_id
}
}`,
variables: {"order":"9"}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation deleteorder($order:ID!){\\r\\n deleteOrder(order_id:$order){\\r\\n order_id\\r\\n }\\r\\n}\",\"variables\":{\"order\":\"9\"}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDA2Nzg1LCJuYmYiOjE2NjM0MDY3OTAsImV4cCI6MTY2MzQwNzU4NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.MuqI5LItPJ4p_N1FvUiWHCbZMcLm0MvX6NefzBLAbgs',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDA2Nzg1LCJuYmYiOjE2NjM0MDY3OTAsImV4cCI6MTY2MzQwNzU4NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.MuqI5LItPJ4p_N1FvUiWHCbZMcLm0MvX6NefzBLAbgs");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation deleteorder($order:ID!){\\r\\n deleteOrder(order_id:$order){\\r\\n order_id\\r\\n }\\r\\n}\",\"variables\":{\"order\":\"9\"}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDA2Nzg1LCJuYmYiOjE2NjM0MDY3OTAsImV4cCI6MTY2MzQwNzU4NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.MuqI5LItPJ4p_N1FvUiWHCbZMcLm0MvX6NefzBLAbgs' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation deleteorder($order:ID!){\r\n deleteOrder(order_id:$order){\r\n order_id\r\n }\r\n}","variables":{"order":"9"}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation deleteorder($order:ID!){\\r\\n deleteOrder(order_id:$order){\\r\\n order_id\\r\\n }\\r\\n}\",\"variables\":{\"order\":\"9\"}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDA2Nzg1LCJuYmYiOjE2NjM0MDY3OTAsImV4cCI6MTY2MzQwNzU4NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.MuqI5LItPJ4p_N1FvUiWHCbZMcLm0MvX6NefzBLAbgs")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDA2Nzg1LCJuYmYiOjE2NjM0MDY3OTAsImV4cCI6MTY2MzQwNzU4NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.MuqI5LItPJ4p_N1FvUiWHCbZMcLm0MvX6NefzBLAbgs"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation deleteorder($order:ID!){\\r\\n deleteOrder(order_id:$order){\\r\\n order_id\\r\\n }\\r\\n}\",\"variables\":{\"order\":\"9\"}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"deleteOrder": {
"order_id": 9
}
}
}
Opencart Order List API
Order list api.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| token | string |
Authrization |
Required |
Bearer token |
| start | integer |
Body GRAPHQL VARIABLES |
Optional |
start index |
| limit | integer |
Body GRAPHQL VARIABLES |
Optional |
record limit |
| Parameter | filter_category_id |
|---|---|
| Type | integer |
| Position | Body |
| # | Optional |
| Description | Filter By category id |
| Parameter | token |
| Type | string |
| Position | authrization |
| # | Required |
| Description | Bearer Token |
| Parameter | start |
| Type | integer |
| Position | Body |
| # | Optional |
| Description | start index. |
| Parameter | limit |
| Type | integer |
| Position | Body GRAPHQL VARIABLES |
| # | Body |
| Description | record limit. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"query orders($start:Int,$limit:Int){\\r\\n orders(start:$start,limit:$limit){\\r\\n order_id invoice_no invoice_prefix store { store_id name url } products{ order_product_id order_id product_id name model quantity price total } customer_id firstname lastname email telephone fax custom_field payment_firstname payment_lastname payment_company payment_address_1 payment_address_2 payment_postcode payment_city paymentZone{zone_id name } paymentCountry{country_id name} payment_method payment_code shipping_firstname shipping_lastname shipping_company shipping_address_1 shipping_address_2 shipping_postcode shipping_city shippingZone{zone_id name} shippingCountry{country_id name} shipping_method shipping_code comment total order_status_id order_status affiliate_id commission language{language_id name} currency{currency_id code } ip forwarded_ip date_added\\r\\n \\r\\n }\\r\\n}","variables":{"start":0,"limit":1}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDEwODEwLCJuYmYiOjE2NjM0MTA4MTUsImV4cCI6MTY2MzQxMTYxMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.VYAlMxXHQOx1FPpg3lkg2Tn9zBcMtQqFxrTNRx98bcI',
'Content-Type: application/json',
'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDEwODEwLCJuYmYiOjE2NjM0MTA4MTUsImV4cCI6MTY2MzQxMTYxMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.VYAlMxXHQOx1FPpg3lkg2Tn9zBcMtQqFxrTNRx98bcI",
"Content-Type": "application/json",
"Cookie": "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "query orders($start:Int,$limit:Int){\r\n orders(start:$start,limit:$limit){\r\n order_id invoice_no invoice_prefix store { store_id name url } products{ order_product_id order_id product_id name model quantity price total } customer_id firstname lastname email telephone fax custom_field payment_firstname payment_lastname payment_company payment_address_1 payment_address_2 payment_postcode payment_city paymentZone{zone_id name } paymentCountry{country_id name} payment_method payment_code shipping_firstname shipping_lastname shipping_company shipping_address_1 shipping_address_2 shipping_postcode shipping_city shippingZone{zone_id name} shippingCountry{country_id name} shipping_method shipping_code comment total order_status_id order_status affiliate_id commission language{language_id name} currency{currency_id code } ip forwarded_ip date_added\r\n \r\n }\r\n}",
variables: {"start":0,"limit":1}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDEwODEwLCJuYmYiOjE2NjM0MTA4MTUsImV4cCI6MTY2MzQxMTYxMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.VYAlMxXHQOx1FPpg3lkg2Tn9zBcMtQqFxrTNRx98bcI',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `query orders($start:Int,$limit:Int){
orders(start:$start,limit:$limit){
order_id invoice_no invoice_prefix store { store_id name url } products{ order_product_id order_id product_id name model quantity price total } customer_id firstname lastname email telephone fax custom_field payment_firstname payment_lastname payment_company payment_address_1 payment_address_2 payment_postcode payment_city paymentZone{zone_id name } paymentCountry{country_id name} payment_method payment_code shipping_firstname shipping_lastname shipping_company shipping_address_1 shipping_address_2 shipping_postcode shipping_city shippingZone{zone_id name} shippingCountry{country_id name} shipping_method shipping_code comment total order_status_id order_status affiliate_id commission language{language_id name} currency{currency_id code } ip forwarded_ip date_added
}
}`,
variables: {"start":0,"limit":1}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"query orders($start:Int,$limit:Int){\\r\\n orders(start:$start,limit:$limit){\\r\\n order_id invoice_no invoice_prefix store { store_id name url } products{ order_product_id order_id product_id name model quantity price total } customer_id firstname lastname email telephone fax custom_field payment_firstname payment_lastname payment_company payment_address_1 payment_address_2 payment_postcode payment_city paymentZone{zone_id name } paymentCountry{country_id name} payment_method payment_code shipping_firstname shipping_lastname shipping_company shipping_address_1 shipping_address_2 shipping_postcode shipping_city shippingZone{zone_id name} shippingCountry{country_id name} shipping_method shipping_code comment total order_status_id order_status affiliate_id commission language{language_id name} currency{currency_id code } ip forwarded_ip date_added\\r\\n \\r\\n }\\r\\n}\",\"variables\":{\"start\":0,\"limit\":1}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDEwODEwLCJuYmYiOjE2NjM0MTA4MTUsImV4cCI6MTY2MzQxMTYxMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.VYAlMxXHQOx1FPpg3lkg2Tn9zBcMtQqFxrTNRx98bcI',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDEwODEwLCJuYmYiOjE2NjM0MTA4MTUsImV4cCI6MTY2MzQxMTYxMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.VYAlMxXHQOx1FPpg3lkg2Tn9zBcMtQqFxrTNRx98bcI");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"query orders($start:Int,$limit:Int){\\r\\n orders(start:$start,limit:$limit){\\r\\n order_id invoice_no invoice_prefix store { store_id name url } products{ order_product_id order_id product_id name model quantity price total } customer_id firstname lastname email telephone fax custom_field payment_firstname payment_lastname payment_company payment_address_1 payment_address_2 payment_postcode payment_city paymentZone{zone_id name } paymentCountry{country_id name} payment_method payment_code shipping_firstname shipping_lastname shipping_company shipping_address_1 shipping_address_2 shipping_postcode shipping_city shippingZone{zone_id name} shippingCountry{country_id name} shipping_method shipping_code comment total order_status_id order_status affiliate_id commission language{language_id name} currency{currency_id code } ip forwarded_ip date_added\\r\\n \\r\\n }\\r\\n}\",\"variables\":{\"start\":0,\"limit\":1}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDEwODEwLCJuYmYiOjE2NjM0MTA4MTUsImV4cCI6MTY2MzQxMTYxMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.VYAlMxXHQOx1FPpg3lkg2Tn9zBcMtQqFxrTNRx98bcI' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb' \
--data-raw '{"query":"query orders($start:Int,$limit:Int){\r\n orders(start:$start,limit:$limit){\r\n order_id invoice_no invoice_prefix store { store_id name url } products{ order_product_id order_id product_id name model quantity price total } customer_id firstname lastname email telephone fax custom_field payment_firstname payment_lastname payment_company payment_address_1 payment_address_2 payment_postcode payment_city paymentZone{zone_id name } paymentCountry{country_id name} payment_method payment_code shipping_firstname shipping_lastname shipping_company shipping_address_1 shipping_address_2 shipping_postcode shipping_city shippingZone{zone_id name} shippingCountry{country_id name} shipping_method shipping_code comment total order_status_id order_status affiliate_id commission language{language_id name} currency{currency_id code } ip forwarded_ip date_added\r\n \r\n }\r\n}","variables":{"start":0,"limit":1}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query orders($start:Int,$limit:Int){\\r\\n orders(start:$start,limit:$limit){\\r\\n order_id invoice_no invoice_prefix store { store_id name url } products{ order_product_id order_id product_id name model quantity price total } customer_id firstname lastname email telephone fax custom_field payment_firstname payment_lastname payment_company payment_address_1 payment_address_2 payment_postcode payment_city paymentZone{zone_id name } paymentCountry{country_id name} payment_method payment_code shipping_firstname shipping_lastname shipping_company shipping_address_1 shipping_address_2 shipping_postcode shipping_city shippingZone{zone_id name} shippingCountry{country_id name} shipping_method shipping_code comment total order_status_id order_status affiliate_id commission language{language_id name} currency{currency_id code } ip forwarded_ip date_added\\r\\n \\r\\n }\\r\\n}\",\"variables\":{\"start\":0,\"limit\":1}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDEwODEwLCJuYmYiOjE2NjM0MTA4MTUsImV4cCI6MTY2MzQxMTYxMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.VYAlMxXHQOx1FPpg3lkg2Tn9zBcMtQqFxrTNRx98bcI")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDEwODEwLCJuYmYiOjE2NjM0MTA4MTUsImV4cCI6MTY2MzQxMTYxMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.VYAlMxXHQOx1FPpg3lkg2Tn9zBcMtQqFxrTNRx98bcI"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
request.body = "{\"query\":\"query orders($start:Int,$limit:Int){\\r\\n orders(start:$start,limit:$limit){\\r\\n order_id invoice_no invoice_prefix store { store_id name url } products{ order_product_id order_id product_id name model quantity price total } customer_id firstname lastname email telephone fax custom_field payment_firstname payment_lastname payment_company payment_address_1 payment_address_2 payment_postcode payment_city paymentZone{zone_id name } paymentCountry{country_id name} payment_method payment_code shipping_firstname shipping_lastname shipping_company shipping_address_1 shipping_address_2 shipping_postcode shipping_city shippingZone{zone_id name} shippingCountry{country_id name} shipping_method shipping_code comment total order_status_id order_status affiliate_id commission language{language_id name} currency{currency_id code } ip forwarded_ip date_added\\r\\n \\r\\n }\\r\\n}\",\"variables\":{\"start\":0,\"limit\":1}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"orders": [
{
"order_id": "10",
"invoice_no": 0,
"invoice_prefix": "INV-2022-00",
"store": {
"store_id": "0",
"name": null,
"url": null
},
"products": [],
"customer_id": "1",
"firstname": "user",
"lastname": "1",
"email": "user1@test.com",
"telephone": "9898989898",
"fax": null,
"custom_field": null,
"payment_firstname": "user1",
"payment_lastname": "1",
"payment_company": "abc",
"payment_address_1": "uyuyuy",
"payment_address_2": "hjhkjhgbjhy",
"payment_postcode": "343434",
"payment_city": "alg",
"paymentZone": {
"zone_id": "1505",
"name": "Uttar Pradesh"
},
"paymentCountry": {
"country_id": "99",
"name": "india"
},
"payment_method": "Cash On Delivery",
"payment_code": "cod",
"shipping_firstname": "user",
"shipping_lastname": "1",
"shipping_company": "abc",
"shipping_address_1": "addresss1",
"shipping_address_2": "rrr",
"shipping_postcode": "202001",
"shipping_city": "aligarh",
"shippingZone": {
"zone_id": "1505",
"name": "Uttar Pradesh"
},
"shippingCountry": {
"country_id": "99",
"name": "India"
},
"shipping_method": "Flat Rate Shipping",
"shipping_code": "flat.flat",
"comment": "ddddd",
"total": "0.0000",
"order_status_id": "1",
"order_status": "Pending",
"affiliate_id": "0",
"commission": "0.0000",
"language": {
"language_id": "1",
"name": "English"
},
"currency": {
"currency_id": "2",
"code": "USD"
},
"ip": "::1",
"forwarded_ip": "",
"date_added": "2022-09-17 08:25:10"
}
]
}
}
Opencart Order Detail API
Order detail api.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| token | string |
Authrization |
Required |
Bearer token |
| order_id | integer |
Body |
Required |
order id to get details |
| Parameter | token |
|---|---|
| Type | string |
| Position | Authrization |
| # | Required |
| Description | Bearer token |
| Parameter | order_id |
| Type | integer |
| Position | Body |
| # | Required |
| Description | order id to get details |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"query getorder($id:ID!){\\r\\n order(id:$id){\\r\\n order_id invoice_no invoice_prefix store { store_id name url } products{ order_product_id order_id product_id name model quantity price total } customer_id firstname lastname email telephone fax custom_field payment_firstname payment_lastname payment_company payment_address_1 payment_address_2 payment_postcode payment_city paymentZone{zone_id name } paymentCountry{country_id name} payment_method payment_code shipping_firstname shipping_lastname shipping_company shipping_address_1 shipping_address_2 shipping_postcode shipping_city shippingZone{zone_id name} shippingCountry{country_id name} shipping_method shipping_code comment total order_status_id order_status affiliate_id commission language{language_id name} currency{currency_id code } ip forwarded_ip date_added\\r\\n }\\r\\n}","variables":{"id":"10"}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDEyOTc0LCJuYmYiOjE2NjM0MTI5NzksImV4cCI6MTY2MzQxMzc3NCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.B_TSHSmzRBRBsgfqphpeM5brzTNOXUPQxRiVESnuaJo',
'Content-Type: application/json',
'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDEyOTc0LCJuYmYiOjE2NjM0MTI5NzksImV4cCI6MTY2MzQxMzc3NCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.B_TSHSmzRBRBsgfqphpeM5brzTNOXUPQxRiVESnuaJo",
"Content-Type": "application/json",
"Cookie": "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "query getorder($id:ID!){\r\n order(id:$id){\r\n order_id invoice_no invoice_prefix store { store_id name url } products{ order_product_id order_id product_id name model quantity price total } customer_id firstname lastname email telephone fax custom_field payment_firstname payment_lastname payment_company payment_address_1 payment_address_2 payment_postcode payment_city paymentZone{zone_id name } paymentCountry{country_id name} payment_method payment_code shipping_firstname shipping_lastname shipping_company shipping_address_1 shipping_address_2 shipping_postcode shipping_city shippingZone{zone_id name} shippingCountry{country_id name} shipping_method shipping_code comment total order_status_id order_status affiliate_id commission language{language_id name} currency{currency_id code } ip forwarded_ip date_added\r\n }\r\n}",
variables: {"id":"10"}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDEyOTc0LCJuYmYiOjE2NjM0MTI5NzksImV4cCI6MTY2MzQxMzc3NCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.B_TSHSmzRBRBsgfqphpeM5brzTNOXUPQxRiVESnuaJo',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `query getorder($id:ID!){
order(id:$id){
order_id invoice_no invoice_prefix store { store_id name url } products{ order_product_id order_id product_id name model quantity price total } customer_id firstname lastname email telephone fax custom_field payment_firstname payment_lastname payment_company payment_address_1 payment_address_2 payment_postcode payment_city paymentZone{zone_id name } paymentCountry{country_id name} payment_method payment_code shipping_firstname shipping_lastname shipping_company shipping_address_1 shipping_address_2 shipping_postcode shipping_city shippingZone{zone_id name} shippingCountry{country_id name} shipping_method shipping_code comment total order_status_id order_status affiliate_id commission language{language_id name} currency{currency_id code } ip forwarded_ip date_added
}
}`,
variables: {"id":"10"}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"query getorder($id:ID!){\\r\\n order(id:$id){\\r\\n order_id invoice_no invoice_prefix store { store_id name url } products{ order_product_id order_id product_id name model quantity price total } customer_id firstname lastname email telephone fax custom_field payment_firstname payment_lastname payment_company payment_address_1 payment_address_2 payment_postcode payment_city paymentZone{zone_id name } paymentCountry{country_id name} payment_method payment_code shipping_firstname shipping_lastname shipping_company shipping_address_1 shipping_address_2 shipping_postcode shipping_city shippingZone{zone_id name} shippingCountry{country_id name} shipping_method shipping_code comment total order_status_id order_status affiliate_id commission language{language_id name} currency{currency_id code } ip forwarded_ip date_added\\r\\n }\\r\\n}\",\"variables\":{\"id\":\"10\"}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDEyOTc0LCJuYmYiOjE2NjM0MTI5NzksImV4cCI6MTY2MzQxMzc3NCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.B_TSHSmzRBRBsgfqphpeM5brzTNOXUPQxRiVESnuaJo',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDEyOTc0LCJuYmYiOjE2NjM0MTI5NzksImV4cCI6MTY2MzQxMzc3NCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.B_TSHSmzRBRBsgfqphpeM5brzTNOXUPQxRiVESnuaJo");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"query getorder($id:ID!){\\r\\n order(id:$id){\\r\\n order_id invoice_no invoice_prefix store { store_id name url } products{ order_product_id order_id product_id name model quantity price total } customer_id firstname lastname email telephone fax custom_field payment_firstname payment_lastname payment_company payment_address_1 payment_address_2 payment_postcode payment_city paymentZone{zone_id name } paymentCountry{country_id name} payment_method payment_code shipping_firstname shipping_lastname shipping_company shipping_address_1 shipping_address_2 shipping_postcode shipping_city shippingZone{zone_id name} shippingCountry{country_id name} shipping_method shipping_code comment total order_status_id order_status affiliate_id commission language{language_id name} currency{currency_id code } ip forwarded_ip date_added\\r\\n }\\r\\n}\",\"variables\":{\"id\":\"10\"}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDEyOTc0LCJuYmYiOjE2NjM0MTI5NzksImV4cCI6MTY2MzQxMzc3NCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.B_TSHSmzRBRBsgfqphpeM5brzTNOXUPQxRiVESnuaJo' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb' \
--data-raw '{"query":"query getorder($id:ID!){\r\n order(id:$id){\r\n order_id invoice_no invoice_prefix store { store_id name url } products{ order_product_id order_id product_id name model quantity price total } customer_id firstname lastname email telephone fax custom_field payment_firstname payment_lastname payment_company payment_address_1 payment_address_2 payment_postcode payment_city paymentZone{zone_id name } paymentCountry{country_id name} payment_method payment_code shipping_firstname shipping_lastname shipping_company shipping_address_1 shipping_address_2 shipping_postcode shipping_city shippingZone{zone_id name} shippingCountry{country_id name} shipping_method shipping_code comment total order_status_id order_status affiliate_id commission language{language_id name} currency{currency_id code } ip forwarded_ip date_added\r\n }\r\n}","variables":{"id":"10"}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query getorder($id:ID!){\\r\\n order(id:$id){\\r\\n order_id invoice_no invoice_prefix store { store_id name url } products{ order_product_id order_id product_id name model quantity price total } customer_id firstname lastname email telephone fax custom_field payment_firstname payment_lastname payment_company payment_address_1 payment_address_2 payment_postcode payment_city paymentZone{zone_id name } paymentCountry{country_id name} payment_method payment_code shipping_firstname shipping_lastname shipping_company shipping_address_1 shipping_address_2 shipping_postcode shipping_city shippingZone{zone_id name} shippingCountry{country_id name} shipping_method shipping_code comment total order_status_id order_status affiliate_id commission language{language_id name} currency{currency_id code } ip forwarded_ip date_added\\r\\n }\\r\\n}\",\"variables\":{\"id\":\"10\"}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDEyOTc0LCJuYmYiOjE2NjM0MTI5NzksImV4cCI6MTY2MzQxMzc3NCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.B_TSHSmzRBRBsgfqphpeM5brzTNOXUPQxRiVESnuaJo")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDEyOTc0LCJuYmYiOjE2NjM0MTI5NzksImV4cCI6MTY2MzQxMzc3NCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.B_TSHSmzRBRBsgfqphpeM5brzTNOXUPQxRiVESnuaJo"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
request.body = "{\"query\":\"query getorder($id:ID!){\\r\\n order(id:$id){\\r\\n order_id invoice_no invoice_prefix store { store_id name url } products{ order_product_id order_id product_id name model quantity price total } customer_id firstname lastname email telephone fax custom_field payment_firstname payment_lastname payment_company payment_address_1 payment_address_2 payment_postcode payment_city paymentZone{zone_id name } paymentCountry{country_id name} payment_method payment_code shipping_firstname shipping_lastname shipping_company shipping_address_1 shipping_address_2 shipping_postcode shipping_city shippingZone{zone_id name} shippingCountry{country_id name} shipping_method shipping_code comment total order_status_id order_status affiliate_id commission language{language_id name} currency{currency_id code } ip forwarded_ip date_added\\r\\n }\\r\\n}\",\"variables\":{\"id\":\"10\"}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"products": [
{
"product_id": "42",
"model": "Product 15",
"description": "\r\n\tThe 30-inch Apple Cinema HD Display delivers an amazing 2560 x 1600 pixel resolution. Designed specifically for the creative professional, this display provides more space for easier access to all the tools and palettes needed to edit, format and composite your work. Combine this display with a Mac Pro, MacBook Pro, or PowerMac G5 and there's no limit to what you can achieve. \r\n\t\r\n\tThe Cinema HD features an active-matrix liquid crystal display that produces flicker-free images that deliver twice the brightness, twice the sharpness and twice the contrast ratio of a typical CRT display. Unlike other flat panels, it's designed with a pure digital interface to deliver distortion-free images that never need adjusting. With over 4 million digital pixels, the display is uniquely suited for scientific and technical applications such as visualizing molecular structures or analyzing geological data. \r\n\t\r\n\tOffering accurate, brilliant color performance, the Cinema HD delivers up to 16.7 million colors across a wide gamut allowing you to see subtle nuances between colors from soft pastels to rich jewel tones,"
"meta_title": "Apple Cinema 30",
"meta_description": "",
"meta_keyword": "",
"tag": "",
"sku": "",
"upc": "",
"ean": "",
"jan": "",
"isbn": "",
"mpn": "",
"location": "",
"quantity": "988",
"stock_status": "Out Of Stock",
"image": "catalog/demo/apple_cinema_30.jpg",
"manufacturer": {
"manufacturer_id": "8",
"name": "Apple"
},
"in_stock": true,
"price": "100.0000",
"special": "90.0000",
"formatted_price": "$100.00",
"formatted_special": "$90.00",
"reward": "100",
"date_available": "2009-02-04",
"tax_class_id": "9",
"weight": "12.50000000",
"weight_class_id": "1",
"length": 1,
"width": 2,
"height": 3,
"length_class_id": "1",
"subtract": "1",
"rating": 0,
"review_count": null,
"minimum": "2",
"sort_order": "0",
"status": "1",
"date_added": "2009-02-03 21:07:37",
"date_modified": "2011-09-30 00:46:19",
"categories": [
{
"category_id": "20",
"name": "Desktops"
},
{
"category_id": "28",
"name": "Monitors"
}
],
"images": [
{
"image": "catalog/demo/canon_logo.jpg"
},
{
"image": "catalog/demo/hp_1.jpg"
},
{
"image": "catalog/demo/compaq_presario.jpg"
},
{
"image": "catalog/demo/canon_eos_5d_1.jpg"
},
{
"image": "catalog/demo/canon_eos_5d_2.jpg"
}
]
}
]
}
}
Opencart Order products API
Order products api.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| token | string |
Authrization |
Required |
Bearer token |
| order_id | integer |
Body |
Required |
order id to get products |
| Parameter | token |
|---|---|
| Type | string |
| Position | Authrization |
| # | Required |
| Description | Bearer token |
| Parameter | order_id |
| Type | integer |
| Position | Body |
| # | Required |
| Description | order id to get products |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"query order($order_id:ID!){\\r\\n orderProducts(order_id:$order_id){\\r\\n product_id model quantity price \\r\\n }\\r\\n}","variables":{"order_id":"8"}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE1Mzk5LCJuYmYiOjE2NjM0MTU0MDQsImV4cCI6MTY2MzQxNjE5OSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.cOA1c23d0_5YSmOlnaMfxfTz3Dsdw9AUaMGAFCETho0',
'Content-Type: application/json',
'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE1Mzk5LCJuYmYiOjE2NjM0MTU0MDQsImV4cCI6MTY2MzQxNjE5OSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.cOA1c23d0_5YSmOlnaMfxfTz3Dsdw9AUaMGAFCETho0",
"Content-Type": "application/json",
"Cookie": "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "query order($order_id:ID!){\r\n orderProducts(order_id:$order_id){\r\n product_id model quantity price \r\n }\r\n}",
variables: {"order_id":"8"}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE1Mzk5LCJuYmYiOjE2NjM0MTU0MDQsImV4cCI6MTY2MzQxNjE5OSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.cOA1c23d0_5YSmOlnaMfxfTz3Dsdw9AUaMGAFCETho0',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `query order($order_id:ID!){
orderProducts(order_id:$order_id){
product_id model quantity price
}
}`,
variables: {"order_id":"8"}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"query order($order_id:ID!){\\r\\n orderProducts(order_id:$order_id){\\r\\n product_id model quantity price \\r\\n }\\r\\n}\",\"variables\":{\"order_id\":\"8\"}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE1Mzk5LCJuYmYiOjE2NjM0MTU0MDQsImV4cCI6MTY2MzQxNjE5OSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.cOA1c23d0_5YSmOlnaMfxfTz3Dsdw9AUaMGAFCETho0',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE1Mzk5LCJuYmYiOjE2NjM0MTU0MDQsImV4cCI6MTY2MzQxNjE5OSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.cOA1c23d0_5YSmOlnaMfxfTz3Dsdw9AUaMGAFCETho0");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"query order($order_id:ID!){\\r\\n orderProducts(order_id:$order_id){\\r\\n product_id model quantity price \\r\\n }\\r\\n}\",\"variables\":{\"order_id\":\"8\"}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE1Mzk5LCJuYmYiOjE2NjM0MTU0MDQsImV4cCI6MTY2MzQxNjE5OSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.cOA1c23d0_5YSmOlnaMfxfTz3Dsdw9AUaMGAFCETho0' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb' \
--data-raw '{"query":"query order($order_id:ID!){\r\n orderProducts(order_id:$order_id){\r\n product_id model quantity price \r\n }\r\n}","variables":{"order_id":"8"}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query order($order_id:ID!){\\r\\n orderProducts(order_id:$order_id){\\r\\n product_id model quantity price \\r\\n }\\r\\n}\",\"variables\":{\"order_id\":\"8\"}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE1Mzk5LCJuYmYiOjE2NjM0MTU0MDQsImV4cCI6MTY2MzQxNjE5OSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.cOA1c23d0_5YSmOlnaMfxfTz3Dsdw9AUaMGAFCETho0")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE1Mzk5LCJuYmYiOjE2NjM0MTU0MDQsImV4cCI6MTY2MzQxNjE5OSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.cOA1c23d0_5YSmOlnaMfxfTz3Dsdw9AUaMGAFCETho0"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
request.body = "{\"query\":\"query order($order_id:ID!){\\r\\n orderProducts(order_id:$order_id){\\r\\n product_id model quantity price \\r\\n }\\r\\n}\",\"variables\":{\"order_id\":\"8\"}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"orderProducts": [
{
"product_id": "40",
"model": "product 11",
"quantity": "3",
"price": "101.0000"
},
{
"product_id": "43",
"model": "Product 16",
"quantity": "2",
"price": "500.0000"
}
]
}
}
Opencart add wishlist API
Add wishlist api.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| token | string |
Authrization |
Required |
Bearer token |
| product_id | ID |
Body |
Required |
product id to add to wishlist |
| Parameter | token |
|---|---|
| Type | string |
| Position | Authrization |
| # | Required |
| Description | Bearer token |
| Parameter | product_id |
| Type | ID |
| Position | Body |
| # | Required |
| Description | product id to add to wishlist |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation addWishlist($product_id:ID!){\\r\\n addWishlist(product_id:$product_id)\\r\\n}","variables":{"product_id":40}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDgzODgwLCJuYmYiOjE2NjM0ODM4ODUsImV4cCI6MTY2MzQ4NDY4MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.IDC10m9JV8La-C-8G8tSOuv98NMeiwK11awXvOJqk4I',
'Content-Type: application/json',
'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDgzODgwLCJuYmYiOjE2NjM0ODM4ODUsImV4cCI6MTY2MzQ4NDY4MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.IDC10m9JV8La-C-8G8tSOuv98NMeiwK11awXvOJqk4I",
"Content-Type": "application/json",
"Cookie": "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation addWishlist($product_id:ID!){\r\n addWishlist(product_id:$product_id)\r\n}",
variables: {"product_id":40}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDgzODgwLCJuYmYiOjE2NjM0ODM4ODUsImV4cCI6MTY2MzQ4NDY4MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.IDC10m9JV8La-C-8G8tSOuv98NMeiwK11awXvOJqk4I',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation addWishlist($product_id:ID!){
addWishlist(product_id:$product_id)
}`,
variables: {"product_id":40}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation addWishlist($product_id:ID!){\\r\\n addWishlist(product_id:$product_id)\\r\\n}\",\"variables\":{\"product_id\":40}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDgzODgwLCJuYmYiOjE2NjM0ODM4ODUsImV4cCI6MTY2MzQ4NDY4MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.IDC10m9JV8La-C-8G8tSOuv98NMeiwK11awXvOJqk4I',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDgzODgwLCJuYmYiOjE2NjM0ODM4ODUsImV4cCI6MTY2MzQ4NDY4MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.IDC10m9JV8La-C-8G8tSOuv98NMeiwK11awXvOJqk4I");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation addWishlist($product_id:ID!){\\r\\n addWishlist(product_id:$product_id)\\r\\n}\",\"variables\":{\"product_id\":40}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDgzODgwLCJuYmYiOjE2NjM0ODM4ODUsImV4cCI6MTY2MzQ4NDY4MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.IDC10m9JV8La-C-8G8tSOuv98NMeiwK11awXvOJqk4I' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation addWishlist($product_id:ID!){\r\n addWishlist(product_id:$product_id)\r\n}","variables":{"product_id":40}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation addWishlist($product_id:ID!){\\r\\n addWishlist(product_id:$product_id)\\r\\n}\",\"variables\":{\"product_id\":40}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDgzODgwLCJuYmYiOjE2NjM0ODM4ODUsImV4cCI6MTY2MzQ4NDY4MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.IDC10m9JV8La-C-8G8tSOuv98NMeiwK11awXvOJqk4I")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDgzODgwLCJuYmYiOjE2NjM0ODM4ODUsImV4cCI6MTY2MzQ4NDY4MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.IDC10m9JV8La-C-8G8tSOuv98NMeiwK11awXvOJqk4I"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation addWishlist($product_id:ID!){\\r\\n addWishlist(product_id:$product_id)\\r\\n}\",\"variables\":{\"product_id\":40}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"addWishlist": true
}
}
Opencart delete wishlist API
Delete wishlist api.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| token | string |
Authrization |
Required |
Bearer token |
| product_id | ID |
Body |
Required |
product id to delete to wishlist |
| Parameter | token |
|---|---|
| Type | string |
| Position | Authrization |
| # | Required |
| Description | Bearer token |
| Parameter | product_id |
| Type | ID |
| Position | Body |
| # | Required |
| Description | product id to delete to wishlist |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation deletewishlist($product_id:ID!){\\r\\n deleteWishlist(product_id:$product_id)\\r\\n}","variables":{"product_id":40}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDg0NzgxLCJuYmYiOjE2NjM0ODQ3ODYsImV4cCI6MTY2MzQ4NTU4MSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.maO1TUorNjbkthOwfeV-0ioRr5mGdwxQia_xkewbfW8',
'Content-Type: application/json',
'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDg0NzgxLCJuYmYiOjE2NjM0ODQ3ODYsImV4cCI6MTY2MzQ4NTU4MSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.maO1TUorNjbkthOwfeV-0ioRr5mGdwxQia_xkewbfW8",
"Content-Type": "application/json",
"Cookie": "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation deletewishlist($product_id:ID!){\r\n deleteWishlist(product_id:$product_id)\r\n}",
variables: {"product_id":40}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDg0NzgxLCJuYmYiOjE2NjM0ODQ3ODYsImV4cCI6MTY2MzQ4NTU4MSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.maO1TUorNjbkthOwfeV-0ioRr5mGdwxQia_xkewbfW8',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation deletewishlist($product_id:ID!){
deleteWishlist(product_id:$product_id)
}`,
variables: {"product_id":40}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation deletewishlist($product_id:ID!){\\r\\n deleteWishlist(product_id:$product_id)\\r\\n}\",\"variables\":{\"product_id\":40}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDg0NzgxLCJuYmYiOjE2NjM0ODQ3ODYsImV4cCI6MTY2MzQ4NTU4MSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.maO1TUorNjbkthOwfeV-0ioRr5mGdwxQia_xkewbfW8',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDg0NzgxLCJuYmYiOjE2NjM0ODQ3ODYsImV4cCI6MTY2MzQ4NTU4MSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.maO1TUorNjbkthOwfeV-0ioRr5mGdwxQia_xkewbfW8");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation deletewishlist($product_id:ID!){\\r\\n deleteWishlist(product_id:$product_id)\\r\\n}\",\"variables\":{\"product_id\":40}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDg0NzgxLCJuYmYiOjE2NjM0ODQ3ODYsImV4cCI6MTY2MzQ4NTU4MSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.maO1TUorNjbkthOwfeV-0ioRr5mGdwxQia_xkewbfW8' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation deletewishlist($product_id:ID!){\r\n deleteWishlist(product_id:$product_id)\r\n}","variables":{"product_id":40}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation deletewishlist($product_id:ID!){\\r\\n deleteWishlist(product_id:$product_id)\\r\\n}\",\"variables\":{\"product_id\":40}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDg0NzgxLCJuYmYiOjE2NjM0ODQ3ODYsImV4cCI6MTY2MzQ4NTU4MSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.maO1TUorNjbkthOwfeV-0ioRr5mGdwxQia_xkewbfW8")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDg0NzgxLCJuYmYiOjE2NjM0ODQ3ODYsImV4cCI6MTY2MzQ4NTU4MSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.maO1TUorNjbkthOwfeV-0ioRr5mGdwxQia_xkewbfW8"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation deletewishlist($product_id:ID!){\\r\\n deleteWishlist(product_id:$product_id)\\r\\n}\",\"variables\":{\"product_id\":40}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"deleteWishlist": true
}
}
Opencart Return list API
Return list api.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| token | string |
Authrization |
Required |
Bearer token |
| product_id | ID |
Body |
Required |
product id to delete to wishlist |
| Parameter | token |
|---|---|
| Type | string |
| Position | Authrization |
| # | Required |
| Description | Bearer token |
| Parameter | product_id |
| Type | ID |
| Position | Body |
| # | Required |
| Description | product id to delete to wishlist |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"query returns($start:Int,$limit:Int){\\r\\n returns(start:$start,limit:$limit){\\r\\n return_id firstname lastname status date_added\\r\\n }\\r\\n}","variables":{"strat":0,"limit":20}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDk2OTY3LCJuYmYiOjE2NjM0OTY5NzIsImV4cCI6MTY2MzQ5Nzc2NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.DTbNkBhJ-VuEhXMVSR7XHzgpeBhryFNCS4Xss-BdiwU',
'Content-Type: application/json',
'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDk2OTY3LCJuYmYiOjE2NjM0OTY5NzIsImV4cCI6MTY2MzQ5Nzc2NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.DTbNkBhJ-VuEhXMVSR7XHzgpeBhryFNCS4Xss-BdiwU",
"Content-Type": "application/json",
"Cookie": "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "query returns($start:Int,$limit:Int){\r\n returns(start:$start,limit:$limit){\r\n return_id firstname lastname status date_added\r\n }\r\n}",
variables: {"strat":0,"limit":20}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDk2OTY3LCJuYmYiOjE2NjM0OTY5NzIsImV4cCI6MTY2MzQ5Nzc2NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.DTbNkBhJ-VuEhXMVSR7XHzgpeBhryFNCS4Xss-BdiwU',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `query returns($start:Int,$limit:Int){
returns(start:$start,limit:$limit){
return_id firstname lastname status date_added
}
}`,
variables: {"strat":0,"limit":20}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"query returns($start:Int,$limit:Int){\\r\\n returns(start:$start,limit:$limit){\\r\\n return_id firstname lastname status date_added\\r\\n }\\r\\n}\",\"variables\":{\"strat\":0,\"limit\":20}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDk2OTY3LCJuYmYiOjE2NjM0OTY5NzIsImV4cCI6MTY2MzQ5Nzc2NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.DTbNkBhJ-VuEhXMVSR7XHzgpeBhryFNCS4Xss-BdiwU',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDk2OTY3LCJuYmYiOjE2NjM0OTY5NzIsImV4cCI6MTY2MzQ5Nzc2NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.DTbNkBhJ-VuEhXMVSR7XHzgpeBhryFNCS4Xss-BdiwU");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"query returns($start:Int,$limit:Int){\\r\\n returns(start:$start,limit:$limit){\\r\\n return_id firstname lastname status date_added\\r\\n }\\r\\n}\",\"variables\":{\"strat\":0,\"limit\":20}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDk2OTY3LCJuYmYiOjE2NjM0OTY5NzIsImV4cCI6MTY2MzQ5Nzc2NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.DTbNkBhJ-VuEhXMVSR7XHzgpeBhryFNCS4Xss-BdiwU' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb' \
--data-raw '{"query":"query returns($start:Int,$limit:Int){\r\n returns(start:$start,limit:$limit){\r\n return_id firstname lastname status date_added\r\n }\r\n}","variables":{"strat":0,"limit":20}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query returns($start:Int,$limit:Int){\\r\\n returns(start:$start,limit:$limit){\\r\\n return_id firstname lastname status date_added\\r\\n }\\r\\n}\",\"variables\":{\"strat\":0,\"limit\":20}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDk2OTY3LCJuYmYiOjE2NjM0OTY5NzIsImV4cCI6MTY2MzQ5Nzc2NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.DTbNkBhJ-VuEhXMVSR7XHzgpeBhryFNCS4Xss-BdiwU")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDk2OTY3LCJuYmYiOjE2NjM0OTY5NzIsImV4cCI6MTY2MzQ5Nzc2NywiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.DTbNkBhJ-VuEhXMVSR7XHzgpeBhryFNCS4Xss-BdiwU"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
request.body = "{\"query\":\"query returns($start:Int,$limit:Int){\\r\\n returns(start:$start,limit:$limit){\\r\\n return_id firstname lastname status date_added\\r\\n }\\r\\n}\",\"variables\":{\"strat\":0,\"limit\":20}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"returns": [
{
"return_id": "15",
"firstname": "user",
"lastname": "1",
"status": "Awaiting Products",
"date_added": "2022-09-12 12:45:11"
},
{
"return_id": "1",
"firstname": "user",
"lastname": "1",
"status": "Awaiting Products",
"date_added": "2022-07-30 10:24:12"
}
]
}
}
Opencart Add Return API
Add Return api.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| token | string |
Authrization |
Required |
Bearer token |
| input | ||||
| order_id | ID |
Body |
Required |
order id |
| firstname | string |
Body |
Required |
user first name |
| lastname | string |
Body |
Required |
user lastname |
string |
Body |
Required |
user email | |
| telephone | string |
Body |
Required |
user telephone |
| product | string |
Body |
Optional |
user product |
| product_id | string |
Body |
Optional |
product id |
| model | string |
Body |
Required |
product model |
| quantity | integer |
Body |
Required |
product quantity |
| opened | integer |
Body |
Required |
product opened |
| return_reason_id | integer |
Body |
Required |
product return reason id |
| comment | string |
Body |
Required |
comment |
| date_ordered | string |
Body |
Required |
date ordered |
| Parameter | token |
|---|---|
| Type | string |
| Position | Authrization |
| # | Required |
| Description | Bearer token |
| Parameter | order_id |
| Type | ID |
| Position | Body |
| # | Required |
| Description | order id |
| Parameter | firstname |
| Type | string |
| Position | Body |
| # | Required |
| Description | user firstname |
| Parameter | lastname |
| Type | string |
| Position | Body |
| # | Required |
| Description | user lastname |
| Parameter | |
| Type | string |
| Position | Body |
| # | Required |
| Description | user email |
| Parameter | telephone |
| Type | string |
| Position | Body |
| # | Required |
| Description | user telephone |
| Parameter | product |
| Type | string |
| Position | Body |
| # | Optional |
| Description | product name |
| Parameter | product_id |
| Type | integer |
| Position | Body |
| # | Optional |
| Description | product id |
| Parameter | model |
| Type | string |
| Position | Body |
| # | Required |
| Description | product model |
| Parameter | quantity |
| Type | string |
| Position | Body |
| # | Required |
| Description | product quantity |
| Parameter | opened |
| Type | integer |
| Position | Body |
| # | Required |
| Description | product opened |
| Parameter | return_reason_id |
| Type | integer |
| Position | Body |
| # | Required |
| Description | return reason id |
| Parameter | comment |
| Type | string |
| Position | Body |
| # | Required |
| Description | comment |
| Parameter | date_ordered |
| Type | string |
| Position | Body |
| # | Required |
| Description | date ordered |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation add_return($return_data:ReturnInput){\\r\\n addReturn(input:$return_data)\\r\\n}","variables":{"return_data":{"order_id":8,"firstname":"user","lastname":"1","email":"user1@test.com","telephone":"9999999999","product":"MacBook","product_id":43,"model":"Product 16","quantity":2,"opened":0,"return_reason_id":2,"comment":"WRONG product","date_ordered":"30/08/2022"}}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDkyNDAwLCJuYmYiOjE2NjM0OTI0MDUsImV4cCI6MTY2MzQ5MzIwMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.bUELo20SHghR-ULPTlbGC0xpfPTxtYRjxDevxOnNXWA',
'Content-Type: application/json',
'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDkyNDAwLCJuYmYiOjE2NjM0OTI0MDUsImV4cCI6MTY2MzQ5MzIwMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.bUELo20SHghR-ULPTlbGC0xpfPTxtYRjxDevxOnNXWA",
"Content-Type": "application/json",
"Cookie": "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation add_return($return_data:ReturnInput){\r\n addReturn(input:$return_data)\r\n}",
variables: {"return_data":{"order_id":8,"firstname":"user","lastname":"1","email":"user1@test.com","telephone":"9999999999","product":"MacBook","product_id":43,"model":"Product 16","quantity":2,"opened":0,"return_reason_id":2,"comment":"WRONG product","date_ordered":"30/08/2022"}}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDkyNDAwLCJuYmYiOjE2NjM0OTI0MDUsImV4cCI6MTY2MzQ5MzIwMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.bUELo20SHghR-ULPTlbGC0xpfPTxtYRjxDevxOnNXWA',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation add_return($return_data:ReturnInput){
addReturn(input:$return_data)
}`,
variables: {"return_data":{"order_id":8,"firstname":"user","lastname":"1","email":"user1@test.com","telephone":"9999999999","product":"MacBook","product_id":43,"model":"Product 16","quantity":2,"opened":0,"return_reason_id":2,"comment":"WRONG product","date_ordered":"30/08/2022"}}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation add_return($return_data:ReturnInput){\\r\\n addReturn(input:$return_data)\\r\\n}\",\"variables\":{\"return_data\":{\"order_id\":8,\"firstname\":\"user\",\"lastname\":\"1\",\"email\":\"user1@test.com\",\"telephone\":\"9999999999\",\"product\":\"MacBook\",\"product_id\":43,\"model\":\"Product 16\",\"quantity\":2,\"opened\":0,\"return_reason_id\":2,\"comment\":\"WRONG product\",\"date_ordered\":\"30/08/2022\"}}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDkyNDAwLCJuYmYiOjE2NjM0OTI0MDUsImV4cCI6MTY2MzQ5MzIwMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.bUELo20SHghR-ULPTlbGC0xpfPTxtYRjxDevxOnNXWA',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDkyNDAwLCJuYmYiOjE2NjM0OTI0MDUsImV4cCI6MTY2MzQ5MzIwMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.bUELo20SHghR-ULPTlbGC0xpfPTxtYRjxDevxOnNXWA");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation add_return($return_data:ReturnInput){\\r\\n addReturn(input:$return_data)\\r\\n}\",\"variables\":{\"return_data\":{\"order_id\":8,\"firstname\":\"user\",\"lastname\":\"1\",\"email\":\"user1@test.com\",\"telephone\":\"9999999999\",\"product\":\"MacBook\",\"product_id\":43,\"model\":\"Product 16\",\"quantity\":2,\"opened\":0,\"return_reason_id\":2,\"comment\":\"WRONG product\",\"date_ordered\":\"30/08/2022\"}}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDkyNDAwLCJuYmYiOjE2NjM0OTI0MDUsImV4cCI6MTY2MzQ5MzIwMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.bUELo20SHghR-ULPTlbGC0xpfPTxtYRjxDevxOnNXWA' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation add_return($return_data:ReturnInput){\r\n addReturn(input:$return_data)\r\n}","variables":{"return_data":{"order_id":8,"firstname":"user","lastname":"1","email":"user1@test.com","telephone":"9999999999","product":"MacBook","product_id":43,"model":"Product 16","quantity":2,"opened":0,"return_reason_id":2,"comment":"WRONG product","date_ordered":"30/08/2022"}}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation add_return($return_data:ReturnInput){\\r\\n addReturn(input:$return_data)\\r\\n}\",\"variables\":{\"return_data\":{\"order_id\":8,\"firstname\":\"user\",\"lastname\":\"1\",\"email\":\"user1@test.com\",\"telephone\":\"9999999999\",\"product\":\"MacBook\",\"product_id\":43,\"model\":\"Product 16\",\"quantity\":2,\"opened\":0,\"return_reason_id\":2,\"comment\":\"WRONG product\",\"date_ordered\":\"30/08/2022\"}}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDkyNDAwLCJuYmYiOjE2NjM0OTI0MDUsImV4cCI6MTY2MzQ5MzIwMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.bUELo20SHghR-ULPTlbGC0xpfPTxtYRjxDevxOnNXWA")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDkyNDAwLCJuYmYiOjE2NjM0OTI0MDUsImV4cCI6MTY2MzQ5MzIwMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.bUELo20SHghR-ULPTlbGC0xpfPTxtYRjxDevxOnNXWA"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation add_return($return_data:ReturnInput){\\r\\n addReturn(input:$return_data)\\r\\n}\",\"variables\":{\"return_data\":{\"order_id\":8,\"firstname\":\"user\",\"lastname\":\"1\",\"email\":\"user1@test.com\",\"telephone\":\"9999999999\",\"product\":\"MacBook\",\"product_id\":43,\"model\":\"Product 16\",\"quantity\":2,\"opened\":0,\"return_reason_id\":2,\"comment\":\"WRONG product\",\"date_ordered\":\"30/08/2022\"}}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"addReturn": "16"
}
}
Opencart Get Return API
Return by id api.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| token | string |
Authrization |
Required |
Bearer token |
| return_id | integer |
Body |
Required |
return id |
| Parameter | token |
|---|---|
| Type | string |
| Position | Authrization |
| # | Required |
| Description | Bearer token |
| Parameter | return_id |
| Type | integer |
| Position | Body |
| # | Required |
| Description | return id |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"query get_return($return_id:Int!){\\r\\n return(return_id:$return_id){\\r\\n return_id order_id comment firstname lastname email telephone product model quantity opened reason status comment date_ordered date_added date_modified\\r\\n }\\r\\n}","variables":{"return_id":15}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTAxNDY1LCJuYmYiOjE2NjM1MDE0NzAsImV4cCI6MTY2MzUwMjI2NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.N1O7hEq55-Wk__t_NzYeGfraNqryFxGm9lKzkmBpGIQ',
'Content-Type: application/json',
'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTAxNDY1LCJuYmYiOjE2NjM1MDE0NzAsImV4cCI6MTY2MzUwMjI2NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.N1O7hEq55-Wk__t_NzYeGfraNqryFxGm9lKzkmBpGIQ",
"Content-Type": "application/json",
"Cookie": "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "query get_return($return_id:Int!){\r\n return(return_id:$return_id){\r\n return_id order_id comment firstname lastname email telephone product model quantity opened reason status comment date_ordered date_added date_modified\r\n }\r\n}",
variables: {"return_id":15}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTAxNDY1LCJuYmYiOjE2NjM1MDE0NzAsImV4cCI6MTY2MzUwMjI2NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.N1O7hEq55-Wk__t_NzYeGfraNqryFxGm9lKzkmBpGIQ',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `query get_return($return_id:Int!){
return(return_id:$return_id){
return_id order_id comment firstname lastname email telephone product model quantity opened reason status comment date_ordered date_added date_modified
}
}`,
variables: {"return_id":15}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"query get_return($return_id:Int!){\\r\\n return(return_id:$return_id){\\r\\n return_id order_id comment firstname lastname email telephone product model quantity opened reason status comment date_ordered date_added date_modified\\r\\n }\\r\\n}\",\"variables\":{\"return_id\":15}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTAxNDY1LCJuYmYiOjE2NjM1MDE0NzAsImV4cCI6MTY2MzUwMjI2NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.N1O7hEq55-Wk__t_NzYeGfraNqryFxGm9lKzkmBpGIQ',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTAxNDY1LCJuYmYiOjE2NjM1MDE0NzAsImV4cCI6MTY2MzUwMjI2NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.N1O7hEq55-Wk__t_NzYeGfraNqryFxGm9lKzkmBpGIQ");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"query get_return($return_id:Int!){\\r\\n return(return_id:$return_id){\\r\\n return_id order_id comment firstname lastname email telephone product model quantity opened reason status comment date_ordered date_added date_modified\\r\\n }\\r\\n}\",\"variables\":{\"return_id\":15}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTAxNDY1LCJuYmYiOjE2NjM1MDE0NzAsImV4cCI6MTY2MzUwMjI2NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.N1O7hEq55-Wk__t_NzYeGfraNqryFxGm9lKzkmBpGIQ' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb' \
--data-raw '{"query":"query get_return($return_id:Int!){\r\n return(return_id:$return_id){\r\n return_id order_id comment firstname lastname email telephone product model quantity opened reason status comment date_ordered date_added date_modified\r\n }\r\n}","variables":{"return_id":15}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query get_return($return_id:Int!){\\r\\n return(return_id:$return_id){\\r\\n return_id order_id comment firstname lastname email telephone product model quantity opened reason status comment date_ordered date_added date_modified\\r\\n }\\r\\n}\",\"variables\":{\"return_id\":15}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTAxNDY1LCJuYmYiOjE2NjM1MDE0NzAsImV4cCI6MTY2MzUwMjI2NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.N1O7hEq55-Wk__t_NzYeGfraNqryFxGm9lKzkmBpGIQ")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTAxNDY1LCJuYmYiOjE2NjM1MDE0NzAsImV4cCI6MTY2MzUwMjI2NSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.N1O7hEq55-Wk__t_NzYeGfraNqryFxGm9lKzkmBpGIQ"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
request.body = "{\"query\":\"query get_return($return_id:Int!){\\r\\n return(return_id:$return_id){\\r\\n return_id order_id comment firstname lastname email telephone product model quantity opened reason status comment date_ordered date_added date_modified\\r\\n }\\r\\n}\",\"variables\":{\"return_id\":15}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"return": {
"return_id": "15",
"order_id": 8,
"comment": "WRONG product",
"firstname": "user",
"lastname": "1",
"email": "user1@test.com",
"telephone": "9999999999",
"product": "iPhone",
"model": "product 11",
"quantity": 2,
"opened": false,
"reason": "Received Wrong Item",
"status": "Awaiting Products",
"date_ordered": "0000-00-00",
"date_added": "2022-09-12 12:45:11",
"date_modified": "2022-09-12 12:45:11"
}
}
}
Opencart Return History API
Return history by id api.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| token | string |
Authrization |
Required |
Bearer token |
| return_id | integer |
Body |
Required |
return id |
| Parameter | token |
|---|---|
| Type | string |
| Position | Authrization |
| # | Required |
| Description | Bearer token |
| Parameter | return_id |
| Type | integer |
| Position | Body |
| # | Required |
| Description | return id |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"query get_return_histrory($return_id:Int){\\r\\n ReturnHistories(return_id:$return_id){\\r\\n comment date_added status\\r\\n }\\r\\n}","variables":{"return_id":15}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTAzMTcwLCJuYmYiOjE2NjM1MDMxNzUsImV4cCI6MTY2MzUwMzk3MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.8lAKlNxGKE7hA1UegTgAkW7POoLhK40MvTSxAGpwaCk',
'Content-Type: application/json',
'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTAzMTcwLCJuYmYiOjE2NjM1MDMxNzUsImV4cCI6MTY2MzUwMzk3MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.8lAKlNxGKE7hA1UegTgAkW7POoLhK40MvTSxAGpwaCk",
"Content-Type": "application/json",
"Cookie": "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "query get_return_histrory($return_id:Int){\r\n ReturnHistories(return_id:$return_id){\r\n comment date_added status\r\n }\r\n}",
variables: {"return_id":15}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTAzMTcwLCJuYmYiOjE2NjM1MDMxNzUsImV4cCI6MTY2MzUwMzk3MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.8lAKlNxGKE7hA1UegTgAkW7POoLhK40MvTSxAGpwaCk',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `query get_return_histrory($return_id:Int){
ReturnHistories(return_id:$return_id){
comment date_added status
}
}`,
variables: {"return_id":15}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"query get_return_histrory($return_id:Int){\\r\\n ReturnHistories(return_id:$return_id){\\r\\n comment date_added status\\r\\n }\\r\\n}\",\"variables\":{\"return_id\":15}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTAzMTcwLCJuYmYiOjE2NjM1MDMxNzUsImV4cCI6MTY2MzUwMzk3MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.8lAKlNxGKE7hA1UegTgAkW7POoLhK40MvTSxAGpwaCk',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTAzMTcwLCJuYmYiOjE2NjM1MDMxNzUsImV4cCI6MTY2MzUwMzk3MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.8lAKlNxGKE7hA1UegTgAkW7POoLhK40MvTSxAGpwaCk");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"query get_return_histrory($return_id:Int){\\r\\n ReturnHistories(return_id:$return_id){\\r\\n comment date_added status\\r\\n }\\r\\n}\",\"variables\":{\"return_id\":15}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTAzMTcwLCJuYmYiOjE2NjM1MDMxNzUsImV4cCI6MTY2MzUwMzk3MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.8lAKlNxGKE7hA1UegTgAkW7POoLhK40MvTSxAGpwaCk' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb' \
--data-raw '{"query":"query get_return_histrory($return_id:Int){\r\n ReturnHistories(return_id:$return_id){\r\n comment date_added status\r\n }\r\n}","variables":{"return_id":15}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query get_return_histrory($return_id:Int){\\r\\n ReturnHistories(return_id:$return_id){\\r\\n comment date_added status\\r\\n }\\r\\n}\",\"variables\":{\"return_id\":15}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTAzMTcwLCJuYmYiOjE2NjM1MDMxNzUsImV4cCI6MTY2MzUwMzk3MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.8lAKlNxGKE7hA1UegTgAkW7POoLhK40MvTSxAGpwaCk")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNTAzMTcwLCJuYmYiOjE2NjM1MDMxNzUsImV4cCI6MTY2MzUwMzk3MCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.8lAKlNxGKE7hA1UegTgAkW7POoLhK40MvTSxAGpwaCk"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb"
request.body = "{\"query\":\"query get_return_histrory($return_id:Int){\\r\\n ReturnHistories(return_id:$return_id){\\r\\n comment date_added status\\r\\n }\\r\\n}\",\"variables\":{\"return_id\":15}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"ReturnHistories": [
{
"comment": "",
"date_added": "2022-09-18 12:14:31",
"status": "Awaiting Products"
},
{
"comment": "",
"date_added": "2022-09-18 12:14:37",
"status": "Pending"
},
{
"comment": "",
"date_added": "2022-09-18 12:14:40",
"status": "Complete"
}
]
}
}
Opencart Products List API
Products list api.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| filter_category_id | integer |
Body |
Optional |
Filter By category id |
| filter_sub_category | integer |
Body |
Optional |
Filter By sub category id |
| filter_filter | string |
Body |
Optional |
filter |
| filter_name | string |
Body |
Optional |
filter by product name |
| filter_tag | string |
Body |
Optional |
filter by tag |
| filter_description | string |
Body |
Optional |
filter by description. |
| filter_quantity | string |
Body |
Optional |
filter by product quantity. |
| filter_status | string |
Body |
Optional |
filter by product status. |
| filter_manufacturer_id | Integer |
Body |
Optional |
filter by product manufacturer id. |
| sort | string |
Body |
Optional |
filter by sort. |
| order | string |
Body |
Optional |
filter by order. |
| start | Integer |
Body |
Optional |
filter product start from . |
| limit | Integer |
Body |
Optional |
filter product number length. |
| Parameter | filter_category_id |
|---|---|
| Type | integer |
| Position | Body |
| # | Optional |
| Description | Filter By category id |
| Parameter | filter_sub_category |
| Type | integer |
| Position | Body |
| # | Optional |
| Description | Filter By sub category id |
| Parameter | filter_filter |
| Type | string |
| Position | Body |
| # | Optional |
| Description | filter. |
| Parameter | filter_name |
| Type | string |
| Position | Body |
| # | Body |
| Description | filter by product name. |
| Parameter | filter_tag |
| Type | string |
| Position | Body |
| # | Optional |
| Description | filter by tag. |
| Parameter | filter_description |
| Type | string |
| Position | Body |
| # | Optional |
| Description | filter by description. |
| Parameter | filter_quantity |
| Type | string |
| Position | Body |
| # | Optional |
| Description | filter by product quantity. |
| Parameter | filter_status |
| Type | string |
| Position | Body |
| # | Optional |
| Description | filter by product status. |
| Parameter | filter_manufacturer_id |
| Type | Integer |
| Position | Body |
| # | Optional |
| Description | filter by product manufacturer id. |
| Parameter | sort |
| Type | Integer |
| Position | Body |
| # | Optional |
| Description | filter by sort. |
| Parameter | order |
| Type | string |
| Position | Body |
| # | Optional |
| Description | filter by order. |
| Parameter | start |
| Type | Integer |
| Position | Body |
| # | Optional |
| Description | filter product start from. |
| Parameter | limit |
| Type | Integer |
| Position | Body |
| # | Optional |
| Description | filter product number length. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"query product_get($start:Int,$limit:Int){\\r\\n products(start:$start,limit:$limit){\\r\\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\\r\\n \\r\\n }\\r\\n}","variables":{"start":0,"limit":1}}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Cookie: OCSESSID=53d60509bdbc26bd5e97f9a973; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Cookie": "OCSESSID=53d60509bdbc26bd5e97f9a973; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "query product_get($start:Int,$limit:Int){\r\n products(start:$start,limit:$limit){\r\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\r\n \r\n }\r\n}",
variables: {"start":0,"limit":1}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=53d60509bdbc26bd5e97f9a973; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `query product_get($start:Int,$limit:Int){
products(start:$start,limit:$limit){
product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}
}
}`,
variables: {"start":0,"limit":1}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"query product_get($start:Int,$limit:Int){\\r\\n products(start:$start,limit:$limit){\\r\\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\\r\\n \\r\\n }\\r\\n}\",\"variables\":{\"start\":0,\"limit\":1}}"
headers = {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=53d60509bdbc26bd5e97f9a973; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=53d60509bdbc26bd5e97f9a973; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"query product_get($start:Int,$limit:Int){\\r\\n products(start:$start,limit:$limit){\\r\\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\\r\\n \\r\\n }\\r\\n}\",\"variables\":{\"start\":0,\"limit\":1}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=53d60509bdbc26bd5e97f9a973; currency=USD; language=en-gb' \
--data-raw '{"query":"query product_get($start:Int,$limit:Int){\r\n products(start:$start,limit:$limit){\r\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\r\n \r\n }\r\n}","variables":{"start":0,"limit":1}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query product_get($start:Int,$limit:Int){\\r\\n products(start:$start,limit:$limit){\\r\\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\\r\\n \\r\\n }\\r\\n}\",\"variables\":{\"start\":0,\"limit\":1}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=53d60509bdbc26bd5e97f9a973; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=53d60509bdbc26bd5e97f9a973; currency=USD; language=en-gb"
request.body = "{\"query\":\"query product_get($start:Int,$limit:Int){\\r\\n products(start:$start,limit:$limit){\\r\\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\\r\\n \\r\\n }\\r\\n}\",\"variables\":{\"start\":0,\"limit\":1}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"products": [
{
"product_id": "42",
"model": "Product 15",
"description": "\r\n\tThe 30-inch Apple Cinema HD Display delivers an amazing 2560 x 1600 pixel resolution. Designed specifically for the creative professional, this display provides more space for easier access to all the tools and palettes needed to edit, format and composite your work. Combine this display with a Mac Pro, MacBook Pro, or PowerMac G5 and there's no limit to what you can achieve. \r\n\t\r\n\tThe Cinema HD features an active-matrix liquid crystal display that produces flicker-free images that deliver twice the brightness, twice the sharpness and twice the contrast ratio of a typical CRT display. Unlike other flat panels, it's designed with a pure digital interface to deliver distortion-free images that never need adjusting. With over 4 million digital pixels, the display is uniquely suited for scientific and technical applications such as visualizing molecular structures or analyzing geological data. \r\n\t\r\n\tOffering accurate, brilliant color performance, the Cinema HD delivers up to 16.7 million colors across a wide gamut allowing you to see subtle nuances between colors from soft pastels to rich jewel tones,"
"meta_title": "Apple Cinema 30",
"meta_description": "",
"meta_keyword": "",
"tag": "",
"sku": "",
"upc": "",
"ean": "",
"jan": "",
"isbn": "",
"mpn": "",
"location": "",
"quantity": "988",
"stock_status": "Out Of Stock",
"image": "catalog/demo/apple_cinema_30.jpg",
"manufacturer": {
"manufacturer_id": "8",
"name": "Apple"
},
"in_stock": true,
"price": "100.0000",
"special": "90.0000",
"formatted_price": "$100.00",
"formatted_special": "$90.00",
"reward": "100",
"date_available": "2009-02-04",
"tax_class_id": "9",
"weight": "12.50000000",
"weight_class_id": "1",
"length": 1,
"width": 2,
"height": 3,
"length_class_id": "1",
"subtract": "1",
"rating": 0,
"review_count": null,
"minimum": "2",
"sort_order": "0",
"status": "1",
"date_added": "2009-02-03 21:07:37",
"date_modified": "2011-09-30 00:46:19",
"categories": [
{
"category_id": "20",
"name": "Desktops"
},
{
"category_id": "28",
"name": "Monitors"
}
],
"images": [
{
"image": "catalog/demo/canon_logo.jpg"
},
{
"image": "catalog/demo/hp_1.jpg"
},
{
"image": "catalog/demo/compaq_presario.jpg"
},
{
"image": "catalog/demo/canon_eos_5d_1.jpg"
},
{
"image": "catalog/demo/canon_eos_5d_2.jpg"
}
]
}
]
}
}
Opencart Products Detail API
Products detail api.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| product_id | integer |
Body |
Required |
product id to get details |
| Parameter | product_id |
|---|---|
| Type | integer |
| Position | Body |
| # | Required |
| Description | product id to get details |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"query product($product_id:ID!){ product(id:$product_id){product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image} }}","variables":{"product_id":42}}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Cookie": "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "query product($product_id:ID!){ product(id:$product_id){product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image} }}",
variables: {"product_id":42}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `query product($product_id:ID!){ product(id:$product_id){product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image} }}`,
variables: {"product_id":42}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"query product_get($start:Int,$limit:Int){\\r\\n products(start:$start,limit:$limit){\\r\\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\\r\\n \\r\\n }\\r\\n}\",\"variables\":{\"start\":0,\"limit\":1}}"
headers = {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=53d60509bdbc26bd5e97f9a973; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"query product($product_id:ID!){ product(id:$product_id){product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image} }}\",\"variables\":{\"product_id\":42}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb' \
--data-raw '{"query":"query product($product_id:ID!){ product(id:$product_id){product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image} }}","variables":{"product_id":42}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query product($product_id:ID!){ product(id:$product_id){product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image} }}\",\"variables\":{\"product_id\":42}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
request.body = "{\"query\":\"query product($product_id:ID!){ product(id:$product_id){product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image} }}\",\"variables\":{\"product_id\":42}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"products": [
{
"product_id": "42",
"model": "Product 15",
"description": "\r\n\tThe 30-inch Apple Cinema HD Display delivers an amazing 2560 x 1600 pixel resolution. Designed specifically for the creative professional, this display provides more space for easier access to all the tools and palettes needed to edit, format and composite your work. Combine this display with a Mac Pro, MacBook Pro, or PowerMac G5 and there's no limit to what you can achieve. \r\n\t\r\n\tThe Cinema HD features an active-matrix liquid crystal display that produces flicker-free images that deliver twice the brightness, twice the sharpness and twice the contrast ratio of a typical CRT display. Unlike other flat panels, it's designed with a pure digital interface to deliver distortion-free images that never need adjusting. With over 4 million digital pixels, the display is uniquely suited for scientific and technical applications such as visualizing molecular structures or analyzing geological data. \r\n\t\r\n\tOffering accurate, brilliant color performance, the Cinema HD delivers up to 16.7 million colors across a wide gamut allowing you to see subtle nuances between colors from soft pastels to rich jewel tones,"
"meta_title": "Apple Cinema 30",
"meta_description": "",
"meta_keyword": "",
"tag": "",
"sku": "",
"upc": "",
"ean": "",
"jan": "",
"isbn": "",
"mpn": "",
"location": "",
"quantity": "988",
"stock_status": "Out Of Stock",
"image": "catalog/demo/apple_cinema_30.jpg",
"manufacturer": {
"manufacturer_id": "8",
"name": "Apple"
},
"in_stock": true,
"price": "100.0000",
"special": "90.0000",
"formatted_price": "$100.00",
"formatted_special": "$90.00",
"reward": "100",
"date_available": "2009-02-04",
"tax_class_id": "9",
"weight": "12.50000000",
"weight_class_id": "1",
"length": 1,
"width": 2,
"height": 3,
"length_class_id": "1",
"subtract": "1",
"rating": 0,
"review_count": null,
"minimum": "2",
"sort_order": "0",
"status": "1",
"date_added": "2009-02-03 21:07:37",
"date_modified": "2011-09-30 00:46:19",
"categories": [
{
"category_id": "20",
"name": "Desktops"
},
{
"category_id": "28",
"name": "Monitors"
}
],
"images": [
{
"image": "catalog/demo/canon_logo.jpg"
},
{
"image": "catalog/demo/hp_1.jpg"
},
{
"image": "catalog/demo/compaq_presario.jpg"
},
{
"image": "catalog/demo/canon_eos_5d_1.jpg"
},
{
"image": "catalog/demo/canon_eos_5d_2.jpg"
}
]
}
]
}
}
Opencart add product review API
The product review API allow you to add product review.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| Token | string |
Authorization |
Required |
Bearer token |
| product_id | ID |
Body GRAPHQL VARIABLES
|
Required |
Product id to add review |
| input | ReviewInput |
Body GRAPHQL VARIABLES
|
Required |
review data |
| Parameter | Token |
|---|---|
| Type | string |
| Position | Authorization |
| # | Required |
| Description | Brearer Token |
| Parameter | product_id |
| Type | ID |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | Product id to add review |
| Parameter | input |
| Type | string |
| Position | Body GRAPHQL VARIABLES |
| # | Required |
| Description | Review data |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation add($id:ID!,$rev:ReviewInput!){\\r\\n addReview(product_id:$id,input:$rev){\\r\\n status message\\r\\n }\\r\\n}","variables":{"id":"42","rev":{"name":"tarun","rating":3,"text":"tttttt"}}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE3NzIwLCJuYmYiOjE2NjM0MTc3MjUsImV4cCI6MTY2MzQxODUyMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.PTKtznoqn8hku5mKgxguvM3EMB8a_O6toxr1MA8HEaI',
'Content-Type: application/json',
'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE3NzIwLCJuYmYiOjE2NjM0MTc3MjUsImV4cCI6MTY2MzQxODUyMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.PTKtznoqn8hku5mKgxguvM3EMB8a_O6toxr1MA8HEaI",
"Content-Type": "application/json",
"Cookie": "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation add($id:ID!,$rev:ReviewInput!){\r\n addReview(product_id:$id,input:$rev){\r\n status message\r\n }\r\n}",
variables: {"id":"42","rev":{"name":"tarun","rating":3,"text":"tttttt"}}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE3NzIwLCJuYmYiOjE2NjM0MTc3MjUsImV4cCI6MTY2MzQxODUyMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.PTKtznoqn8hku5mKgxguvM3EMB8a_O6toxr1MA8HEaI',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation add($id:ID!,$rev:ReviewInput!){
addReview(product_id:$id,input:$rev){
status message
}
}`,
variables: {"id":"42","rev":{"name":"tarun","rating":3,"text":"tttttt"}}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation editaddress($address_id:ID!,$address_data:AddressInput!){\\r\\n editAddress(address_id:$address_id,input:$address_data){\\r\\n status\\r\\n }\\r\\n}\",\"variables\":{\"address_id\":\"11\",\"address_data\":{\"firstname\":\"test\",\"lastname\":\"32\",\"company\":\"yyyy\",\"address_1\":\"zzzzz\",\"address_2\":\"yyubbbbbbuyy\",\"postcode\":\"202001\",\"city\":\"ttttttt\",\"zone_id\":\"2\",\"country_id\":\"33\",\"custom_field\":\"\",\"default\":false}}}"
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMzk1MjU2LCJuYmYiOjE2NjMzOTUyNjEsImV4cCI6MTY2MzM5NjA1NiwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.hKSO4rdmgUWhyHC-67fWVNoUV_xqf2aVaD1AQv1TUcc',
'Cookie': 'OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE3NzIwLCJuYmYiOjE2NjM0MTc3MjUsImV4cCI6MTY2MzQxODUyMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.PTKtznoqn8hku5mKgxguvM3EMB8a_O6toxr1MA8HEaI");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation add($id:ID!,$rev:ReviewInput!){\\r\\n addReview(product_id:$id,input:$rev){\\r\\n status message\\r\\n }\\r\\n}\",\"variables\":{\"id\":\"42\",\"rev\":{\"name\":\"tarun\",\"rating\":3,\"text\":\"tttttt\"}}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE3NzIwLCJuYmYiOjE2NjM0MTc3MjUsImV4cCI6MTY2MzQxODUyMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.PTKtznoqn8hku5mKgxguvM3EMB8a_O6toxr1MA8HEaI' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation add($id:ID!,$rev:ReviewInput!){\r\n addReview(product_id:$id,input:$rev){\r\n status message\r\n }\r\n}","variables":{"id":"42","rev":{"name":"tarun","rating":3,"text":"tttttt"}}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation add($id:ID!,$rev:ReviewInput!){\\r\\n addReview(product_id:$id,input:$rev){\\r\\n status message\\r\\n }\\r\\n}\",\"variables\":{\"id\":\"42\",\"rev\":{\"name\":\"tarun\",\"rating\":3,\"text\":\"tttttt\"}}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE3NzIwLCJuYmYiOjE2NjM0MTc3MjUsImV4cCI6MTY2MzQxODUyMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.PTKtznoqn8hku5mKgxguvM3EMB8a_O6toxr1MA8HEaI")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzNDE3NzIwLCJuYmYiOjE2NjM0MTc3MjUsImV4cCI6MTY2MzQxODUyMCwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.PTKtznoqn8hku5mKgxguvM3EMB8a_O6toxr1MA8HEaI"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=5efa28faa1a9d02dfb4707b96b; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation add($id:ID!,$rev:ReviewInput!){\\r\\n addReview(product_id:$id,input:$rev){\\r\\n status message\\r\\n }\\r\\n}\",\"variables\":{\"id\":\"42\",\"rev\":{\"name\":\"tarun\",\"rating\":3,\"text\":\"tttttt\"}}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"addReview": {
"status": 1,
"message": "Review added successfully"
}
}
}
Opencart bestseller products
Best selle products.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| limit | integer | BODY | Optional | Product limit |
| Parameter | limit |
|---|---|
| Type | integer |
| Position | BODY |
| # | Optional |
| Description | Product limit. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"query bestsellerProducts($limit:Int){\\r\\n bestsellerProducts(limit:$limit){\\r\\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\\r\\n }\\r\\n}","variables":{"limit":1}}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Cookie": "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "query bestsellerProducts($limit:Int){\r\n bestsellerProducts(limit:$limit){\r\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\r\n }\r\n}",
variables: {"limit":1}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `query bestsellerProducts($limit:Int){
bestsellerProducts(limit:$limit){
product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}
}
}`,
variables: {"limit":1}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"query bestsellerProducts($limit:Int){\\r\\n bestsellerProducts(limit:$limit){\\r\\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\\r\\n }\\r\\n}\",\"variables\":{\"limit\":1}}"
headers = {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"query bestsellerProducts($limit:Int){\\r\\n bestsellerProducts(limit:$limit){\\r\\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\\r\\n }\\r\\n}\",\"variables\":{\"limit\":1}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb' \
--data-raw '{"query":"query bestsellerProducts($limit:Int){\r\n bestsellerProducts(limit:$limit){\r\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\r\n }\r\n}","variables":{"limit":1}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query bestsellerProducts($limit:Int){\\r\\n bestsellerProducts(limit:$limit){\\r\\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\\r\\n }\\r\\n}\",\"variables\":{\"limit\":1}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
request.body = "{\"query\":\"query bestsellerProducts($limit:Int){\\r\\n bestsellerProducts(limit:$limit){\\r\\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\\r\\n }\\r\\n}\",\"variables\":{\"limit\":1}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"bestsellerProducts": [
{
"product_id": "40",
"model": "product 11",
"description": "\r\n\tiPhone is a revolutionary new mobile phone that allows you to make a call by simply tapping a name or number in your address book, a favorites list, or a call log. It also automatically syncs all your contacts from a PC, Mac, or Internet service. And it lets you select and listen to voicemail messages in whatever order you want just like email.\r\n",
"meta_title": "iPhone",
"meta_description": "",
"meta_keyword": "",
"tag": "",
"sku": "",
"upc": "",
"ean": "",
"jan": "",
"isbn": "",
"mpn": "",
"location": "",
"quantity": "965",
"stock_status": "Out Of Stock",
"image": "catalog/demo/iphone_1.jpg",
"manufacturer": {
"manufacturer_id": "8",
"name": "Apple"
},
"in_stock": true,
"price": "101.0000",
"special": null,
"formatted_price": "$101.00",
"formatted_special": "$0.00",
"reward": "0",
"date_available": "2009-02-03",
"tax_class_id": "9",
"weight": "10.00000000",
"weight_class_id": "1",
"length": 0,
"width": 0,
"height": 0,
"length_class_id": "1",
"subtract": "1",
"rating": 0,
"review_count": null,
"minimum": "1",
"sort_order": "0",
"status": "1",
"date_added": "2009-02-03 21:07:12",
"date_modified": "2011-09-30 01:06:53",
"categories": [
{
"category_id": "20",
"name": "Desktops"
},
{
"category_id": "24",
"name": "Phones & PDAs"
}
],
"images": [
{
"image": "catalog/demo/iphone_6.jpg"
},
{
"image": "catalog/demo/iphone_2.jpg"
},
{
"image": "catalog/demo/iphone_5.jpg"
},
{
"image": "catalog/demo/iphone_3.jpg"
},
{
"image": "catalog/demo/iphone_4.jpg"
}
]
}
]
}
}
Opencart all language API
The all language API allow you to get all language.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"{\\r\\n languages{\\r\\n language_id\\r\\n name\\r\\n code\\r\\n }\\r\\n}","variables":{}}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Cookie": "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "{\r\n languages{\r\n language_id\r\n name\r\n code\r\n }\r\n}",
variables: {}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=2108decce9e3b41227292d97dd; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `{
languages{
language_id
name
code
}
}`,
variables: {}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"{\\r\\n languages{\\r\\n language_id\\r\\n name\\r\\n code\\r\\n }\\r\\n}\",\"variables\":{}}"
headers = {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"{\\r\\n languages{\\r\\n language_id\\r\\n name\\r\\n code\\r\\n }\\r\\n}\",\"variables\":{}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb' \
--data-raw '{"query":"{\r\n languages{\r\n language_id\r\n name\r\n code\r\n }\r\n}","variables":{}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"{\\r\\n languages{\\r\\n language_id\\r\\n name\\r\\n code\\r\\n }\\r\\n}\",\"variables\":{}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
request.body = "{\"query\":\"{\\r\\n languages{\\r\\n language_id\\r\\n name\\r\\n code\\r\\n }\\r\\n}\",\"variables\":{}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"languages": [
{
"language_id": "1",
"name": "English",
"code": "en-gb"
}
]
}
}
Opencart all country API
The all country API allow you to get all country.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"{\\r\\n countries{\\r\\n \\r\\n country_id name iso_code_2 iso_code_3 postcode_required status\\r\\n }\\r\\n}","variables":{}}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Cookie": "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "{\r\n countries{\r\n \r\n country_id name iso_code_2 iso_code_3 postcode_required status\r\n }\r\n}",
variables: {}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `{
countries{
country_id name iso_code_2 iso_code_3 postcode_required status
}
}`,
variables: {}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"{\\r\\n countries{\\r\\n \\r\\n country_id name iso_code_2 iso_code_3 postcode_required status\\r\\n }\\r\\n}\",\"variables\":{}}"
headers = {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"{\\r\\n countries{\\r\\n \\r\\n country_id name iso_code_2 iso_code_3 postcode_required status\\r\\n }\\r\\n}\",\"variables\":{}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb' \
--data-raw '{"query":"{\r\n countries{\r\n \r\n country_id name iso_code_2 iso_code_3 postcode_required status\r\n }\r\n}","variables":{}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"{\\r\\n countries{\\r\\n \\r\\n country_id name iso_code_2 iso_code_3 postcode_required status\\r\\n }\\r\\n}\",\"variables\":{}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
request.body = "{\"query\":\"{\\r\\n countries{\\r\\n \\r\\n country_id name iso_code_2 iso_code_3 postcode_required status\\r\\n }\\r\\n}\",\"variables\":{}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"countries": [
{
"country_id": "244",
"name": "Aaland Islands",
"iso_code_2": "AX",
"iso_code_3": "ALA",
"postcode_required": "0",
"status": 1
},
{
"country_id": "1",
"name": "Afghanistan",
"iso_code_2": "AF",
"iso_code_3": "AFG",
"postcode_required": "0",
"status": 1
},
{
"country_id": "2",
"name": "Albania",
"iso_code_2": "AL",
"iso_code_3": "ALB",
"postcode_required": "0",
"status": 1
},
{
"country_id": "3",
"name": "Algeria",
"iso_code_2": "DZ",
"iso_code_3": "DZA",
"postcode_required": "0",
"status": 1
},
{
"country_id": "4",
"name": "American Samoa",
"iso_code_2": "AS",
"iso_code_3": "ASM",
"postcode_required": "0",
"status": 1
},
{
"country_id": "5",
"name": "Andorra",
"iso_code_2": "AD",
"iso_code_3": "AND",
"postcode_required": "0",
"status": 1
},
...........
...........
more.......
]
}
}
Opencart get country by id API
Get country details by country id.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| country_id | ID | BODY | # | Country id to get country details |
| Parameter | country_id |
|---|---|
| Type | ID |
| Position | BODY |
| # | Required |
| Description | Country id to get country details. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"query get_country($country_id:ID!){\\r\\n country(id:$country_id){\\r\\n country_id name iso_code_2 iso_code_3 postcode_required status\\r\\n }\\r\\n}","variables":{"country_id":"99"}}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Cookie": "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "query get_country($country_id:ID!){\r\n country(id:$country_id){\r\n country_id name iso_code_2 iso_code_3 postcode_required status\r\n }\r\n}",
variables: {"country_id":"99"}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `query get_country($country_id:ID!){
country(id:$country_id){
country_id name iso_code_2 iso_code_3 postcode_required status
}
}`,
variables: {"country_id":"99"}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"query get_country($country_id:ID!){\\r\\n country(id:$country_id){\\r\\n country_id name iso_code_2 iso_code_3 postcode_required status\\r\\n }\\r\\n}\",\"variables\":{\"country_id\":\"99\"}}"
headers = {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"query get_country($country_id:ID!){\\r\\n country(id:$country_id){\\r\\n country_id name iso_code_2 iso_code_3 postcode_required status\\r\\n }\\r\\n}\",\"variables\":{\"country_id\":\"99\"}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb' \
--data-raw '{"query":"query get_country($country_id:ID!){\r\n country(id:$country_id){\r\n country_id name iso_code_2 iso_code_3 postcode_required status\r\n }\r\n}","variables":{"country_id":"99"}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query get_country($country_id:ID!){\\r\\n country(id:$country_id){\\r\\n country_id name iso_code_2 iso_code_3 postcode_required status\\r\\n }\\r\\n}\",\"variables\":{\"country_id\":\"99\"}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
request.body = "{\"query\":\"query get_country($country_id:ID!){\\r\\n country(id:$country_id){\\r\\n country_id name iso_code_2 iso_code_3 postcode_required status\\r\\n }\\r\\n}\",\"variables\":{\"country_id\":\"99\"}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"country": {
"country_id": "99",
"name": "India",
"iso_code_2": "IN",
"iso_code_3": "IND",
"postcode_required": "0",
"status": 1
}
}
}
Opencart get zones by country id API
Get zones details by country id.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| country_id | ID | BODY | # | Country id to get country details |
| Parameter | country_id |
|---|---|
| Type | ID |
| Position | BODY |
| # | Required |
| Description | Country id to get zones details. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"query get_zones($c_id:ID!){\\r\\n zones(country_id:$c_id){\\r\\n zone_id country{name } name code status\\r\\n }\\r\\n}","variables":{"c_id":"99"}}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Cookie": "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "query get_zones($c_id:ID!){\r\n zones(country_id:$c_id){\r\n zone_id country{name } name code status\r\n }\r\n}",
variables: {"c_id":"99"}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `query get_zones($c_id:ID!){
zones(country_id:$c_id){
zone_id country{name } name code status
}
}`,
variables: {"c_id":"99"}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"query get_zones($c_id:ID!){\\r\\n zones(country_id:$c_id){\\r\\n zone_id country{name } name code status\\r\\n }\\r\\n}\",\"variables\":{\"c_id\":\"99\"}}"
headers = {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"query get_zones($c_id:ID!){\\r\\n zones(country_id:$c_id){\\r\\n zone_id country{name } name code status\\r\\n }\\r\\n}\",\"variables\":{\"c_id\":\"99\"}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb' \
--data-raw '{"query":"query get_zones($c_id:ID!){\r\n zones(country_id:$c_id){\r\n zone_id country{name } name code status\r\n }\r\n}","variables":{"c_id":"99"}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query get_zones($c_id:ID!){\\r\\n zones(country_id:$c_id){\\r\\n zone_id country{name } name code status\\r\\n }\\r\\n}\",\"variables\":{\"c_id\":\"99\"}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
request.body = "{\"query\":\"query get_zones($c_id:ID!){\\r\\n zones(country_id:$c_id){\\r\\n zone_id country{name } name code status\\r\\n }\\r\\n}\",\"variables\":{\"c_id\":\"99\"}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"zones": [
{
"zone_id": "1475",
"country": {
"name": "India"
},
"name": "Andaman and Nicobar Islands",
"code": "AN",
"status": 1
},
{
"zone_id": "1476",
"country": {
"name": "India"
},
"name": "Andhra Pradesh",
"code": "AP",
"status": 1
},
{
"zone_id": "1477",
"country": {
"name": "India"
},
"name": "Arunachal Pradesh",
"code": "AR",
"status": 1
},
{
"zone_id": "1478",
"country": {
"name": "India"
},
"name": "Assam",
"code": "AS",
"status": 1
},
{
"zone_id": "1479",
"country": {
"name": "India"
},
"name": "Bihar",
"code": "BI",
"status": 1
},
{
"zone_id": "1480",
"country": {
"name": "India"
},
"name": "Chandigarh",
"code": "CH",
"status": 1
},
{
"zone_id": "1481",
"country": {
"name": "India"
},
"name": "Dadra and Nagar Haveli",
"code": "DA",
"status": 1
},
. . . . . .
. . . . . .
more . . .
]
}
}
Opencart get zone by zone id API
Get zone details by zone id.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| zone_id | ID | BODY | # | Country id to get zone details |
| Parameter | zone_id |
|---|---|
| Type | ID |
| Position | BODY |
| # | Required |
| Description | Zone id to get zone details. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
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 =>'{"query":"query get_zone($c_id:ID!){\\r\\n zone(id:$c_id){\\r\\n zone_id country{name } name code status\\r\\n }\\r\\n}","variables":{"c_id":1505}}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "GET",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Cookie": "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "query get_zone($c_id:ID!){\r\n zone(id:$c_id){\r\n zone_id country{name } name code status\r\n }\r\n}",
variables: {"c_id":1505}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'GET',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `query get_zone($c_id:ID!){
zone(id:$c_id){
zone_id country{name } name code status
}
}`,
variables: {"c_id":1505}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"query get_zone($c_id:ID!){\\r\\n zone(id:$c_id){\\r\\n zone_id country{name } name code status\\r\\n }\\r\\n}\",\"variables\":{\"c_id\":1505}}"
headers = {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"query get_zone($c_id:ID!){\\r\\n zone(id:$c_id){\\r\\n zone_id country{name } name code status\\r\\n }\\r\\n}\",\"variables\":{\"c_id\":1505}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request GET 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb' \
--data-raw '{"query":"query get_zone($c_id:ID!){\r\n zone(id:$c_id){\r\n zone_id country{name } name code status\r\n }\r\n}","variables":{"c_id":1505}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query get_zone($c_id:ID!){\\r\\n zone(id:$c_id){\\r\\n zone_id country{name } name code status\\r\\n }\\r\\n}\",\"variables\":{\"c_id\":1505}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("GET", body)
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
request.body = "{\"query\":\"query get_zone($c_id:ID!){\\r\\n zone(id:$c_id){\\r\\n zone_id country{name } name code status\\r\\n }\\r\\n}\",\"variables\":{\"c_id\":1505}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"zone": {
"zone_id": "1505",
"country": {
"name": "India"
},
"name": "Uttar Pradesh",
"code": "UP",
"status": 1
}
}
}
Opencart contact us API
Contact us.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| name | string | BODY | # | User name |
| string | BODY | # | User email | |
| enquiry | string | BODY | # | Enquiry message |
| Parameter | name |
|---|---|
| Type | string |
| Position | BODY |
| # | Required |
| Description | user name. |
| Parameter | |
| Type | string |
| Position | BODY |
| # | Required |
| Description | user email. |
| Parameter | enquiry |
| Type | string |
| Position | BODY |
| # | Required |
| Description | Enquiry message. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"mutation contactus($name:String!,$email:String!,$enquiry:String!){\\r\\n contactus(name:$name,email:$email,enquiry:$enquiry)\\r\\n}","variables":{"name":"abc","email":"abc@test.com","enquiry":"enquiry messase"}}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Cookie": "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "mutation contactus($name:String!,$email:String!,$enquiry:String!){\r\n contactus(name:$name,email:$email,enquiry:$enquiry)\r\n}",
variables: {"name":"abc","email":"abc@test.com","enquiry":"enquiry messase"}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `mutation contactus($name:String!,$email:String!,$enquiry:String!){
contactus(name:$name,email:$email,enquiry:$enquiry)
}`,
variables: {"name":"abc","email":"abc@test.com","enquiry":"enquiry messase"}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"mutation contactus($name:String!,$email:String!,$enquiry:String!){\\r\\n contactus(name:$name,email:$email,enquiry:$enquiry)\\r\\n}\",\"variables\":{\"name\":\"abc\",\"email\":\"abc@test.com\",\"enquiry\":\"enquiry messase\"}}"
headers = {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"mutation contactus($name:String!,$email:String!,$enquiry:String!){\\r\\n contactus(name:$name,email:$email,enquiry:$enquiry)\\r\\n}\",\"variables\":{\"name\":\"abc\",\"email\":\"abc@test.com\",\"enquiry\":\"enquiry messase\"}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb' \
--data-raw '{"query":"mutation contactus($name:String!,$email:String!,$enquiry:String!){\r\n contactus(name:$name,email:$email,enquiry:$enquiry)\r\n}","variables":{"name":"abc","email":"abc@test.com","enquiry":"enquiry messase"}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation contactus($name:String!,$email:String!,$enquiry:String!){\\r\\n contactus(name:$name,email:$email,enquiry:$enquiry)\\r\\n}\",\"variables\":{\"name\":\"abc\",\"email\":\"abc@test.com\",\"enquiry\":\"enquiry messase\"}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
request.body = "{\"query\":\"mutation contactus($name:String!,$email:String!,$enquiry:String!){\\r\\n contactus(name:$name,email:$email,enquiry:$enquiry)\\r\\n}\",\"variables\":{\"name\":\"abc\",\"email\":\"abc@test.com\",\"enquiry\":\"enquiry messase\"}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"zone": {
"zone_id": "1505",
"country": {
"name": "India"
},
"name": "Uttar Pradesh",
"code": "UP",
"status": 1
}
}
}
Opencart bestseller products
Best selle products.
POST: /index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| limit | integer | BODY | Optional | Product limit |
| Parameter | limit |
|---|---|
| Type | integer |
| Position | BODY |
| # | Optional |
| Description | Product limit. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"query bestsellerProducts($limit:Int){\\r\\n bestsellerProducts(limit:$limit){\\r\\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\\r\\n }\\r\\n}","variables":{"limit":1}}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Cookie": "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
},
"data": JSON.stringify({
query: "query bestsellerProducts($limit:Int){\r\n bestsellerProducts(limit:$limit){\r\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\r\n }\r\n}",
variables: {"limit":1}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
},
body: JSON.stringify({
query: `query bestsellerProducts($limit:Int){
bestsellerProducts(limit:$limit){
product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}
}
}`,
variables: {"limit":1}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"query bestsellerProducts($limit:Int){\\r\\n bestsellerProducts(limit:$limit){\\r\\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\\r\\n }\\r\\n}\",\"variables\":{\"limit\":1}}"
headers = {
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"query bestsellerProducts($limit:Int){\\r\\n bestsellerProducts(limit:$limit){\\r\\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\\r\\n }\\r\\n}\",\"variables\":{\"limit\":1}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb' \
--data-raw '{"query":"query bestsellerProducts($limit:Int){\r\n bestsellerProducts(limit:$limit){\r\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\r\n }\r\n}","variables":{"limit":1}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query bestsellerProducts($limit:Int){\\r\\n bestsellerProducts(limit:$limit){\\r\\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\\r\\n }\\r\\n}\",\"variables\":{\"limit\":1}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=f00ef44e208e3d696f5e43f6a2; currency=USD; language=en-gb"
request.body = "{\"query\":\"query bestsellerProducts($limit:Int){\\r\\n bestsellerProducts(limit:$limit){\\r\\n product_id model description meta_title meta_description meta_keyword tag model sku upc ean jan isbn mpn location quantity stock_status image manufacturer{ manufacturer_id name } in_stock price special formatted_price formatted_special reward date_available tax_class_id weight weight_class_id length width height length_class_id subtract rating review_count minimum sort_order status date_added date_modified categories{category_id name } images{image}\\r\\n }\\r\\n}\",\"variables\":{\"limit\":1}}"
response = http.request(request)
puts response.read_body
Response
{
"data": {
"bestsellerProducts": [
{
"product_id": "40",
"model": "product 11",
"description": "\r\n\tiPhone is a revolutionary new mobile phone that allows you to make a call by simply tapping a name or number in your address book, a favorites list, or a call log. It also automatically syncs all your contacts from a PC, Mac, or Internet service. And it lets you select and listen to voicemail messages in whatever order you want just like email.\r\n",
"meta_title": "iPhone",
"meta_description": "",
"meta_keyword": "",
"tag": "",
"sku": "",
"upc": "",
"ean": "",
"jan": "",
"isbn": "",
"mpn": "",
"location": "",
"quantity": "965",
"stock_status": "Out Of Stock",
"image": "catalog/demo/iphone_1.jpg",
"manufacturer": {
"manufacturer_id": "8",
"name": "Apple"
},
"in_stock": true,
"price": "101.0000",
"special": null,
"formatted_price": "$101.00",
"formatted_special": "$0.00",
"reward": "0",
"date_available": "2009-02-03",
"tax_class_id": "9",
"weight": "10.00000000",
"weight_class_id": "1",
"length": 0,
"width": 0,
"height": 0,
"length_class_id": "1",
"subtract": "1",
"rating": 0,
"review_count": null,
"minimum": "1",
"sort_order": "0",
"status": "1",
"date_added": "2009-02-03 21:07:12",
"date_modified": "2011-09-30 01:06:53",
"categories": [
{
"category_id": "20",
"name": "Desktops"
},
{
"category_id": "24",
"name": "Phones & PDAs"
}
],
"images": [
{
"image": "catalog/demo/iphone_6.jpg"
},
{
"image": "catalog/demo/iphone_2.jpg"
},
{
"image": "catalog/demo/iphone_5.jpg"
},
{
"image": "catalog/demo/iphone_3.jpg"
},
{
"image": "catalog/demo/iphone_4.jpg"
}
]
}
]
}
}
GET User info API
The user info API is stands for GET request, which is provide the user information
by Bearer_token
.
POST: index.php?route=lets_graphql/lets_graphql
| Parameter | Type | Position | # | Description |
|---|---|---|---|---|
| bearer_token | string |
Authorization |
Required |
Token is generate when user attempt login API. |
| Parameter | bearer_token |
|---|---|
| Type | string |
| Position | Authorization |
| # | Required |
| Description | Token is generate when user attempt login API. |
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"query":"query get_customer($c_id:ID!){customer(id:$c_id){ firstname lastname email}}","variables":{"c_id":1}}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMjI3OTQ5LCJuYmYiOjE2NjMyMjc5NTQsImV4cCI6MTY2MzIyODc0OSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.M7HcEdjgn-ZKthuCSyy4ZNh9jEcaoDjOFdNk8XQXZUg',
'Content-Type: application/json',
'Cookie: OCSESSID=53d60509bdbc26bd5e97f9a973; currency=EUR; language=en-gb'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMjI3OTQ5LCJuYmYiOjE2NjMyMjc5NTQsImV4cCI6MTY2MzIyODc0OSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.M7HcEdjgn-ZKthuCSyy4ZNh9jEcaoDjOFdNk8XQXZUg",
"Content-Type": "application/json",
"Cookie": "OCSESSID=53d60509bdbc26bd5e97f9a973; currency=EUR; language=en-gb"
},
"data": JSON.stringify({
query: "query get_customer($c_id:ID!){customer(id:$c_id){ firstname lastname email}}",
variables: {"c_id":1}
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql',
'headers': {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMjI3OTQ5LCJuYmYiOjE2NjMyMjc5NTQsImV4cCI6MTY2MzIyODc0OSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.M7HcEdjgn-ZKthuCSyy4ZNh9jEcaoDjOFdNk8XQXZUg',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=53d60509bdbc26bd5e97f9a973; currency=EUR; language=en-gb'
},
body: JSON.stringify({
query: `query get_customer($c_id:ID!){customer(id:$c_id){ firstname lastname email}}`,
variables: {"c_id":1}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql"
payload="{\"query\":\"query get_customer($c_id:ID!){customer(id:$c_id){ firstname lastname email}}\",\"variables\":{\"c_id\":1}}"
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMjI3OTQ5LCJuYmYiOjE2NjMyMjc5NTQsImV4cCI6MTY2MzIyODc0OSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.M7HcEdjgn-ZKthuCSyy4ZNh9jEcaoDjOFdNk8XQXZUg',
'Content-Type': 'application/json',
'Cookie': 'OCSESSID=53d60509bdbc26bd5e97f9a973; currency=EUR; language=en-gb'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMjI3OTQ5LCJuYmYiOjE2NjMyMjc5NTQsImV4cCI6MTY2MzIyODc0OSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.M7HcEdjgn-ZKthuCSyy4ZNh9jEcaoDjOFdNk8XQXZUg");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Cookie", "OCSESSID=53d60509bdbc26bd5e97f9a973; currency=EUR; language=en-gb");
request.AddParameter("application/json", "{\"query\":\"query get_customer($c_id:ID!){customer(id:$c_id){ firstname lastname email}}\",\"variables\":{\"c_id\":1}}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request POST 'http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMjI3OTQ5LCJuYmYiOjE2NjMyMjc5NTQsImV4cCI6MTY2MzIyODc0OSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.M7HcEdjgn-ZKthuCSyy4ZNh9jEcaoDjOFdNk8XQXZUg' \
--header 'Content-Type: application/json' \
--header 'Cookie: OCSESSID=53d60509bdbc26bd5e97f9a973; currency=EUR; language=en-gb' \
--data-raw '{"query":"query get_customer($c_id:ID!){customer(id:$c_id){ firstname lastname email}}","variables":{"c_id":1}}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query get_customer($c_id:ID!){customer(id:$c_id){ firstname lastname email}}\",\"variables\":{\"c_id\":1}}");
Request request = new Request.Builder()
.url("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMjI3OTQ5LCJuYmYiOjE2NjMyMjc5NTQsImV4cCI6MTY2MzIyODc0OSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.M7HcEdjgn-ZKthuCSyy4ZNh9jEcaoDjOFdNk8XQXZUg")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "OCSESSID=53d60509bdbc26bd5e97f9a973; currency=EUR; language=en-gb")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "json"
require "net/http"
url = URI("http://localhost/opencart_graphql/index.php?route=lets_graphql/lets_graphql")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUSEVfSVNTVUVSIiwiYXVkIjoiVEhFX0FVRElFTkNFIiwiaWF0IjoxNjYzMjI3OTQ5LCJuYmYiOjE2NjMyMjc5NTQsImV4cCI6MTY2MzIyODc0OSwiZGF0YSI6eyJpZCI6IjEiLCJmaXJzdG5hbWUiOiJ1c2VyMSIsImxhc3RuYW1lIjoiMTEiLCJlbWFpbCI6InVzZXIxQHRlc3QuY29tIn19.M7HcEdjgn-ZKthuCSyy4ZNh9jEcaoDjOFdNk8XQXZUg"
request["Content-Type"] = "application/json"
request["Cookie"] = "OCSESSID=53d60509bdbc26bd5e97f9a973; currency=EUR; language=en-gb"
request.body = "{\"query\":\"query get_customer($c_id:ID!){customer(id:$c_id){ firstname lastname email}}\",\"variables\":{\"c_id\":1}}"
response = http.request(request)
puts response.read_body
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '{{site_url}}/wp-json/letscms/v1/umw-get-user-info?user_id=33',
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_HTTPHEADER => array(
'Cookie: PHPSESSID=auojsobvada704p45fo28j4217'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "{{site_url}}/wp-json/letscms/v1/umw-get-user-info?user_id=33",
"method": "GET",
"timeout": 0,
"headers": {
"Cookie": "PHPSESSID=auojsobvada704p45fo28j4217"
},
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'GET',
'url': '{{site_url}}/wp-json/letscms/v1/umw-get-user-info?user_id=33',
'headers': {
'Cookie': 'PHPSESSID=auojsobvada704p45fo28j4217'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
url = "{{site_url}}/wp-json/letscms/v1/umw-get-user-info?user_id=33"
payload={}
headers = {
'Cookie': 'PHPSESSID=auojsobvada704p45fo28j4217'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("{{site_url}}/wp-json/letscms/v1/umw-get-user-info?user_id=33");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Cookie", "PHPSESSID=auojsobvada704p45fo28j4217");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request GET '{{site_url}}/wp-json/letscms/v1/umw-get-user-info?user_id=33' \
--header 'Cookie: PHPSESSID=auojsobvada704p45fo28j4217'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("{{site_url}}/wp-json/letscms/v1/umw-get-user-info?user_id=33")
.method("GET", null)
.addHeader("Cookie", "PHPSESSID=auojsobvada704p45fo28j4217")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "net/http"
url = URI("{{site_url}}/wp-json/letscms/v1/umw-get-user-info?user_id=33")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Get.new(url)
request["Cookie"] = "PHPSESSID=auojsobvada704p45fo28j4217"
response = http.request(request)
puts response.read_body
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '{{site_url}}/wp-json/letscms/v1/umw-get-user-info?user_key=184930752',
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_HTTPHEADER => array(
'Cookie: PHPSESSID=auojsobvada704p45fo28j4217'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var settings = {
"url": "{{site_url}}/wp-json/letscms/v1/umw-get-user-info?user_key=184930752",
"method": "GET",
"timeout": 0,
"headers": {
"Cookie": "PHPSESSID=auojsobvada704p45fo28j4217"
},
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'GET',
'url': '{{site_url}}/wp-json/letscms/v1/umw-get-user-info?user_key=184930752',
'headers': {
'Cookie': 'PHPSESSID=auojsobvada704p45fo28j4217'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
url = "{{site_url}}/wp-json/letscms/v1/umw-get-user-info?user_key=184930752"
payload={}
headers = {
'Cookie': 'PHPSESSID=auojsobvada704p45fo28j4217'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
var client = new RestClient("{{site_url}}/wp-json/letscms/v1/umw-get-user-info?user_key=184930752");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Cookie", "PHPSESSID=auojsobvada704p45fo28j4217");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location --request GET '{{site_url}}/wp-json/letscms/v1/umw-get-user-info?user_key=184930752' \
--header 'Cookie: PHPSESSID=auojsobvada704p45fo28j4217'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("{{site_url}}/wp-json/letscms/v1/umw-get-user-info?user_key=184930752")
.method("GET", null)
.addHeader("Cookie", "PHPSESSID=auojsobvada704p45fo28j4217")
.build();
Response response = client.newCall(request).execute();
require "uri"
require "net/http"
url = URI("{{site_url}}/wp-json/letscms/v1/umw-get-user-info?user_key=184930752")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Get.new(url)
request["Cookie"] = "PHPSESSID=auojsobvada704p45fo28j4217"
response = http.request(request)
puts response.read_body
Response
{
{
"data": {
"customer": {
"firstname": "user1",
"lastname": "11",
"email": "user1@test.com"
}
}
}