<?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>