Get started on the G2G OpenAPI with our guide on managing your information on G2G. The G2G OpenAPI can provide the following functionalities for our sellers:
Access keys consist of an access key ID and secret access key.
To access G2G OpenAPI, you will need to request from G2G.
When your request to access G2G OpenAPI is approved, you can create access keys from G2G OpenAPI management page. You authenticate with our API by providing the appropriate key in the request Authorization header. Never share your secret keys. Keep them guarded and secure.
Authentication is handled via HTTP headers, as shown in the table below:
Param | Type | Descritpion |
---|---|---|
g2g-api-key | String | Your access key ID created in G2G. Example: c09222e3fc40ffb25fc947f738b1abf1 |
g2g-userid | String | Your G2G user ID. Example: 509205 |
g2g-signature | String | Signature generated by API path, api_key, user_id and timestamp via HMAC-SHA256 hashing algorithm. Example: e318d3e932719916a9f9ebb57e2011961bd47abfa54a36e040d050d8931596e2 |
g2g-timestamp | timestamp | This is to indicate the timestamp of the request, in miliseconds. Required for all requests. Expires in 5 minutes. Example: 1654675838694 |
Login to https://www.g2g.com/.
On top right of the menu bar, click on your avatar, select API Integration.
Request API integration access if you have not gotten permission to use G2G OpenAPI.
On the API integration page, click "Generate key" to generate the G2G API and Secret key.
var CryptoJS = require("crypto-js");
const secretKey = "dJirm8nG5AqQWoh7J5EHw3373Dk95zjRHaQ3gnv99kw"; // Your API Secret Key
const apiKey = "b5769724c1cb1d52c58717d3d12ae2fe"; // Your API Key
const userId = "100000"; // Your User ID
const timestamp = "1653278884000"; // g2g-timestamp
const canonicalUrl = "/v1/offers/G1650445167989US/inventory_items/ba8551d9-47e3-424a-a809-4f043059eefb"; // API Endpoint
let canonicalString = canonicalUrl + apiKey + userId + String(timestamp);
const signature = CryptoJS.HmacSHA256(canonicalString, secretKey);
console.log(String(signature)) // This value should match with g2g-signature, which is 0884a10b8d07d9fb69cccd3ae0d00fdfbedc6b74fff22ed86b14cd235e73268c
import hashlib, hmac
secret_key = "dJirm8nG5AqQWoh7J5EHw3373Dk95zjRHaQ3gnv99kw" # Your API Secret Key
api_key = "b5769724c1cb1d52c58717d3d12ae2fe" # Your API Key
user_id = "100000" # Your User ID
timestamp = "1653278884000" # g2g-timestamp
canonical_url = "/v1/offers/G1650445167989US/inventory_items/ba8551d9-47e3-424a-a809-4f043059eefb" # API Endpoint
canonical_string = canonical_url + api_key + user_id + str(timestamp);
signature = hmac.new(
key=bytes(secret_key.encode("utf8")),
msg=bytes(canonical_string.encode("utf8")),
digestmod=hashlib.sha256,
).hexdigest()
print(signature) # This value should match with g2g-signature, which is 0884a10b8d07d9fb69cccd3ae0d00fdfbedc6b74fff22ed86b14cd235e73268c
$secret_key = "dJirm8nG5AqQWoh7J5EHw3373Dk95zjRHaQ3gnv99kw"; // Your API Secret Key
$api_key = "b5769724c1cb1d52c58717d3d12ae2fe"; // Your API Key
$user_id = "100000"; // Your User ID
$timestamp = "1653278884000"; // g2g-timestamp
$canonical_url = "/v1/offers/G1650445167989US/inventory_items/ba8551d9-47e3-424a-a809-4f043059eefb"; // API Endpoint
$canonical_string = $canonical_url.$api_key.$user_id.(string)$timestamp;
$signature = hash_hmac("sha256", $canonical_string, $secret_key);
echo $signature; // This value should match with g2g-signature, which is 0884a10b8d07d9fb69cccd3ae0d00fdfbedc6b74fff22ed86b14cd235e73268c
Top Up only supported in V2
Order Delivery Flow is mainly for Top Up order.
delivery_method_list
will be returned in the response.delivery_method_list
, lookup attribute_group_list
.{
"attribute_group_list": [
{
"attribute_group_id": "e02308e5",
"attribute_group_name": "User ID",
"input_field": "text",
"input_settings": {},
"is_required": true,
"attribute_key": "delivery_info_1",
"attribute_list": []
},
{
"attribute_group_id": "1759fb6c",
"attribute_group_name": "Servers (Ragnarok X: Next Generation)",
"input_field": "dropdown",
"input_settings": {
"is_searchable": false
},
"is_required": true,
"attribute_key": "delivery_info_2",
"attribute_list": [
{
"attribute_id": "98f0250f",
"attribute_name": "Aldebaran",
"sub_attribute_list": []
},
{
"attribute_id": "6ab853d2",
"attribute_name": "Angeling",
"sub_attribute_list": []
},
... // more options
]
}
]
}
text
field, which is refers to User ID
input and the attribute_key
is delivery_info_1
.dropdown
field, which is refers to Server
input and the attribute_key
is delivery_info_2
.attribute_key
for integration instead of attribute_group_id
or attribute_group_name
.order.api_delivery
and delivery_method_list
will be provided in the payload.{
"delivery_method_list": [
{
"attribute_group_id": "e02308e5",
"attribute_group_name": "User ID",
"attribute_key": "delivery_info_1",
"attribute_id": "",
"attribute_value": "",
"value": "hello_world"
},
{
"attribute_group_id": "1759fb6c",
"attribute_group_name": "Servers (Ragnarok X: Next Generation)",
"attribute_key": "delivery_info_2",
"attribute_id": "98f0250f",
"attribute_value": "Aldebaran",
"value": ""
}
]
}
delivery_info_1
refers to User ID
and hello_world
is the User ID provided by buyer.delivery_info_2
refers to Servers
and Aldebaran
is the server chosen by buyer.# | Order Status | Description |
---|---|---|
1 | unpaid | Buyer started the checkout process but not yet complete the payment. |
2 | cancelled | Order is cancelled. |
3 | unpaid (rollback from cancelled) | A cancelled order is moved back to unpaid. |
4 | paid | Buyer has completed the checkout process and payment is done and confirmed. |
5 | start_delivering | Delivery is ready. |
6 | delivering | Delivery in progress. |
7 | awaiting_buyer_confirmation | Delivery completed, pending buyer to confirm order received. |
8 | delivered | Buyer has confirmed order received. Quantities in the order is fully delivered. |
9 | partial_delivered | Buyer has confirmed order received. Only some quantities in the order is delivered. |
10 | delivering (rollback from delivered / partial_delivered) | Buyer reported issue after confirmed receipt. |
11 | refunded | Quantity is refunded due to not receiving or defect. |
The following code snippet is a sample error response that contains an error code and message pair:
{
"code": 40400001,
"message": "The requested resource does not exist.",
"warning": "",
"request_id": "595285dc-9c43-4b9c-a1e6-0cd9aff5b084",
"payload": {}
}
When troubleshooting the error, you can divide the error code into two components: REST API HTTP status code and error category code. See the following error code sample:
40400001
404
The following table summarizes the HTTP response codes you may receive from the G2GOpen API.
Status Code | Description |
---|---|
200 | Everything worked as expected. |
400 | The request was unacceptable, often due to missing a required parameter, incorrect data type or incorrect request schema. |
401 | No valid API key provided. For eg:
|
403 | The API key doesn't have permissions to perform the request. |
404 | The requested resource doesn't exist. |
409 | The request conflicts with another request. |
422 | Unprocessable Entity. |
429 | The request cannot be completed because client have exceeded his rate limits. |
500 | Something went wrong on G2GOpenAPI’s end, these are rare. |
Code | Descritpion |
---|---|
40000001 | The request was unacceptable, often due to missing a required parameter. |
40100001 | The request is not authorized and cannot access the requested resource. |
40300001 | The application identified with the request is not available. |
40400001 | The requested resource does not exist. |
40900001 | The requested resource already exists. |
40900002 | Data constraint violation. |
42200001 | Validation error. |
42900001 | Throttle request. |
50000001 | The server encounters an unexpected exception while trying to process the request. Please retry the request. |
Version | Descritpion |
---|---|
V1 | Deprecated. We encourage to use the latest version of G2G OpenAPI. |
V2 | Current version of G2G OpenAPI. |
Please visit https://github.com/g2g-official/open-api-sample to download the sample postman collection as a reference to kickstart your API integration.
Get list of all available services.
language | string Default: "en" Enum: "en" "zh-CN" "id" "zh-TW" Language |
{- "code": 20000001,
- "message": "",
- "warning": "",
- "request_id": "595285dc-9c43-4b9c-a1e6-0cd9aff5b084",
- "payload": {
- "service_list": [
- {
- "service_id": "44b3148a-0dc8-4262-81d8-c762559f0d74",
- "service_name": "Gift Cards",
- "categories": [
- {
- "category_name": "Gift Cards",
- "category_id": "f6fc99db-96d2-4158-a29f-663d9a2f6199"
}, - {
- "category_name": "Video Games",
- "sub_categories": [
- {
- "category_name": "PC Platform",
- "category_id": "2994a61d-3993-44ba-8190-e3daac599278"
}, - {
- "category_name": "PSN (Playstation) Platform",
- "category_id": "96364cef-838f-49c0-9efb-0fa90dfa06d2"
}, - {
- "category_name": "Xbox Platform",
- "category_id": "148255f6-4ab4-4af4-833d-4deedb4fd574"
}, - {
- "category_name": "Nintendo Switch Platform",
- "category_id": "dc67a04b-3aa1-460c-aaa3-549ebecb3404"
}
]
}
]
}
]
}
}
Get brands of a service.
service_id required | string <uuid> Example: 44b3148a-0dc8-4262-81d8-c762559f0d74 The unique identifier of a service. Note: This API have a limit of 1000 results per request |
language | string Default: "en" Enum: "en" "zh-CN" "id" "zh-TW" Language |
q | string Example: q=itunes Search brands by keyword. |
after | string <uuid> Example: after=ba683457-f9d0-4330-bea7-923ed300d2e5 Retrieve next set of brands. |
{- "code": 20000001,
- "message": "",
- "warning": "",
- "request_id": "595285dc-9c43-4b9c-a1e6-0cd9aff5b084",
- "payload": {
- "service_id": "44b3148a-0dc8-4262-81d8-c762559f0d74",
- "brand_list": [
- {
- "brand_id": "8c42b2d4-6d2c-4188-931a-240d2f94183f",
- "brand_name": "Apple iTunes"
}, - {
- "brand_id": "lgc_game_25055",
- "brand_name": "PlayStation Network"
}
], - "after": "lgc_game_25055"
}
}
Get products of a brand.
category_id | string <uuid> Example: category_id=f6fc99db-96d2-4158-a29f-663d9a2f6199 The unique identifier of a category. |
service_id | string <uuid> Example: service_id=44b3148a-0dc8-4262-81d8-c762559f0d74 The unique identifier of a service. Required when category_id is not provided |
brand_id | string <uuid> Example: brand_id=8c42b2d4-6d2c-4188-931a-240d2f94183f The unique identifier of a brand. Required when service_id is provided |
q | string Example: q=itunes Search products by brand keyword. |
{- "code": 20000001,
- "message": "",
- "warning": "",
- "request_id": "5cd2b212-868f-4d0a-b05f-37e93a37529b",
- "payload": {
- "product_list": [
- {
- "service_id": "44b3148a-0dc8-4262-81d8-c762559f0d74",
- "brand_id": "8c42b2d4-6d2c-4188-931a-240d2f94183f",
- "product_id": "814298ea-fd9f-4741-8134-f5fef5614714",
- "category_id": "f6fc99db-96d2-4158-a29f-663d9a2f6199",
- "product_name": "Gift Cards > Apple iTunes > JP",
- "service_name": "Gift Cards",
- "brand_name": "Apple iTunes",
- "region_name": "JP"
}, - {
- "service_id": "44b3148a-0dc8-4262-81d8-c762559f0d74",
- "brand_id": "8c42b2d4-6d2c-4188-931a-240d2f94183f",
- "product_id": "3c0d0298-408d-43b4-b069-8a56d9d5ac08",
- "category_id": "f6fc99db-96d2-4158-a29f-663d9a2f6199",
- "product_name": "Gift Cards > Apple iTunes > RU",
- "service_name": "Gift Cards",
- "brand_name": "Apple iTunes",
- "region_name": "RU"
}, - {
- "service_id": "44b3148a-0dc8-4262-81d8-c762559f0d74",
- "brand_id": "8c42b2d4-6d2c-4188-931a-240d2f94183f",
- "product_id": "4a610301-4e3a-4cc7-b242-35ebc1a521a7",
- "category_id": "f6fc99db-96d2-4158-a29f-663d9a2f6199",
- "product_name": "Gift Cards > Apple iTunes > US",
- "service_name": "Gift Cards",
- "brand_name": "Apple iTunes",
- "region_name": "US"
}
]
}
}
Get attributes of a product.
product_id required | string <uuid> Example: 4a610301-4e3a-4cc7-b242-35ebc1a521a7 The unique identifier of a product. |
{- "request_id": "e48919cd-12be-4005-ba09-fe4004f08925",
- "code": 20000001,
- "message": "",
- "warning": "",
- "payload": {
- "product_id": "c9bf2323-fa8d-4c88-acc8-87d2ced62b72",
- "attribute_group_list": [
- {
- "attribute_group_id": "30258ae5-3143-441d-95a4-cd6b2d69b503",
- "attribute_group_name": "Denomination",
- "input_field": "dropdown",
- "is_required": true,
- "attribute_list": [
- {
- "attribute_id": "e3c21690-d2c3-436e-9137-c554e1938ee8",
- "attribute_name": "Karma Koin USD100"
}, - {
- "attribute_id": "a4591035-5956-43b2-aabc-f6b9a7ce5bcf",
- "attribute_name": "Karma Koin USD50"
}
]
}
], - "delivery_method_list": [
- {
- "delivery_code": "direct_top_up",
- "delivery_method_id": "k8ej93u6-5956-43b2-aabc-f6b9a7ce5bcf",
- "delivery_method_name": "Direct Top Up",
- "attribute_group_list": [
- {
- "attribute_group_id": "10533bad",
- "attribute_group_name": "Account ID",
- "attribute_key": "delivery_info_1",
- "input_field": "text",
- "input_settings": {
- "max_length": "20",
- "min_length": 1
}, - "is_required": true,
- "attribute_list": [ ]
}, - {
- "attribute_group_id": "0283e116",
- "attribute_group_name": "Server",
- "attribute_key": "delivery_info_2",
- "input_field": "dropdown",
- "input_settings": {
- "is_searchable": true
}, - "is_required": true,
- "attribute_list": [
- {
- "attribute_id": "e3c21690-d2c3-436e-9137-c554e1938ee8",
- "attribute_name": "MiskaTown",
- "sub_attribute_list": [ ]
}, - {
- "attribute_id": "a4591035-5956-43b2-aabc-f6b9a7ce5bcf",
- "attribute_name": "SandCastle",
- "sub_attribute_list": [ ]
}
]
}, - {
- "attribute_group_id": "10533bad",
- "attribute_group_name": "Login",
- "attribute_key": "delivery_info_3",
- "input_field": "text",
- "input_settings": {
- "max_length": "20",
- "min_length": 1
}, - "is_required": true,
- "attribute_list": [ ]
}
]
}
], - "additional_info_list": [
- {
- "attribute_group_id": "10533bad",
- "attribute_group_name": "Special note to seller",
- "attribute_key": "additional_info_1",
- "input_field": "textarea",
- "input_settings": {
- "max_length": "128",
- "min_length": 1
}, - "is_required": true,
- "attribute_list": [ ]
}
]
}
}
Create a new offer.
product_id required | string <uuid> The unique identifier of the product. |
title | string The title of an offer. Not applicable for Giftcard & Top Up |
description | string Description of an offer. Not applicable for Giftcard |
min_qty required | integer >= 1 Minimum purchase quantity. |