G2A.COM Developers API

API for purchasing products on g2a.com

Orders

Orders - Add an order

https://sandboxapi.g2a.com/v1/order
curl -i -XPOST https://sandboxapi.g2a.com/v1/order \
-H "Authorization: qdaiciDiyMaTjxMt, 74026b3dc2c6db6a30a73e71cdb138b1e1b5eb7a97ced46689e2d28db1050875" \
-H 'Content-Type: application/json' \
-d '{"product_id": "10000027819004", "max_price": 45.0}'

Header

Field Type Description
Authorization String

Authorization header in format apiHash, apiKey e.g. qdaiciDiyMaTjxMt, 74026b3dc2c6db6a30a73e71cdb138b1e1b5eb7a97ced46689e2d28db1050875. You can generate it with echo "<?php echo 'HASH, ' . hash('sha256', 'HASHEMAILSECRET'). PHP_EOL;" |php

Content-type String

application/json

Parameter

Field Type Description
product_id

String

Id of an product eg. 10000027819004

currency optional

String

Order currency, default EUR

max_price optional

Number

Max price in EUR if API should select auction for merchant eg. 10.50. If 0, then no limit is applied. Not allowed if auction_id is present

min_rating optional

Number

Min user's rating [0.0 - 1.0] if API should select auction for merchant eg. 0.9. If 0, then no limit is applied. Not allowed if auction_id is present

Success 200

Field Type Description
order_id

String

Id of an order eg. 80201019921771

price

Number

Order price

currency

String

Order currency

HTTP/1.1 200 OK
{
    "order_id": "80201019921771",
    "price": 12.55,
    "currency": "EUR"
}
HTTP/1.1 429 Too Many Requests
{
    "status": "ERROR",
    "message": "Too many requests",
    "code": "BR03"
}
HTTP/1.1 403 Bad Request
{
    "status": "ERROR",
    "message": "No Authorization header",
    "code": "AUTH01"
}
HTTP/1.1 401 Unauthorized
{
    "status": "ERROR",
    "message": "Authorization failed",
    "code": "AUTH02"
}
HTTP/1.1 400 Bad Request
{
    "status": "ERROR",
    "message": "Invalid JSON",
    "code": "BR01"
}
HTTP/1.1 400 Bad Request
{
    "status": "ERROR",
    "message": "Invalid JSON data",
    "code": "BR02"
}
HTTP/1.1 401 Unauthorized
{
    "status": "ERROR",
    "message": "Merchant not found"
    "code": "AUTH02"
}

Orders - Get Order Details

https://sandboxapi.g2a.com/v1/order/details/:id
curl -i https://sandboxapi.g2a.com/v1/order/details/80201019921771 \
 -H "Authorization: qdaiciDiyMaTjxMt, 74026b3dc2c6db6a30a73e71cdb138b1e1b5eb7a97ced46689e2d28db1050875"

Header

Field Type Description
Authorization String

Authorization header in format apiHash, apiKey e.g. qdaiciDiyMaTjxMt, 74026b3dc2c6db6a30a73e71cdb138b1e1b5eb7a97ced46689e2d28db1050875. You can generate it with echo "<?php echo 'HASH, ' . hash('sha256', 'HASHEMAILSECRET'). PHP_EOL;" |php

Parameter

Field Type Description
id

Number

Id of an order eg. 80201019921771

Success 200

Field Type Description
status

String

Order status: complete, pending

price

Number

Order price

currency

String

Order currency

HTTP/1.1 200 OK
{
    "status": "complete",
    "price": 12.55,
    "currency": "PLN"
}
HTTP/1.1 200 OK
{
    "status": "pending"
}
HTTP/1.1 403 Bad Request
{
    "status": "ERROR",
    "message": "No Authorization header",
    "code": "AUTH01"
}
HTTP/1.1 401 Unauthorized
{
    "status": "ERROR",
    "message": "Authorization failed",
    "code": "AUTH02"
}
HTTP/1.1 404 Not Found
{
    "status": "ERROR",
    "message": "Order not found"
}
HTTP/1.1 400 Bad Request
{
    "status": "ERROR",
    "message": "Order ID is not valid"
}

Orders - Get Order Key

https://sandboxapi.g2a.com/v1/order/key/:id
curl -i https://sandboxapi.g2a.com/v1/order/key/80201019921771 \
 -H "Authorization: qdaiciDiyMaTjxMt, 74026b3dc2c6db6a30a73e71cdb138b1e1b5eb7a97ced46689e2d28db1050875"

Header

Field Type Description
Authorization String

Authorization header in format apiHash, apiKey e.g. qdaiciDiyMaTjxMt, 74026b3dc2c6db6a30a73e71cdb138b1e1b5eb7a97ced46689e2d28db1050875. You can generate it with echo "<?php echo 'HASH, ' . hash('sha256', 'HASHEMAILSECRET'). PHP_EOL;" |php

HTTP/1.1 200 OK
{
    "key": "QWEEWE-SDASDD-SDSDSD"
}
HTTP/1.1 405 Bad Request
{
    "status": "ERROR",
    "message": "Order key has been downloaded already",
    "code": "ORD04"
}
HTTP/1.1 402 Payment Required
{
    "status": "ERROR",
    "message": "Order key has been downloaded already",
    "code": "ORD05"
}
HTTP/1.1 400 Bad Request
{
    "status": "ERROR",
    "message": "Order is not processed yet",
    "code": "ORD06"
}
HTTP/1.1 403 Bad Request
{
    "status": "ERROR",
    "message": "No Authorization header",
    "code": "AUTH01"
}
HTTP/1.1 401 Unauthorized
{
    "status": "ERROR",
    "message": "Authorization failed",
    "code": "AUTH02"
}
HTTP/1.1 400 Bad Request
{
    "status": "ERROR",
    "message": "Invalid order id",
    "code": "ORD01"
}
HTTP/1.1 404 Not Found
{
    "status": "ERROR",
    "message": "Order not found",
    "code": "ORD02"
}

Orders - Pay for an order

https://sandboxapi.g2a.com/v1/order/pay/:id
curl -i -XPUT https://sandboxapi.g2a.com/v1/order/pay/:id \
 -H "Authorization: qdaiciDiyMaTjxMt, 74026b3dc2c6db6a30a73e71cdb138b1e1b5eb7a97ced46689e2d28db1050875" \
-H 'Content-Type: application/json'

Header

Field Type Description
Authorization String

Authorization header in format apiHash, apiKey e.g. qdaiciDiyMaTjxMt, 74026b3dc2c6db6a30a73e71cdb138b1e1b5eb7a97ced46689e2d28db1050875. You can generate it with echo "<?php echo 'HASH, ' . hash('sha256', 'HASHEMAILSECRET'). PHP_EOL;" |php

Content-type String

application/json

Parameter

Field Type Description
id

Number

Id of an order eg. 80201019921771

Success 200

Field Type Description
status

Boolean

Status of transaction

transaction_id

Boolean

transaction from G2A PAY

HTTP/1.1 200 OK
{
    "status": true
}
HTTP/1.1 403 Forbidden
{
    "status": "ERROR",
    "message": "Unable to process payment - it is not ready yet. Try again later",
    "code": "ORD03"
}
HTTP/1.1 403 Bad Request
{
    "status": "ERROR",
    "message": "No Authorization header",
    "code": "AUTH01"
}
HTTP/1.1 401 Unauthorized
{
    "status": "ERROR",
    "message": "Authorization failed",
    "code": "AUTH02"
}
HTTP/1.1 404 Not Found
{
    "status": "ERROR",
    "message": "Order not found",
    "code": "ORD02"
}
HTTP/1.1 400 Bad Request
{
    "status": "ERROR",
    "message": "Invalid order id",
    "code": "ORD01"
}

Products

Products - Get Products

https://sandboxapi.g2a.com/v1/products
curl -i -XGET "https://sandboxapi.g2a.com/v1/products?page=1&minQty=5" \
 -H "Authorization: qdaiciDiyMaTjxMt, 74026b3dc2c6db6a30a73e71cdb138b1e1b5eb7a97ced46689e2d28db1050875"
<?php
try {
    $client = \G2A\Api\Client($authorizationHeader);
    $products = $client->getProducts($page);
} catch (\Exception $e) {
    // ...
}

Header

Field Type Description
Authorization String

Authorization header in format apiHash, apiKey e.g. qdaiciDiyMaTjxMt, 74026b3dc2c6db6a30a73e71cdb138b1e1b5eb7a97ced46689e2d28db1050875. You can generate it with echo "<?php echo 'HASH, ' . hash('sha256', 'HASHEMAILSECRET'). PHP_EOL;" |php

Parameter

Field Type Description
page optional

Number

Number of page to get. Page size is fixed 20. Default value: 1, allowed values: 1-100

id optional

String

Id of product

minQty optional

Number

Minimum product quantity available to buy

minPriceFrom optional

Number

Minimal product's price start

minPriceTo optional

Number

Minimal product's price end

Success 200

Field Type Description
page

Number

Number of page

docs

Object[]

Products array

  id

String

ID of product

  name

String

Name of product

  type

String

Type of product, currently it is always key

  slug

String

Slug of product

  qty

Number

Qty of product available to buy

  minPrice

Number

Float minimal price of product

  thumbnail

String

Url to image

  smallImage

String

Url to image

HTTP/1.1 200 OK
{
    "page": 1,
    "docs": [
         {
             "id": "10000083595001",
             "name": "Middle-earth: Shadow of War Standard Edition Steam Key GLOBAL",
             "type": "key",
             "slug": "/middle-earth-shadow-of-war-standard-edition-steam-key-global-i10000034823002",
             "qty": 9,
             "minPrice": 30.00,
             "thumbnail": "https://images.g2a.com/images/58x58/0x1x1/b187e036fea3/59ce681aae653a840571a334",
             "smallImage": "https://images.g2a.com/images/230x336/0x1x1/2bdbea2e846c/59ce681aae653a840571a334",
         },
         ...
     ]
 }
HTTP/1.1 400 Bad Request
{
    "status": "ERROR",
    "message": "Invalid product id",
    "code": "PR01"
}
HTTP/1.1 400 Bad Request
{
    "status": "ERROR",
    "message": "Page param out of range | Qty param out of range | Min price from param out of range | Min price to param out of range",
    "code": "PR02"
}
HTTP/1.1 500 Internal Server Error
{
    "status": "ERROR",
    "message": "Internal error",
    "code": "PR03|PR04|IN01"
}
HTTP/1.1 400 Bad Request
{
    "status": "ERROR",
    "message": "Invalid JSON data",
    "code": "BR02"
}

Response error codes

Error code HTTP code Description
AUTH01 400 No Authorization header
AUTH02 401 Wrong Authorization header
AUTH03 401 Unallowed IP address
AUTH04 401 No privileges to this method
AUTH05 401 Merchant not found
BR01 400 Invalid JSON
BR02 400 Invalid JSON data
BR03 429 Too many requests
ORD01 400 Invalid order id
ORD02 404 Order not found
ORD03 405 Order not paid
ORD04 405 Order key already downloaded
ORD05 402 Problem with payment
ORD06 400 Order is not processed yet
PR01 400 Invalid product id
PR02 400 Wrong arguments
PR03 500 Internal error
PR04 500 Internal error
IN01 500 Internal error
Generated with apidoc 0.13.1 - 2017-11-28T15:59:50.455Z