Linode Account Balance Enquiry API

Linode is a cloud hosting platform provides varieties of Linux based OS (ubuntu, cent-os, and more). It does provide an API to dynamically provision Linode cloud, like add new node, upgrade/downgrade plan, and account API. It does provide Prepaid service by credit card. In case you purchase $20 plan, you can pay in advance the amount stored in your account, it will be deducted every first week of month.

I owns a Linode. Normally I paid one or two months fee in advance. I have to create my own reminder or randomly remember, Oh, just need to pay Linode again. I had to log in to Linode Member Dashboard to check my account balance every time.

After 9 months of Linode experience, I began finding its API and found this API very useful, its Account Balance Enquiry API.

This simple API allows me to query my current account balance, and then compare with the threshold I define, if it is lower than the threshold, then I can receive iPhone Push Notification.

I set a Cron Job to execute the following PHP script which then send the notification. The details of setting up Push Notification for iPhone is not in this topic.

< ?php

$threshold = 20;

$api_key = '<your api key here>';
$result = json_decode(file_get_contents(''.$api_key.'&'), TRUE);

if($result['ACTION'] == '') {
	$balance = floatval($result['DATA']['BALANCE']);
	$balance = abs($balance);
	$message = 'Linode Account Balance is '.$balance;
	if($balance < $threshold) { 		$message .= ', lower than threshold '. $threshold; 	} 	sendAPN($message); } echo '1'; ?>

Author: fyhao

Jebsen & Jessen Comms Singapore INTI University College Bsc (Hon) of Computer Science, Coventry University

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.