Create Account - Sign In
Browse - New Book - My Books - Sell - Groups - $19 ISBNs - Upload / Convert - Help - follow us!   

The ePub Bud API

If you don't know what an API is, don't worry about it!


What can it do?

Absolutely everything the epubbud.com website can do!


How does it work?

Simply POST to any of our site URLs with two additional variables:

   api_username the username or email address of your ePub Bud account.
api_password your account's password.

Can the API create ePub Bud accounts?

Yup.. just post to the url:


http://www.epubbud.com/login.php

With the variables:

   new (with the value "1")
submit (with the value "1")
username (your desired username)
password (your desired password)
name (your name)
email (your email address)

If the response is a 302 redirect, you succeeded. Any other response means there was an error.

(This is the only functionality that doesn't require the api_username and api_password variables.)

How do I upload a file to convert via the API?

Simply post to the url:


http://www.epubbud.com/uploader.php

With the variable:

   file (make it the actual content of the file to convert)

Of course, you also need to post the api_username and api_password variables!

Any questions, problems, or suggestions?

Please, let us know!


Example PHP code using the API

<?php

$email = 'test@epubbud.com';
$pw = 'testtest';
$name = 'API test';
$username = 'apitester';
$filename = 'testfile.pdf';

# let's try creating an account first!
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.epubbud.com/login.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1 );

$postData = array('email'=>$email,
				  'password'=>$pw,
				  'name'=>$name,
				  'username'=>$username,
				  'new'=>1,
				  'submit'=>1
				  );
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData );
$response = curl_exec( $ch );

if ($response) {
	print "error creating account! $response";
	# note: $response is going to be a full HTML page!
} else { #we are good!
	# upload a file to convert!
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, 'http://www.epubbud.com/uploader.php');
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
	curl_setopt($ch, CURLOPT_POST, 1 );

	$postData = array('api_username'=>$email,
					  'api_password'=>$pw,
					  'file'=>"@$filename");
	curl_setopt($ch, CURLOPT_POSTFIELDS, $postData );
	if (is_file($filename)) {
		$res2 = curl_exec( $ch );
		if ($res2) {
			print "error: $res2";
		} else {
			print "successfully uploaded!";
		}
	} else {
		print "no such file: $filename";
	}
}
?>


Example Perl code using the API

#!/usr/bin/perl

my $email = 'test@epubbud.com';
my $pw = 'testtest';
my $name = 'API test';
my $username = 'apitester';
my $filename = 'testfile.pdf';

use LWP;
my $browser = LWP::UserAgent->new;

# let's try creating an account first!
my $response = $browser->post(
  'http://www.epubbud.com/login.php',
   [
	'email'=>$email,
	'password'=>$pw,
	'name'=>$name,
	'username'=>$username,
	'new'=>1,
	'submit'=>1
   ],
);

if (my $error = $response->{'_content'}) {
	print "error creating account! $error"; 
	# note: $error is going to be a full HTML page!
} else { # we are good!
	# now let's upload a file to convert!
	my $res2 = $browser->post(
	 'http://www.epubbud.com/uploader.php',
	 [
	  'api_username'=>$email, # $username also works
	  'api_password'=>$pw,
	  'file' => [$filename]
	 ],
	 'Content_Type' => 'form-data'
	);
	my $loc = $res2->{'_headers'}->{'location'};
	if ($loc eq 'http://www.epubbud.com/upload.php') {
		print "successfully uploaded!";
	} else {
		print "error: $loc";
	}
}

   Use one of these to use the API