๐ Communication Protocol
Protocol:
HTTP POSTMethod:
RESTful JSON APIContent-Type Header:
application/jsonTimestamp Format:
YYYY-MM-DD HH:mm:ssExample:
2024-04-25 19:35:33
Essential credentials required to integrate: API Username (apiusername), API Password (apipass), REST API URL, Operator ID
๐งพ POST Body Format
The POST body must contain a valid JSON object with the parameters required for the requested command. EG: {"command": "getListGames", "apiusername": "testAdmin1", "apipass": "testAdminPass1"}
Use json_encode($request_data) in PHP or the equivalent in other languages.
Sample code for sending a POST command via CURL:
<?php
$cws_api = [
'apiusername' => 'rgs_demo_testXXXXXX',//replace with your given api username
'apipass' => 'rgs_demo_passXXXXXX',//replace with your given api password
'restapi_url' => 'https://************.casino/restapi_url.php',//replace with our given REST API URL
];
$request_data = [
'command' => 'getListGames', // command used for getting list of games
'apiusername' => $cws_api['apiusername'],
'apipass' => $cws_api['apipass'],
];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $cws_api['restapi_url'],//replace with REST API URL
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($request_data, JSON_UNESCAPED_SLASHES),
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Accept: application/json',
],
]);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$curlErr = curl_error($curl);
curl_close($curl);
// Handle transport errors
if ($response === false) {
die("cURL error: $curlErr\n");
// Show HTTP status for quick debugging
echo "HTTP $httpCode\n";
}else{
//process the response
//print_r($response);
}
//DISCLAIMER: the above sample code is written by our team and tested to work
//DISCLAIMER: The code samples below were AI-generated based on our original PHP implementation. Please review and test thoroughly before use. We provide these samples for guidance only and assume no responsibility for their implementation in production environments.
// TypeScript (also works as JavaScript by removing type annotations)
interface CWSApiConfig {
apiusername: string;
apipass: string;
}
interface GetListGamesRequest {
command: string;
apiusername: string;
apipass: string;
}
const cwsApi: CWSApiConfig = {
apiusername: 'rgs_demo_testXXXXXX', // replace with your api username
apipass: 'rgs_demo_passXXXXXX', // replace with your api password
};
const requestData: GetListGamesRequest = {
command: 'getListGames', // command used for getting list of games
apiusername: cwsApi.apiusername,
apipass: cwsApi.apipass,
};
async function callCWSApi() {
try {
const response = await fetch('https://************.casino/restapi_url.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: JSON.stringify(requestData),
signal: AbortSignal.timeout(30000), // 30 second timeout
});
const httpCode = response.status;
console.log(`HTTP ${httpCode}`);
if (!response.ok) {
throw new Error(`HTTP error! status: ${httpCode}`);
}
const data = await response.json();
// Process the response
console.log(data);
} catch (error) {
if (error instanceof Error) {
console.error('Request error:', error.message);
}
throw error;
}
}
callCWSApi();//DISCLAIMER: The code samples below were AI-generated based on our original PHP implementation. Please review and test thoroughly before use. We provide these samples for guidance only and assume no responsibility for their implementation in production environments.
import requests
import json
from typing import Dict, Any
cws_api = {
'apiusername': 'rgs_demo_testXXXXXX', # replace with your given api username
'apipass': 'rgs_demo_passXXXXXX', # replace with your given api password
'restapi_url': 'https://************.casino/restapi_url.php', # replace with our given REST API URL
}
request_data = {
'command': 'getListGames', # command used for getting list of games
'apiusername': cws_api['apiusername'],
'apipass': cws_api['apipass'],
}
try:
response = requests.post(
cws_api['restapi_url'],
json=request_data,
headers={
'Content-Type': 'application/json',
'Accept': 'application/json',
},
timeout=30 # 30 seconds timeout
)
http_code = response.status_code
print(f"HTTP {http_code}")
# Raise exception for bad status codes
response.raise_for_status()
# Process the response
data = response.json()
print(data)
except requests.exceptions.ConnectionError as e:
print(f"Connection error: {e}")
except requests.exceptions.Timeout as e:
print(f"Timeout error: {e}")
except requests.exceptions.HTTPError as e:
print(f"HTTP error: {e}")
except requests.exceptions.RequestException as e:
print(f"Request error: {e}")//DISCLAIMER: The code samples below were AI-generated based on our original PHP implementation. Please review and test thoroughly before use. We provide these samples for guidance only and assume no responsibility for their implementation in production environments.purposes;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import com.google.gson.Gson;
import java.util.HashMap;
import java.util.Map;
public class CWSApiClient {
private static final String API_USERNAME = "rgs_demo_testXXXXXX"; // replace with your given api username
private static final String API_PASSWORD = "rgs_demo_passXXXXXX"; // replace with your given api password
private static final String RESTAPI_URL = "https://************.casino/restapi_url.php"; // replace with our given REST API URL
public static void main(String[] args) {
try {
// Prepare request data
Map<String, String> requestData = new HashMap<>();
requestData.put("command", "getListGames"); // command used for getting list of games
requestData.put("apiusername", API_USERNAME);
requestData.put("apipass", API_PASSWORD);
// Convert to JSON
Gson gson = new Gson();
String jsonBody = gson.toJson(requestData);
// Create HTTP client
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(30))
.build();
// Build request
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(RESTAPI_URL))
.timeout(Duration.ofSeconds(30))
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
// Send request
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
int httpCode = response.statusCode();
System.out.println("HTTP " + httpCode);
if (httpCode >= 200 && httpCode < 300) {
// Process the response
String responseBody = response.body();
System.out.println(responseBody);
} else {
System.err.println("HTTP error: " + httpCode);
}
} catch (java.net.ConnectException e) {
System.err.println("Connection error: " + e.getMessage());
} catch (java.net.http.HttpTimeoutException e) {
System.err.println("Timeout error: " + e.getMessage());
} catch (Exception e) {
System.err.println("Request error: " + e.getMessage());
e.printStackTrace();
}
}
}
//Maven Dependencies
//<dependencies>
// <dependency>
// <groupId>com.google.code.gson</groupId>
// <artifactId>gson</artifactId>
// <version>2.10.1</version>
// </dependency>
//</dependencies>//DISCLAIMER: The code samples below were AI-generated based on our original PHP implementation. Please review and test thoroughly before use. We provide these samples for guidance only and assume no responsibility for their implementation in production environments.
using System;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text.Json;
using System.Threading.Tasks;
using System.Collections.Generic;
public class CWSApiClient
{
private const string ApiUsername = "rgs_demo_testXXXXXX"; // replace with your given api username
private const string ApiPassword = "rgs_demo_passXXXXXX"; // replace with your given api password
private const string RestApiUrl = "https://************.casino/restapi_url.php"; // replace with our given REST API URL
public static async Task Main(string[] args)
{
try
{
// Prepare request data
var requestData = new Dictionary<string, string>
{
{ "command", "getListGames" }, // command used for getting list of games
{ "apiusername", ApiUsername },
{ "apipass", ApiPassword }
};
// Create HTTP client with timeout
using var httpClient = new HttpClient
{
Timeout = TimeSpan.FromSeconds(30)
};
// Send POST request
var response = await httpClient.PostAsJsonAsync(RestApiUrl, requestData);
int httpCode = (int)response.StatusCode;
Console.WriteLine($"HTTP {httpCode}");
// Ensure success status code
response.EnsureSuccessStatusCode();
// Process the response
var responseData = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseData);
// Or deserialize to object:
// var data = await response.Content.ReadFromJsonAsync<Dictionary<string, object>>();
}
catch (HttpRequestException e)
{
Console.WriteLine($"HTTP error: {e.Message}");
}
catch (TaskCanceledException e)
{
Console.WriteLine($"Timeout error: {e.Message}");
}
catch (Exception e)
{
Console.WriteLine($"Request error: {e.Message}");
}
}
}
//IMPORTANT:NuGet packages required:
//System.Net.Http.Json (included in .NET 5+)
//System.Text.Json (included in .NET Core 3.0+)//DISCLAIMER: The code samples below were AI-generated based on our original PHP implementation. Please review and test thoroughly before use. We provide these samples for guidance only and assume no responsibility for their implementation in production environments. purposes;
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"time"
)
type CWSApiConfig struct {
ApiUsername string
ApiPassword string
RestApiUrl string
}
type GetListGamesRequest struct {
Command string `json:"command"`
ApiUsername string `json:"apiusername"`
ApiPassword string `json:"apipass"`
}
func main() {
// Configuration
cwsApi := CWSApiConfig{
ApiUsername: "rgs_demo_testXXXXXX", // replace with your given api username
ApiPassword: "rgs_demo_passXXXXXX", // replace with your given api password
RestApiUrl: "https://************.casino/restapi_url.php", // replace with our given REST API URL
}
// Prepare request data
requestData := GetListGamesRequest{
Command: "getListGames", // command used for getting list of games
ApiUsername: cwsApi.ApiUsername,
ApiPassword: cwsApi.ApiPassword,
}
// Convert to JSON
jsonData, err := json.Marshal(requestData)
if err != nil {
fmt.Printf("JSON marshal error: %v\n", err)
return
}
// Create HTTP client with timeout
client := &http.Client{
Timeout: 30 * time.Second,
}
// Create request
req, err := http.NewRequest("POST", cwsApi.RestApiUrl, bytes.NewBuffer(jsonData))
if err != nil {
fmt.Printf("Request creation error: %v\n", err)
return
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
// Send request
resp, err := client.Do(req)
if err != nil {
fmt.Printf("Request error: %v\n", err)
return
}
defer resp.Body.Close()
httpCode := resp.StatusCode
fmt.Printf("HTTP %d\n", httpCode)
// Read response body
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Printf("Response read error: %v\n", err)
return
}
if httpCode >= 200 && httpCode < 300 {
// Process the response
fmt.Println(string(body))
// Or unmarshal to struct/map:
// var result map[string]interface{}
// json.Unmarshal(body, &result)
} else {
fmt.Printf("HTTP error: %d\n", httpCode)
}
}//DISCLAIMER: The code samples below were AI-generated based on our original PHP implementation. Please review and test thoroughly before use. We provide these samples for guidance only and assume no responsibility for their implementation in production environments.purposes;
require 'net/http'
require 'json'
require 'uri'
# Configuration
cws_api = {
apiusername: 'rgs_demo_testXXXXXX', # replace with your given api username
apipass: 'rgs_demo_passXXXXXX', # replace with your given api password
restapi_url: 'https://************.casino/restapi_url.php' # replace with our given REST API URL
}
# Prepare request data
request_data = {
command: 'getListGames', # command used for getting list of games
apiusername: cws_api[:apiusername],
apipass: cws_api[:apipass]
}
begin
# Parse URL
uri = URI.parse(cws_api[:restapi_url])
# Create HTTP object
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.open_timeout = 30
http.read_timeout = 30
# Create request
request = Net::HTTP::Post.new(uri.request_uri)
request['Content-Type'] = 'application/json'
request['Accept'] = 'application/json'
request.body = request_data.to_json
# Send request
response = http.request(request)
http_code = response.code.to_i
puts "HTTP #{http_code}"
if response.is_a?(Net::HTTPSuccess)
# Process the response
data = JSON.parse(response.body)
puts data
else
puts "HTTP error: #{http_code}"
puts response.body
end
rescue Net::OpenTimeout, Net::ReadTimeout => e
puts "Timeout error: #{e.message}"
rescue SocketError => e
puts "Connection error: #{e.message}"
rescue StandardError => e
puts "Request error: #{e.message}"
end๐งพ Data Format Notes
All parameters must be passed as JSON-encoded data.
Data types:
Any fields can be of type
string, even numbersIf you prefer to not send numbers as strings, then please note that some numerical values can be passed as
int
โ ๏ธ Do not pass raw
float! Usestringforfloats
โก๏ธ REST API Endpoint URL
The REST API URL you're supposed to use was provided by CWS Support when your operator account was configured.
Refer to this as your:REST API URL (e.g., https://www.cryptoclub.casino/wwwmisc/API/restapi_url.php)
๐ Where to Find Parameter Details
For a list of required parameters and request structures per command:
See the documentation sections:
Main Endpoints
Advanced Endpoints
๐งโ๐ป Code Samples
If you require code samples in PHP for getting list of games, launching the games, please contact us.