PHPackages                             m4aax16/kinguin-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. m4aax16/kinguin-laravel

ActiveLibrary[API Development](/categories/api)

m4aax16/kinguin-laravel
=======================

Laravel wrapper package for the Kinguin API

1.0.3(5y ago)193MITPHP

Since Aug 26Pushed 2y ago1 watchersCompare

[ Source](https://github.com/m4aax16/kinguin-laravel)[ Packagist](https://packagist.org/packages/m4aax16/kinguin-laravel)[ RSS](/packages/m4aax16-kinguin-laravel/feed)WikiDiscussions master Synced today

READMEChangelog (4)DependenciesVersions (11)Used By (0)

m4aax16/kinguin
===============

[](#m4aax16kinguin)

Description
-----------

[](#description)

##### m4aax16/kinguin-laravel is a unofficial Kinguin api wrapper for Laravel

[](#m4aax16kinguin-laravel-is-a-unofficial-kinguin-api-wrapper-for-laravel)

Installation
------------

[](#installation)

`composer require m4aax16/kinguin-laravel "^1.2-alpha"`

Functions
---------

[](#functions)

```
Product:
	- GET products per page
	- GET count of pages
	- GET single product

Region:
	- GET all regions
	- GET one region by Id

User:
	- GET user balance

Order:
	- Place order
	- Dispatch order
	- Get order keys
Handle Exceptions

```

Usage
-----

[](#usage)

### Initalize the objects

[](#initalize-the-objects)

```
use m4aax16\kinguin\Client;
use m4aax16\kinguin\Product;
use m4aax16\kinguin\Order;
use m4aax16\kinguin\User;
use m4aax16\kinguin\Region;
```

Client
------

[](#client)

### Client initialization

[](#client-initialization)

```
 $kinguinClient = new Client("YOUR-API-KEY-HERE");
```

Product
-------

[](#product)

### GET Products by page number

[](#get-products-by-page-number)

```
//This function will fetch 25 products per Page, it's a default value by Kinguin

 $page = 1;
 $products = Product::getPage($page); // $page is NOT required, default is $page = 1

 return $products;
```

###### This function will output a JSON object of products

[](#this-function-will-output-a-json-object-of-products)

#### Accessing the fetched result

[](#accessing-the-fetched-result)

```
foreach($products['results'] as $product)
{
	$product['kinguinId']; //Accessing product attribute Id => Output : INT
	$product['name']; //Accessing product attribute name => Output : STRING

	//accessing other objects of product
	//Example : Screenshots
	$screenshots = $product['screenshots'];

	foreach($screenshots as $screenshot)
	{
		$screenshot['url_original'];
	}
}
```

### GET count of pages

[](#get-count-of-pages)

```
$itemsPerPage = 100; // Max. products per page is 100
$pageCount = Product::getPagesCount($itemsPerPage); // $itemsPerPage is NOT required, default $itemsPerPage = 25
```

### GET a single product

[](#get-a-single-product)

```
$productId = 5; //set the kinguinId of product

$product = Product::getProduct($productId); //returns detailed information about this product
```

Region
------

[](#region)

### GET all regions

[](#get-all-regions)

##### Note : The output isn't a call to the Kinguin API Endpoint.

[](#note--the-output-isnt-a-call-to-the-kinguin-api-endpoint)

##### All regions are saved as a array at `Region::class`

[](#all-regions-are-saved-as-a-array-at-regionclass)

```
Region::getRegions(); //returns all regions, the array key is the id of the region
```

#### Accessing the Id and name

[](#accessing-the-id-and-name)

```
$regions = Region::getRegions();

foreach($regions as $regionId => $value)
{
	echo $regionId; //region id
	echo " ";
	echo $value; //region name
	echo "";
}
```

### GET Region by ID

[](#get-region-by-id)

```
$regionId = 1; // Id 1 is "Europe"
$region = Region::getRegionById($regionId);

echo $region; //Output will be a STRING
```

User
----

[](#user)

### GET User Balance

[](#get-user-balance)

```
$balance = User::getBalance(); // Output is a FLOAT, Example: 20439.99
```

Order
-----

[](#order)

##### Note : The Kinguin-Endpoint supports multiple items on one order

[](#note--the-kinguin-endpoint-supports-multiple-items-on-one-order)

##### But this package doesn't support multiple items per order

[](#but-this-package-doesnt-support-multiple-items-per-order)

### Place order

[](#place-order)

```
$productId = 195; // ProductId is Warhammer for Steam
$qty = 1;
$price = 0.59;

//All parameter all required
$order = Order::placeOrder($productId,$qty,$price,$couponCode*);  // returns a json with order "orderId: 26983294"
								  // $couponCode is a optional parameter
```

### Dispatch order

[](#dispatch-order)

```
$dispatch = Order::dispatchOrder($orderId);    //returns:  "dispatchId:	19036724"
$dispatchId = $dispatch['dispatchId'];
```

### GET ordered keys

[](#get-ordered-keys)

```
$keys = Order::getOrderKeys($dispatchId);

/* Example Output :
        0:
        serial	"SOME-ACTIVATION-KEY"
        type	"text/plain" //Key types are text or image
        name	"Warhammer 40,000: Space Marine Steam CD Key"
        kinguinId	195
*/
```

Note : To save your own and Kinguin server resources, it's highly recommend subscribing to order postback. It's also much more efficient. Replace your storeId if you want to use this url : [https://www.kinguin.net/integration/dashboard/stores/{storeId}/postback](https://www.kinguin.net/integration/dashboard/stores/%7BstoreId%7D/postback)

As soon as the Post Back notification arrives, this function can be used :

```
$kgOrderId = "9XQ3FFRQKVL";
$keys = Order::getOrderKeyById($kgOrderId);

/* Example Output :
	0
	serial	"Real_1942  XYYG8-4GBCC-ILMFM"
	type	"text/plain"
	name	"Real 1942 Steam CD Key"
	kinguinId	57083
	productId	"5c9b787a2539a4e8f184354a"
	offerId	"5fa56a6d9c2506000196e12a"
*/
```

### Handle Exceptions

[](#handle-exceptions)

Note : It works on all methods except on Region::class

```

   $productId = 0; //set the kinguinId of product

    $product = Product::getProduct($productId); //returns detailed information about this product

    //Check the method getStatusCode exists
    if(method_exists($product,'getStatusCode')){
      //If the status code is higher than 200
      if($product->getStatusCode() > 200){

        //This method return the full error message inline
        $errFull = $product->getData()->error;

        //This method return only the Kinguin Error Code
        $errCode = $product->getData()->response->code;

        //This method return the error message
        $errMessage = $product->getData()->response->message;

        echo "Full Error : ".$errFull."";
        echo "Error Code : ".$errCode."";
        echo "Error Message : ".$errMessage."";

        /* Example ouputs :
                1. If the client is not authorized =>

                Full Error : Client error: `GET https://gateway.kinguin.net/esa/api/v1/products/0` resulted in a `401 Unauthorized` response: {"code":2401,"message":"Full authentication is required to access this resource."}
                Error Code : 2401
                Error Message : Full authentication is required to access this resource.

                2. If the client is authorized but something goes wrong. For example the requested product does not exist =>

                Full Error : Client error: `GET https://gateway.kinguin.net/esa/api/v1/products/0` resulted in a `404 Not Found` response: {"code":3404,"message":"Product not found"}
                Error Code : 3404
                Error Message : Product not found
        */

      }
    }
    else{
       //Do something clever with the requested product
       return $product;

    }
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~23 days

Recently: every ~29 days

Total

10

Last Release

1876d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/50498034?v=4)[m4aax16](/maintainers/m4aax16)[@m4aax16](https://github.com/m4aax16)

---

Top Contributors

[![m4aax16](https://avatars.githubusercontent.com/u/50498034?v=4)](https://github.com/m4aax16 "m4aax16 (10 commits)")

### Embed Badge

![Health badge](/badges/m4aax16-kinguin-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/m4aax16-kinguin-laravel/health.svg)](https://phpackages.com/packages/m4aax16-kinguin-laravel)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
