Tuesday, December 9, 2014

Control Panel v4 - WebShop API - Bot Manual


Interested in opening a website to advertise your bot? 

ML Bots WebShop API is a development tool that allows you to set up a pricing website for your customers requests getting set names, card buy/sell prices and quantities held by your bots to display on your website.

Each bot registered with ML Bots has a unique key identifier. This identifier is sent to our API along with your request so we know which bot’s data is desired. We then reply to your request with the data you’ve requested.

If you are not a developer, no problem. ML Bot specialists will gladly assist you to get your website off to the right start. You can contact us on Livechat or email us at staff@mtgolibrary.com

A functioning example of the API in action can be seen at www.decentbot.com.

The following is a php example which makes a call to the API and then displays the data in a simple HTML table.

<?php
/*** MTGO Library API Example ***/

// build the url to the api
$url = 'https://www.mtgolibrary.com/web_shops/inventory?' .  http_build_query(array(
    'bot' => 'YOUR_BOT_NAME_HERE', // your username
    'key' => 'YOUR_API_KEY_HERE',  // your api key
    'set_name' => 'BNG',           // the set name to download
));

// download the inventory
$inventory = json_decode(file_get_contents($url), true);

// create a table with the cards
?>
<table>
    <thead>
    <tr>
        <th>Card Name</th>
        <th>Set Name</th>
        <th>Rarity</th>
        <th>Bot</th>
        <th>Foil</th>
        <th>Buy Price</th>
        <th>Buy Quantity</th>
        <th>Sell Price</th>
        <th>Sell Quantity</th>
    </tr>
    </thead>
    <tbody>
    <?php foreach ($inventory as $card) { ?>
        <tr>
            <td><?php echo stripslashes(urldecode($card['card_name'])); ?></td>
            <td><?php echo $card['set_name']; ?></td>
            <td><?php echo $card['rarity']; ?></td>
            <td><?php echo urldecode($card['bot']); ?></td>
            <td><?php echo $card['foil'] ? 'foil' : ''; ?></td>
            <td><?php echo $card['buy_price']; ?></td>
            <td><?php echo $card['buy_quantity']; ?></td>
            <td><?php echo $card['sell_price']; ?></td>
            <td><?php echo $card['sell_quantity']; ?></td>
        </tr>
    <?php } ?>
    </tbody>
</table>


No comments:

Post a Comment