
Envato recently released an API for thier various Marketplaces. I have taken the various methods of interacting with this data and compiled it into one, easy to use codeigniter library. It can also be used as a standalone php class if you wish. The class is currently PHP5 and requires you have json_encode, json_decode, and curl functions available.
Overview
So I created this library mostly out of boredom. It includes functions to interact with all of the options & functionality that the current version (“EDGE”) provides. It was designed to be a CodeIgniter library but it can easily be ported over to php in just a few steps. It allows you to output the data in json, array, or raw (the format that the request was [json, xml]). So lets get to it!
Download
Envato Marketplace CodeIgniter API Library ( v1.0 )Documentation
Configuration
There are several options you can set in the configuration that will make the library behave differently.
- username – obviously your username for the envato marketplaces
- api_key – your api key for the marketplaces ( you should never set this in view of the public, its sort of like a password ).
- api_format – the format you want the library to request, this can be altered with the next option (output format) – options incude : json, array, xml (default is json)
- output_format – the format you want the library to return to you. options: array (default), json, raw (unaltered/formatted data straight from the feed) note: to get xml format back you need to set this to raw and set api_format to xml
This is how you can set the config information with a simple function and array.
$this->envato_api->config(array('api_format' => 'json', 'output_format' => 'array', 'username' => 'joesmith', 'api_key' => 'MYSUPERSECRETKEY'));
Place the configuration code above the functions listed below.
Public Functions
These are functions that do not require a username and api key to access. They are mostly things such as the latest files on the marketplaces, the most popular threads, etc.
Blog Posts
A list of blog posts for a particular site. Requires a site parameter.
$data = $this->envato_api->public_blog_posts('sitename');
$this->evanto_api->clear();
Active Threads
Threads with the most recent messages activity. Requires a site parameter.
$data = $this->envato_api->public_threads_active('sitename');
$this->evanto_api->clear();
Number of Files in Categories
Shows the number of files in the major categories of a particular site. Requires a site paramater.
$data = $this->envato_api->public_files_number('sitename');
$this->evanto_api->clear();
Category New Files
New files, recently uploaded to a particular site. Requires site and category paramaters.
$data = $this->envato_api->public_files_new('sitename', 'categoryname');
$this->evanto_api->clear();
Popular Files
Returns the popular files for a particular site. Requires a site paramater.
$data = $this->envato_api->public_files_popular('sitename');
$this->evanto_api->clear();
New User Files
Shows the newest 10 files a user has uploaded to a particualr site. Requires username and site paramaters.
$data = $this->envato_api->public_files_user_new('username', 'sitename');
$this->evanto_api->clear();
Random New Files
Shows a random list of newly uploaded files from a particular site (i.e. like the homepage). Requires a site paramater.
$data = $this->envato_api->public_files_new_random('sitename');
$this->evanto_api->clear();
API Releases
Returns Release and Set information for the API (used to generate the documentation).
$data = $this->envato_api->public_releases(); $this->evanto_api->clear();
Private User Functions
These are functions that DO require a username and API key to access. They include things such as account information, billing statements, etc. Make sure to set your username & api key inside the script or with the config function above.
User Vitals
Return a users username and balance.
$data = $this->envato_api->user_vitals(); $this->evanto_api->clear();
User Account
Returns the first name, surname, total earnings, total deposits, balance (deposits + earnings), country and current commission rate for sales.
$data = $this->envato_api->user_account(); $this->evanto_api->clear();
User Earnings & Monthly Sales
Returns the monthly sales data, as displayed on the user’s earnings page.
$data = $this->envato_api->user_earnings(); $this->evanto_api->clear();
User Statement
Returns the last 100 events as seen on the user’s statement page.
$data = $this->envato_api->user_statement(); $this->evanto_api->clear();
User Recent Sales
Shows the 50 recent sales of the user’s items.
$data = $this->envato_api->user_recent_sales(); $this->evanto_api->clear();
User Multiple
This function will return multiple sets of data at once. if you dont supply anything in the parameters it will return all of the results by default. The options inside the array below are the only options you have. You can use as many or as little as you need.
$data = $this->envato_api->user_multiple(array('account', 'vitals', 'earnings-adn-sales-by-month', 'statement', 'recent-sales'));
$this->evanto_api->clear();
Done!
We are all done! If you have any questions, suggestions, bugs or just wanna say thanks then reply in the comments.









One Response
Nice! I didn’t know about the Envato marketplace at all … thanks for this!