添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

G2G OpenAPI Beta ( 1.0.0 )

  1. Login to https://www.g2g.com/ .

  2. On top right of the menu bar, click on your avatar, select API Integration.

  3. You can start to send requests to G2G OpenAPI by generating the g2g-signature and adding it to the HTTP request headers.
Javascript
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.

Understand delivery attributes for Top Up

  • Buyer has to fill in Order Information when place order.
  • When you call Get Attributes API, delivery_method_list will be returned in the response.
  • Under delivery_method_list , lookup attribute_group_list .
  • From the Order Information sample image, you will get below response:
  • "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
  • The 1st attribute is a text field, which is refers to User ID input and the attribute_key is delivery_info_1 .
  • The 2nd attribute is a dropdown field, which is refers to Server input and the attribute_key is delivery_info_2 .
  • You are adviced to use attribute_key for integration instead of attribute_group_id or attribute_group_name .
  • When order is placed, you will receive webhook 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" : ""
  • From the sample payload above,
  • 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.
  • 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.

    Please visit https://github.com/g2g-official/open-api-sample to download the sample postman collection as a reference to kickstart your API integration.

    Product

    Version Descritpion Deprecated. We encourage to use the latest version of G2G OpenAPI. Current version of G2G OpenAPI.
    language
    string
    Default: "en"
    Enum : "en" "zh-CN" "id" "zh-TW"

    Language

    Get Products

    query Parameters
    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.

    Response samples

  • } ,
  • ]
    } ,
  • }
    ]
    }
    ] ,
  • } ] } }

    Create Offer

    Request Body schema: application/json
    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.

    api_qty
    required
    int >= 0

    The quantity of stock to sell in G2G via OpenAPI.

    low_stock_alert_qty
    required
    int >= 0

    When reach low_stock_alert_qty, will receive offer.low_stock webhook

    required
    Array of objects [ items ]
    currency
    required
    string

    Currency ISO code. Reference

    unit_price
    required
    number < double > > 0

    Unit price of an offer item.

    Array of objects [ 1 .. 3 ] items [ items ]
    Array of objects [ items ]

    Other currency pricing that you may have for an offer.

    Array of objects [ items ]

    The wholesale detail setting for other currency that you may have for an offer.

    object

    Setting to allow or disallowed buyer from specific country to purchase the offer. Default global, no country restriction

    delivery_method_ids
    Array of strings < uuid >

    A list of uid string that respresent delivery method of an offer. Does not required for Gift Card offer

    Response samples

  • }
    }

    Response samples

  • }
    }

    Update Offer

    path Parameters
    offer_id
    required
    string
    Example: G1650341633714BW

    The unique identifier of an offer.

    Request Body schema: application/json
    min_qty
    integer >= 1

    Minimum purchase quantity.

    api_qty
    int >= 0

    The quantity of stock to sell in G2G via OpenAPI.

    low_stock_alert_qty
    int >= 0

    When reach low_stock_alert_qty, will receive offer.low_stock webhook

    Array of objects [ items ]
    currency
    string

    Currency ISO code. Reference

    unit_price
    number < double > > 0

    Unit price of an offer item.

    Array of objects [ 1 .. 3 ] items [ items ]
    Array of objects [ items ]

    Other currency pricing that you may have for an offer.

    Array of objects [ items ]

    The wholesale detail setting for other currency that you may have for an offer.

    object

    Setting to allow or disallowed buyer from specific country to purchase the offer. Default global, no country restriction

    delivery_method_ids
    Array of strings < uuid >

    A list of uid string that respresent delivery method of an offer. Does not required for Gift Card offer

    Response samples

  • }
    }

    Response samples

    } ,
  • }
    }
    ] ,
  • }
    }

    Get Delivery Status

    path Parameters
    order_id
    required
    string
    Example: 1654240349966TEKP-1

    The unique identifier of an order.

    delivery_id
    required
    string
    Example: D1650341633714

    The unique identifier of delivery.

    Response samples

    Patch Delivery

    path Parameters
    order_id
    required
    string
    Example: 1654240349966TEKP-1

    The unique identifier of an order.

    delivery_id
    required
    string
    Example: D1650341633714

    The unique identifier of delivery.

    Request Body schema: application/json
    delivered_qty
    required
    integer

    Total quantity of item delivered by seller for this order.

    delivery_issue
    string
    Enum : "incorrect_delivery_detail" "insufficient_stock" "others"

    Issue encountered when unable to fulfill the requested deliver quantity.

    delivered_at
    required
    integer

    Timestamp in milliseconds when the code is delivered for this delivery.

    reference_id
    string

    A reference identifier for this delivery.

    Search Webhook Logs

    Request Body schema: application/json
    required
    object

    The search and filter query settings.

    limit
    integer

    Specifies the number of messages to return per page.

    sort_order
    string
    Enum : "asc" "desc"

    The ordering of the records.

    after
    string

    Marks the starting point of the search results to retrieve in the result set.

    Response samples

  • } ,
  • } ,
  • } ,
  • }
    ] ,
  • }
    }

    Get Attributes

    path Parameters
    product_id
    required
    string < uuid >
    Example: 4a610301-4e3a-4cc7-b242-35ebc1a521a7

    The unique identifier of a product.

    }

    Create Offer

    Request Body schema: application/json
    product_id
    required
    string < uuid >

    The unique identifier of the product.

    min_qty
    required
    integer >= 1

    Minimum purchase quantity.

    api_qty
    required
    int >= 0

    The quantity of stock to sell in G2G via OpenAPI.

    low_stock_alert_qty
    required
    int >= 0

    When reach low_stock_alert_qty, will receive offer.low_stock webhook

    required
    Array of objects [ items ]
    currency
    required
    string

    Currency ISO code. Reference

    unit_price
    required
    number < double > > 0

    Unit price of an offer item.

    Array of objects [ 1 .. 3 ] items [ items ]
    object

    Setting to allow or disallowed buyer from specific country to purchase the offer. Default global, no country restriction

    Response samples

    Update Offer

    path Parameters
    offer_id
    required
    string
    Example: G1650341633714BW

    The unique identifier of an offer.

    Request Body schema: application/json
    min_qty
    integer >= 1

    Minimum purchase quantity.

    api_qty
    int >= 0

    The quantity of stock to sell in G2G via OpenAPI.

    low_stock_alert_qty
    int >= 0

    When reach low_stock_alert_qty, will receive offer.low_stock webhook

    Array of objects [ items ]
    currency
    string

    Currency ISO code. Reference

    unit_price
    number < double > > 0

    Unit price of an offer item.

    Array of objects [ 1 .. 3 ] items [ items ]
    object

    Setting to allow or disallowed buyer from specific country to purchase the offer. Default global, no country restriction

    Response samples

    Get Delivery Status

    path Parameters
    order_id
    required
    string
    Example: 1654240349966TEKP-1

    The unique identifier of an order.

    delivery_id
    required
    string
    Example: D1650341633714

    The unique identifier of delivery.

    Response samples

    Search Webhook Logs

    Request Body schema: application/json
    required
    object

    The search and filter query settings.

    limit
    integer

    Specifies the number of messages to return per page.

    sort_order
    string
    Enum : "asc" "desc"

    The ordering of the records.

    after
    string

    Marks the starting point of the search results to retrieve in the result set.

    Response samples

  • } ,
  • } ,
  • } ,
  • }
    ] ,
  • }
    }
    1. Login to https://www.g2g.com/ .

    2. On top right of the menu bar, click on your avatar, select API Integration.

      Developer contact G2G will send an alert email to this contact when your system does not respond upon receiving the webhook message. Callback URL G2G will send the webhook message to this URL. The secret token is mandatory. G2G will use it to create a hash signature that is passed along in the g2g-signature. You can generate secret token on your own or use the "Generate random secret token" provided by G2G. Please copy the secret key and keep it securely. Events You must fill in the callback URL before configuring webhook events. G2G will send webhook message to your system for the events you selected. By selecting all events, all existing events and any future incoming events will also be selected.

    Orders

    The webhooks for different stage of orders

    Event Trigger
    order.created Buyer placed the order but not yet paid. order.confirmed Buyer has made the payment and payment is confirmed. order.delivery_status The result of your delivery request, it could be fully delivered / partial delivered / unfulfilled
    Note : If you are not subscribed to this event, you can use Get Delivery Status API to check your delivery status.
    order.api_delivery Seller is ready to deliver codes via API.
    Note : Seller should start prepare deliver the codes when receive this event. Please refer to Deliver Code API to deliver codes
    order.cancelled The payment of the order is unsuccessful and cancelled. order.completed Buyer has confirmed order received. order.rollback_cancelled A cancelled order is moved back to unpaid. order.rollback_completed Buyer reported issue after confirmed receipt. order.case_opened Buyer reported an issue of the order.
    Note : Seller should investigate the reported case from G2G resolution center when receive this event.

    Offers

    The webhooks for offer

    Event Trigger offer.low_stock Seller's offer is below the low stock threshold.

    order.created Webhook

    header Parameters
    g2g-signature
    string

    The signed signature for webhook payload verification

    g2g-timestamp
    string

    The timestamp when post the webhook

    Request Body schema: application/json
    id
    string

    The event ID of the request.

    event_happened_at
    integer

    Timestamp in milliseconds when the event occured.

    event_type
    string
    Value : "order.created"

    The type of the webhook event.

    object

    Request payload.

    order.delivery_status Webhook

    header Parameters
    g2g-signature
    string

    The signed signature for webhook payload verification

    g2g-timestamp
    string

    The timestamp when post the webhook

    Request Body schema: application/json
    id
    string

    The event ID of the request.

    event_happened_at
    integer

    Timestamp in milliseconds when the event occured.

    event_type
    string
    Value : "order.delivery_status"

    The type of the webhook event.

    object

    Request payload.

    Responses

    Request samples

    Content type
    application/json
    Example

    order.api_delivery Webhook

    header Parameters
    g2g-signature
    string

    The signed signature for webhook payload verification

    g2g-timestamp
    string

    The timestamp when post the webhook

    Request Body schema: application/json
    id
    string

    The event ID of the request.

    event_happened_at
    integer

    Timestamp in milliseconds when the event occured.

    event_type
    string
    Value : "order.api_delivery"

    The type of the webhook event.

    object

    Request payload.

    Responses

    Request samples

    Content type
    application/json
    Example }

    order.refunded Webhook

    header Parameters
    g2g-signature
    string

    The signed signature for webhook payload verification

    g2g-timestamp
    string

    The timestamp when post the webhook

    Request Body schema: application/json
    id
    string

    The event ID of the request.

    event_happened_at
    integer

    Timestamp in milliseconds when the event occured.

    event_type
    string
    Value : "order.refunded"

    The type of the webhook event.

    object

    Request payload.

    order.case_opened Webhook

    header Parameters
    g2g-signature
    string

    The signed signature for webhook payload verification

    g2g-timestamp
    string

    The timestamp when post the webhook

    Request Body schema: application/json
    id
    string

    The event ID of the request.

    event_happened_at
    integer

    Timestamp in milliseconds when the event occured.

    event_type
    string
    Value : "order.case_opened"

    The type of the webhook event.

    object

    Request payload.

    Responses

    Request samples

    Content type
    application/json
    }

    Feature

  • Added order.refunded event webhook that will be send to seller each time seller's order being refunded. To ensure deliverability please make sure order.refunded webhook is selected in API Integration
  •