PHP code example of dvdx1995 / cs-float-php-bundle

1. Go to this page and download the library: Download dvdx1995/cs-float-php-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dvdx1995 / cs-float-php-bundle example snippets


use CsFloatPhpBundle\Service\CsFloatApiService;

$api = new CsFloatApiService('YOUR_API_KEY');

use CsFloatPhpBundle\Service\CsFloatListingApiService;

$api = new CsFloatListingApiService('YOUR_API_KEY');

use CsFloatPhpBundle\Service\CsFloatTradesApiService;

$api = new CsFloatTradesApiService('YOUR_API_KEY');

use CsFloatPhpBundle\Request\AbstractRequest;
use CsFloatPhpBundle\Helper\RequestMethodConst;

class YourCustomRequest extends AbstractRequest
{
    private $param;

    public function __construct($param)
    {
        $this->param = $param;
    }

    public function getMethod(): string
    {
        return RequestMethodConst::POST; // or GET, DELETE, PATCH
    }

    public function getUrl(): string
    {
        return 'endpoint/path';
    }

    public function getParams(): array
    {
        return [
            'query' => ['key' => 'value'],       // for GET requests
            // or
            'form_params' => ['key' => 'value'], // for POST/PATCH requests
            // or
            'body' => json_encode(['key' => 'value']),
        ];
    }
}

$api = new \CsFloatPhpBundle\Service\CsFloatApiService('YOUR_API_KEY');
$response = $api->call(new YourCustomRequest('value'));

use CsFloatPhpBundle\Service\CsFloatListingApiService;

$api = new CsFloatListingApiService('YOUR_API_KEY');
$inventory = $api->getInventory();

use CsFloatPhpBundle\Service\CsFloatListingApiService;

$api = new CsFloatListingApiService('YOUR_API_KEY');
$listings = $api->getListings(
    limit: 10,
    minPrice: 100,
    maxPrice: 500,
    category: 2
);

use CsFloatPhpBundle\Service\CsFloatListingApiService;

$api = new \CsFloatPhpBundle\Service\CsFloatApiService('YOUR_API_KEY');
$result = $api->createBuyNowListing(assetId: 12345, price: 150); // $1.50

use CsFloatPhpBundle\Service\CsFloatTradesApiService;

$api = new CsFloatTradesApiService('YOUR_API_KEY');
$result = $api->bulkAcceptTrades(['947100664322983730', '123456789']);

use CsFloatPhpBundle\Service\CsFloatListingApiService;

$api = new CsFloatListingApiService('YOUR_API_KEY');
$sales = $api->getItemLatestSales('AK-47 | Redline (Field-Tested)', 632);