Apiheap.js is super easy to use. Start making your REST requests to a number of platforms, in just a few minutes.
Apiheap.js is only 6.13 kilobytes in size. Make quick and powerful requests, without compromising performance.
Apiheap.js is completely opensource. View the code, make changes, and use it to your hearts content.
To use apiheap.js, include it after your
</body>
tag. Note that apiheap.js requires jQuery to function.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="js/apiheap.min.js"></script>
If you prefer, you can also use apiheap.js through a CDN.
<script src="https://cdn.rawgit.com/tash-had/apiheapjs/764562ed/apiheap.min.js"></script>
Hit 'How It Works' to get a gist of apiheap.js behind the scenes.
var myObj = new apiheap("imgur", "IMGUR_CLIENT_ID"), myData;
var myObj = new apiheap("imgur", "IMGUR_CLIENT_ID"), myData;
myObj.imgur("Awesome", "top/all", true); //Look in topic 'Awesome', search top of all-time, request is a topic.
var myObj = new apiheap("imgur", "IMGUR_CLIENT_ID"), myData;
myObj.imgur("Awesome", "top/all", true); //Look in topic 'Awesome', search top of alltime, request is a topic.
function myFunction() {
myData = myObj.parse("link"); //Requesting all 'links' from the objects in the response data.
console.log(myData); } //Use the data (array)
//When myFunction() is triggered, bitlyLink will hold a short link for "https://google.ca"
var bitlyObj = new apiheap("bitly", "MY_AUTH_TOKEN"),bitlyLink;
bitlyObj.bitly("https://google.ca");
function myFunction() {
bitlyLink = bitlyObj.parse(); console.log(bitlyLink);}
//When myFunction() is triggered, tumblrData will hold an array containing URL's of the 50 post's fetched.
var tumblrObj = new apiheap("tumblr", "MY_TUMBLR_KEY"), tumblrData;
tumblrObj.tumblr("myexampleblog.tumblr.com", null, "limit=50");
function myFunction() {
tumblrData = tumblrObj.parse("post_url"); console.log(tumblrData);}
myObj.tumblr("BLOG_URL",
"POST_TYPE", "REQUEST_PARAMS")
myObj.parse("MY_ITEM");
//When myFunction() is triggered, imgurData will hold an array of links from the fetched data.
var imgurObj = new apiheap("imgur", "MY_CLIENT_ID"), imgurData;
imgurObj.imgur("cats", "top/all");
function myFunction() {
imgurData = imgurObj.parse("link"); console.log(imgurData); }
myObj.imgur("TAG_NAME",
"OPT_PARAMS", IS_TOPIC);
myObj.imgur(null,
"r/funny/top/all");
Note that the first, and last character of this parameter can never be a slash.
myObj.parse("MY_ITEM");
//When myFunction() is triggered, redditData will hold an array of URL's from post's fetched.
var redditObj = new apiheap("reddit"), redditData;
redditObj.reddit("funny", "new", "t=week&limit=50");
function myFunction() {
redditData = redditObj.parse("url"); console.log(redditData);}
myObj.reddit("SUBREDDIT_NAME",
"SORT", "OPT_PARAMS");
myObj.reddit(null,
"subreddits/popular");
will search for popular subreddits.myObj.reddit(null,
"search", "q=kittens&limit=10");
myObj.parse(MY_ITEM);
var redditObj = new apiheap("reddit"), redditData;
/* Subreddit is optional. Defaults to /r/all. 2nd and 3rd parameters are required.
This code will return the most recent comments from /r/cats containing "funny" */
redditObj.reddit("cats", "comments", "funny&limit=50");
function myFunction() {
redditData = redditObj.parse("comments"); console.log(redditData);}
//When myFunction() is triggered, ytData will hold an array of YouTube links from videos/playlists fetched.
var ytObj = new apiheap("youtube", "MY_API_KEY"), ytData=[];
ytObj.youtube("search", "snippet", "q=cat videos");
function myFunction() {
ytData = ytObj.parse(ytObj.RESPONSE, "vid_links"); console.log(ytData);}
myObj.youtube(TYPE, PART, OPT_PARAMS, PAGE_TOKEN);
myObj.youtube("search", "snippet", "q=cat videos"); //Requesting results from a search query for 'cat videos'
myObj.youtube("playlists", "snippet", "channelId=CHANNEL_ID"); //Requesting playlists in a channel
myObj.parse(DATA, ITEM);
//Make object, and use youtube() method to make request for 'cats' search query. Also make variable to hold data.
var myObj = new apiheap("youtube", "MY_API_KEY"), query_results = [];
myObj.youtube("search", "snippet", "q=cats");
//Make loadMore() function to first push request response to query_results, then make another request using the youtube() method - this time, including a fourth parameter (PAGE_TOKEN). Enter pageToken(myObj.MY_RESPONSE) as the value for the fourth parameter.
function loadMore() {
query_results.push(myObj.RESPONSE);
myObj.youtube("search", "snippet", "q=cats", pageToken(myObj.RESPONSE));}
//query_results will be an array of responses (depending on how many times loadMore() was triggered). Use the parse() method, and pass in query_results as the data, along with an request item to parse data from the responses.
function myFunction() {
console.log(myObj.parse(query_results, "vid_links"));}
//When myFunction() is triggered, weatherData will hold an object with information from the response.
var weatherObj = new apiheap("openweathermap", "MY_API_KEY"), weatherData;
weatherObj.weather("toronto");
function myFunction() {
weatherData = weatherObj.parse("main"); console.log(weatherData);}
myObj.weather("CITY", "CUSTOM");
myObj.weather(null,
"zip=XXXXXX, ca")
myObj.parse("ITEM");
YouWork is an open-source Chrome extension that aims to minimize distractions on YouTube by redirecting YouTube to YouWork - a distraction free version. YouWork uses apiheap.js to fetch YouTube videos and video data.
Internet-Thoughts is an open-source sentiment analysis tool created at Yale University for YHack 2016. Internet-Thoughts uses Apiheap.js (and other methods) to fetch data on any given topic based on a query. Internet-Thoughts then analyzes this data using a built-in sentiment-analysis engine, which calculates the average positivity/negativity within references of that topic.