Welcome to World of IPTV

With

+23k members
+11k threads
+106k posts

we are the most popular IPTV community on the web. 

IMPORTANT NOTE:
WE HAVE RECENTLY NOTICED THAT TOO MANY DOUBLE FAKE ACCOUNTS ARE CREATED IN THE PAST.
TO PREVENT THIS ISSUE THE DECISION WAS MADE THAT IN THE FUTURE A ANNUALLY FEE 20 EURO WILL BE RAISED FOR NEW MEMBERSHIPS.

Join now to the World of IPTV

Forum Rules

Before you start, check out the forum rules first

Account upgrade

Upgrade your account to get access to full features

Advertising

Would you like to place your advertisement with us ?

Resources Manager

Hundreds of IPTV scripts and apps are available for download

Info Xtream Codes v2 API Examples

mojbuk

Extended Member
Ext. Member
Joined
Sep 22, 2019
Messages
55
Reaction score
325
Points
64
Location
BiH
Hi People, here some "maybe" usefull information about the XC v2 API - didnt try it by myself
You schould be able to use it against you XC v2 CMS server

Please like - no likes needed to see the contents :)



Creating New Line

To create a New line, we will call the following URL.

http://dns:port/api.php?action=user&sub=create

The above URL, accepts the POST action, and to create a new line we will have to specify some arguments in an array called user_data

Example Code:


PHP:
<?php

$panel_url = 'http://DNS:PORT/';
$username = 'test_username';
$password = 'test_password';
$max_connections = 1;
$reseller = 1;
$bouquet_ids = array(
    1,
    2,
    3 );
$expire_date = strtotime( "+1 month" );

###############################################################################
$post_data = array( 'user_data' => array(
        'username' => $username,
        'password' => $password,
        'max_connections' => $max_connections,
        'is_restreamer' => $reseller,
        'exp_date' => $expire_date,
        'bouquet' => json_encode( $bouquet_ids ) ) );

$opts = array( 'http' => array(
        'method' => 'POST',
        'header' => 'Content-type: application/x-www-form-urlencoded',
        'content' => http_build_query( $post_data ) ) );

$context = stream_context_create( $opts );
$api_result = json_decode( file_get_contents( $panel_url . "api.php?action=user&sub=create", false, $context ) );

?>

If you leave the username and/or password elements empty, the system will generate random characters for these 2 fields. In addition, leaving any field empty, api will use the default value for this field according to SQL Database. So theoretically, you can make a line with just Calling the Above URL, without any parameter, however the created user, wont have any bouquets inside.

You can call any other element that is in the database like
  • member_id
  • admin_enabled
  • enabled
  • allowed_ips
  • allowed_ua
  • force_server_id
  • is_isplock
  • admin_notes
  • and so on...
If you want to set the allowed_ips/allowed_ua since this is a JSON Encoded format you can do it like bouquet in the above Code.

The API will return a simple json encoded string that upon decoding will contain the element result which returns true/false.

Example(API Success)


JSON:
{"result":true,"created_id":14838,"username":"d4PSc5uCqF","password":"2ZiuRRZk4b"}
The API returned as the username/password of the NEW line, as well as the ID so we can use it wherever we want.

Example(API Failed)

JSON:
{"result":false,"error":"EXISTS"}
{"result":false,"error":"PARAMETER ERROR"}
  • EXISTS
    The Username you specified already exists in the database
  • PARAMETER ERROR
    You wrote invalid characters in your user_data array

Editing Line

To procedure to edit a line is very similar to the above. The URL we will call this time is

http://dns:port/api.php?action=user&sub=edit

REQUIRED PARAMETERS
  • username
  • password
OPTIONAL PARAMETERS
  • user_data array
For example if we want to Edit the Expire Date, make the line restreamer and adjusting the max connections to 10 we will do it like this:

PHP:
<?php

$panel_url = 'http://DNS:PORT/';
$username = 'test_username';
$password = 'test_password';
$max_connections = 10;
$reseller = 1;
$expire_date = strtotime( "+1 month" ); //from the time now, not from line's expire date.

###############################################################################
$post_data = array(
    'username' => $username,
    'password' => $password,
    'user_data' => array(
        'max_connections' => $max_connections,
        'is_restreamer' => $reseller,
        'exp_date' => $expire_date ) );

$opts = array( 'http' => array(
        'method' => 'POST',
        'header' => 'Content-type: application/x-www-form-urlencoded',
        'content' => http_build_query( $post_data ) ) );

$context = stream_context_create( $opts );
$api_result = json_decode( file_get_contents( $panel_url . "api.php?action=user&sub=edit", false, $context ) );

?>

In the above example, we will edit the max_connections, is_restreamer and exp_date for our line with username test_username, and password test_password that already exists in our database.

Example(API Success)

JSON:
{"result":true}

Example(API Failed)

JSON:
{"result":false,"error":"NOT EXISTS"}
{"result":false,"error":"PARAMETER ERROR"}
{"result":false,"error":"PARAMETER ERROR (user\/pass)"}
  • NOT EXISTS
    The Username / Password you specified are not exists in the database
  • PARAMETER ERROR
    You wrote invalid characters in your user_data array
  • PARAMETER ERROR (user/pass)
    The Username OR/AND Password elements are missing
View Line Information

With this API call, we will get all the information available about our line including the active connections.

The URL we will call this time is

http://dns:port/api.php?action=user&sub=info

REQUIRED PARAMETERS
  • username
  • password
It will return a JSON Encoded string, with all information that you might want.

Example Code:

PHP:
$panel_url = 'http://DNS:PORT/';
$username = "username";
$password = "passwrd";


###############################################################################
$post_data = array( 'username' => $username, 'password' => $password );
$opts = array( 'http' => array(
        'method' => 'POST',
        'header' => 'Content-type: application/x-www-form-urlencoded',
        'content' => http_build_query( $post_data ) ) );

$context = stream_context_create( $opts );
$api_result = json_decode( file_get_contents( $panel_url . "api.php?action=user&sub=info", false, $context ), true );

if ( $api_result['result'] )
{
    echo "Active Connections (Now): " . $api_result['user_info']['active_cons'];
    echo "\nCurrent Expire Date: " . (( empty( $api_result['user_info']['exp_date'] ) ) ? 'Unlimited' : strtotime( $api_result['user_info']['exp_date'] ));
    echo "\nMax Connections: " . $api_result['user_info']['max_connections'];
    echo "\nAvailable Channel IDs: " . implode( ',', $api_result['user_info']['channel_ids'] );
}
else
    echo 'FAILED';

Create/Edit & View Information on MAG Devices

The procedure is almost the same as creating/editing & view info on a user line. The only difference is that instead of calling the user action, we will the stb action. Of course instead of username/password we will just have the mac parameter.


Example API Call To Create New MAG

http://dns:port/api.php?action=stb&sub=create

REQUIRED PARAMETERS
  • user_data[mac]
PHP:
<?php

$panel_url = 'http://DNS:PORT/';
$mac = '00:1A:79:79:79:79';
$bouquet_ids = array(
    1,
    2,
    3 );
$expire_date = strtotime( "+1 month" );

###############################################################################
$post_data = array( 'user_data' => array(
        'mac' => $mac,
        'exp_date' => $expire_date,
        'bouquet' => json_encode( $bouquet_ids ) ) );

$opts = array( 'http' => array(
        'method' => 'POST',
        'header' => 'Content-type: application/x-www-form-urlencoded',
        'content' => http_build_query( $post_data ) ) );

$context = stream_context_create( $opts );
$api_result = json_decode( file_get_contents( $panel_url . "api.php?action=stb&sub=create", false, $context ) );
print_r($api_result);

?>

Example(API Success)

JSON:
{"result":true}

Example(API Failed)

JSON:
{"result":false,"error":"NOT EXISTS"}
{"result":false,"error":"PARAMETER ERROR"}
{"result":false,"error":"PARAMETER ERROR (mac)"}
  • EXISTS
    The MAC already exists in the database
  • PARAMETER ERROR
    You wrote invalid characters in your user_data array
  • PARAMETER ERROR (mac)
    The MAC Parameter was missing

Example API Call To Edit a MAG Device

http://dns:port/api.php?action=stb&sub=edit

REQUIRED PARAMETERS
  • mac
PHP:
<?php

$panel_url = 'http://DNS:PORT/';
$mac = '00:1A:79:79:79:79';
$bouquet_ids = array(
    1,
    2,
    3 );
$expire_date = strtotime( "+1 month" );

###############################################################################
$post_data = array( 'mac' => $mac, 'user_data' => array( 'exp_date' => $expire_date, 'bouquet' => json_encode( $bouquet_ids ) ) );

$opts = array( 'http' => array(
        'method' => 'POST',
        'header' => 'Content-type: application/x-www-form-urlencoded',
        'content' => http_build_query( $post_data ) ) );

$context = stream_context_create( $opts );
$api_result = json_decode( file_get_contents( $panel_url . "api.php?action=stb&sub=edit", false, $context ) );
?>

Example(API Success)

JSON:
{"result":true}

Example(API Failed)

JSON:
{"result":false}
{"result":false,"error":"PARAMETER ERROR"}
{"result":false,"error":"PARAMETER ERROR (mac)"}
  • no error
    The updated information, are the same as in the database, so no action taken.
  • PARAMETER ERROR
    You wrote invalid characters in your user_data array
  • PARAMETER ERROR (mac)
    The MAC Parameter was missing

View Information MAG Device

http://dns:port/api.php?action=stb&sub=info

REQUIRED PARAMETERS
  • mac
It will return a JSON Encoded string, with all information that you might want.

Example Code:

PHP:
<?php

$panel_url = 'http://DNS:PORT/';
$mac = '00:1A:79:79:79:79';


###############################################################################
$post_data = array( 'mac' => $mac);
$opts = array( 'http' => array(
        'method' => 'POST',
        'header' => 'Content-type: application/x-www-form-urlencoded',
        'content' => http_build_query( $post_data ) ) );

$context = stream_context_create( $opts );
$api_result = json_decode( file_get_contents( $panel_url . "api.php?action=stb&sub=info", false, $context ), true );


if ( $api_result['result'] )
{
    echo "Active Connections (Now): " . $api_result['user_info']['active_cons'];
    echo "\nCurrent Expire Date: " . ( ( empty( $api_result['user_info']['exp_date'] ) ) ? 'Unlimited' : strtotime( $api_result['user_info']['exp_date'] ) );
    echo "\nMax Connections: " . $api_result['user_info']['max_connections'];
    echo "\nAvailable Channel IDs: " . implode( ',', $api_result['user_info']['channel_ids'] );
}
else
    echo 'FAILED';

?>
How add no expired (unlimited) mag?
 
I

iptvgoods

Guest
api throws 404 on updating exp_date if exp_date is lower than current date called expired
 
I

iptvgoods

Guest
anybody does have a idea how to solve this issue?

i know i see this issue some years ago but i dont have any idea how i solved this issue some years ago ....
 
Channels MatchTime Unblock CDN Offshore Server Contact
100 cnx / 90€ 5Gbps / 180€ 48CPU-256GRAM 10Gbps 569€ Skype live:giefsl
500 cnx / 350€ 10Gbps / 350€ 48CPU-128GRAM 5Gbps / 349€ TG @changglobize
1000 cnx / 500€ 20Gbps / 700€ 40CPU-128GRAM 20Gbps / €980 http://coronaserver.com

vette

Basic Member
Basic Member
Ext. Member
Joined
Apr 26, 2023
Messages
5
Reaction score
0
Points
4
Location
USA
Is there a way as a reseller to call via the api how many credits I have left? Running 4 services I would like to have a python script or something call out to my services a few times per day and see how many credits I have and if that number is below a threshold I set it would email me or something. I figured out the API call for XUI One but not for Xtream Codes yet.
 
shape1
shape2
shape3
shape4
shape5
shape6
Top
AdBlock Detected

We know, ad-blocking software do a great job at blocking ads. But our site is sponsored by advertising. 

For the best possible site experience please take a moment to disable your AdBlocker.
You can create a Account with us or if you already have account, you can prefer an Account Upgrade.

I've Disabled AdBlock