Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Public API v1 - GET
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / V4 / Downloads & Updates

2020-12-07 06:56:14
Im working on a public API (version 1) in the GET stages of the documentation for application building / feeding data.

Just logging my progress as I shift a full API sandbox.

[color=rgb(65, 168, 95)]VALID (RFC 8259)[/color]

Stage 1: Retrieve data : endpoint parameters


/*
   API Request:     GET - List Games
   JSON Endpoint:  /api/public/v1/list_Games.json
   Params:          ? limit, order_by, sort_by
*/

if (array_key_exists('list_Games', $_GET)) {
   $data = $db->query_params('SELECT DISTINCT torrent_id, info_hash, name, descr AS description, cover1 AS boxart, image1 AS screen_1, image2 AS screen_2, category, size, added, comments, views, hits, times_completed AS completed, leechers, seeders, numratings AS total_ratings, external, tags, youtube, version, dlc FROM torrents ORDER BY :order_by :sort_by LIMIT :limit',
   array(
   'order_by' => strval($_GET['order_by']) ? strval($_GET['order_by']) : 'added',  // Order By - Default: added
   'sort_by' => strval($_GET['sort_by']) ? strval($_GET['sort_by']) : 'DESC',        // Sort By - Default: DESC
   'limit' => intval($_GET['limit']) ? intval($_GET['limit']) : 20)                 // Limit - Default: 20
   );
   $gameData = array();
   if ($data) {
       $listgames = $data->fetchAll();
       $status = ($data) ? 'ok' : 'error';
       $limit = 0;
       foreach ($listgames as $row => $data) {
           $limit++;
           $data = $row;
           $message = '';
           if ($data) {
               $message = 'Query was successful';
           }else{
               $message = 'Query returned error';
           }
           array_push($gameData, $listgames);
       }
   }
   echo "{\"status\":\"$status\",\"status_message\":\"$message\",\"data\":{\"game_count\":958,\"limit\":$limit,\"page_number\":1,\"games\":" . json_encode($listgames, JSON_PRETTY_PRINT, JSON_INVALID_UTF8_SUBSTITUTE) . "}}";
   die;
}

/*
   API Request:     GET - Game Details
   JSON Endpoint:  /api/public/v1/Game_details.json
   Params:          torrent_id
*/

if (array_key_exists('Game_details', $_GET)) {
   $data = $db->query_params('SELECT torrent_id, info_hash, name, descr AS description, cover1 AS boxart, image1 AS screen_1, image2 AS screen_2, category, size, added, comments, views, hits, times_completed AS completed, leechers, seeders, numratings AS total_ratings, external, tags, youtube, version, dlc FROM torrents WHERE torrent_id = :torrent_id LIMIT 1',
   array(
   'torrent_id' => intval($_GET['torrent_id']) ? intval($_GET['torrent_id']) : 1)      // Torrent ID - Default: 1
   );
   $gameData = array();
   if ($data) {
       $listdetails = $data->fetchAll();
       $status = ($data) ? 'ok' : 'error';
       foreach ($listdetails as $row => $data) {
           $data = $row;
           $message = '';
           if ($data) {
               $message = 'Query was successful';
           }else{
               $message = 'Query returned error';
           }
           array_push($gameData, $listdetails);
       }
   }
   echo "{\"status\":\"$status\",\"status_message\":\"$message\",\"data\":" . json_encode($listdetails, JSON_PRETTY_PRINT, JSON_INVALID_UTF8_SUBSTITUTE) . "}";
   die;
}
2020-12-11 10:30:38
"STorrents2020, post: 69669, member: 20382":

echo "{\"status\":\"$status\",\"status_message\":\"$message\",\"data\":" . json_encode($listdetails, JSON_PRETTY_PRINT, JSON_INVALID_UTF8_SUBSTITUTE) . "}";

You can simply pass a array with the key => value
2020-12-11 23:42:52
this should do it
<?php

/**

* API Request:     GET - List Games

* JSON Endpoint:  /api/public/v1/list_Games.json

* @Params:          ? $limit, $order_by, $sort_by

*/


if (array_key_exists('list_Games', $_GET)) {


   $data = $db->query_params('SELECT DISTINCT torrent_id, info_hash, name, descr AS description, cover1 AS boxart, image1 AS screen_1, image2 AS screen_2, category, size, added, comments, views, hits, times_completed AS completed, leechers, seeders, numratings AS total_ratings, external, tags, youtube, version, dlc FROM torrents ORDER BY :eek:rder_by :sort_by LIMIT :limit',

       array(

           'order_by' => strval($_GET['order_by']) ? strval($_GET['order_by']) : 'added',  // Order By - Default: added

           'sort_by' => strval($_GET['sort_by']) ? strval($_GET['sort_by']) : 'DESC',        // Sort By - Default: DESC

           'limit' => intval($_GET['limit']) ? intval($_GET['limit']) : 20)                 // Limit - Default: 20

   );

   $gameData = array();

   if ($data) {

       $listgames = $data->fetchAll();

       $status = ($data) ? 'ok' : 'error';

       $limit = 0;

       foreach ($listgames as $row => $data) {

           $limit++;

           $data = $row;

           $message = '';

           if ($data) {

               $message = 'Query was successful';

           } else {

               $message = 'Query returned error';

           }

           array_push($gameData, $listgames);

       }

   }


   echo json_encode([

       'status' => $status,

       'status_message' => $message,

       'data' =>

           [

               'game_count' => 958,

               'limit' => $limit,

               'page_number' => 1,

               'games' => json_encode($listgames, JSON_PRETTY_PRINT, JSON_INVALID_UTF8_SUBSTITUTE)


           ]

   ]);

   die();

}


/**

* API Request:     GET - Game Details

* JSON Endpoint:  /api/public/v1/Game_details.json

* @Params:         $torrent_id

*/


if (array_key_exists('Game_details', $_GET)) {

   $data = $db->query_params('SELECT torrent_id, info_hash, name, descr AS description, cover1 AS boxart, image1 AS screen_1, image2 AS screen_2, category, size, added, comments, views, hits, times_completed AS completed, leechers, seeders, numratings AS total_ratings, external, tags, youtube, version, dlc FROM torrents WHERE torrent_id = :torrent_id LIMIT 1',

       array(

           'torrent_id' => intval($_GET['torrent_id']) ? intval($_GET['torrent_id']) : 1)      // Torrent ID - Default: 1

   );

   $gameData = array();

   if ($data) {

       $listdetails = $data->fetchAll();

       $status = ($data) ? 'ok' : 'error';

       foreach ($listdetails as $row => $data) {

           $data = $row;

           $message = '';

           if ($data) {

               $message = 'Query was successful';

           } else {

               $message = 'Query returned error';

           }

           array_push($gameData, $listdetails);

       }

   }

   echo json_encode(

       [

           'status' => $status, '

           status_message' => $message,

           'data' => json_encode($listdetails, JSON_PRETTY_PRINT, JSON_INVALID_UTF8_SUBSTITUTE)

       ]);


}
2020-12-13 00:39:08
"rio, post: 69674, member: 20324":

this should do it
<?php

/**

* API Request:     GET - List Games

* JSON Endpoint:  /api/public/v1/list_Games.json

* @Params:          ? $limit, $order_by, $sort_by

*/


if (array_key_exists('list_Games', $_GET)) {


   $data = $db->query_params('SELECT DISTINCT torrent_id, info_hash, name, descr AS description, cover1 AS boxart, image1 AS screen_1, image2 AS screen_2, category, size, added, comments, views, hits, times_completed AS completed, leechers, seeders, numratings AS total_ratings, external, tags, youtube, version, dlc FROM torrents ORDER BY :eek:rder_by :sort_by LIMIT :limit',

       array(

           'order_by' => strval($_GET['order_by']) ? strval($_GET['order_by']) : 'added',  // Order By - Default: added

           'sort_by' => strval($_GET['sort_by']) ? strval($_GET['sort_by']) : 'DESC',        // Sort By - Default: DESC

           'limit' => intval($_GET['limit']) ? intval($_GET['limit']) : 20)                 // Limit - Default: 20

   );

   $gameData = array();

   if ($data) {

       $listgames = $data->fetchAll();

       $status = ($data) ? 'ok' : 'error';

       $limit = 0;

       foreach ($listgames as $row => $data) {

           $limit++;

           $data = $row;

           $message = '';

           if ($data) {

               $message = 'Query was successful';

           } else {

               $message = 'Query returned error';

           }

           array_push($gameData, $listgames);

       }

   }


   echo json_encode([

       'status' => $status,

       'status_message' => $message,

       'data' =>

           [

               'game_count' => 958,

               'limit' => $limit,

               'page_number' => 1,

               'games' => json_encode($listgames, JSON_PRETTY_PRINT, JSON_INVALID_UTF8_SUBSTITUTE)


           ]

   ]);

   die();

}


/**

* API Request:     GET - Game Details

* JSON Endpoint:  /api/public/v1/Game_details.json

* @Params:         $torrent_id

*/


if (array_key_exists('Game_details', $_GET)) {

   $data = $db->query_params('SELECT torrent_id, info_hash, name, descr AS description, cover1 AS boxart, image1 AS screen_1, image2 AS screen_2, category, size, added, comments, views, hits, times_completed AS completed, leechers, seeders, numratings AS total_ratings, external, tags, youtube, version, dlc FROM torrents WHERE torrent_id = :torrent_id LIMIT 1',

       array(

           'torrent_id' => intval($_GET['torrent_id']) ? intval($_GET['torrent_id']) : 1)      // Torrent ID - Default: 1

   );

   $gameData = array();

   if ($data) {

       $listdetails = $data->fetchAll();

       $status = ($data) ? 'ok' : 'error';

       foreach ($listdetails as $row => $data) {

           $data = $row;

           $message = '';

           if ($data) {

               $message = 'Query was successful';

           } else {

               $message = 'Query returned error';

           }

           array_push($gameData, $listdetails);

       }

   }

   echo json_encode(

       [

           'status' => $status, '

           status_message' => $message,

           'data' => json_encode($listdetails, JSON_PRETTY_PRINT, JSON_INVALID_UTF8_SUBSTITUTE)

       ]);


}



Nice! Thank you
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 2
  • Members: 0
  • Guests online: 2
  • Comments: 3
  • Messages: 1,728