Idea Melt

Focus Mode

Library

Send Requests

The Basics

Sending requests with IdeaMelt's library is super easy - it's actually just one line of code!

IdeaMelt.send(ENDPOINT, OPTIONS, SUCCESS, FAIL)

This is really the only command you need to know. Everything else is simply abstracted away. Let's dive into each of the four parameters.

The Details
ENDPOINT SLUGS
string
required
The name of the endpoint you want to make a request to. For a complete list of available endpoints, do IdeaMelt.listEndPoints() in the console or see them all here.
OPTIONS
object
required
Put all the parameters you want to send to the request right here. Each endpoint requires a different set of parameters so be sure to check them out in the docs. Or do IdeaMelt.listEndPointParameters(ENDPOINT) in the console to see what you need for a specific endpoint.
SUCCESS(response)
function
optional
Since all requests are made asynchronously, you'll want to do something with the data that comes back from the servers - this is where you attach the callback. It takes the response object as the one and only arguement, so be sure to include it! Go here for general information on what the response object looks like. For detailed information on additional stuff each endpoint sends back, check out the endpoint itself. Check out the example function below!
var success = function(response) {
    console.log(response);
}
FAIL(response)
function
optional
If something goes wrong, this function will be executed by the library. Again, this is totally asynchronous, so it's completely non-blocking. This also takes the response object as the one and only arguement, so make sure you include it! Go here for general information on what the response object looks like. In most cases, you'll probably want to update the UI and print out the message list sent by the serve in the console - check it out:
var fail = function(response) {
    console.log(response.message_list);
}
Endpoint Slugs

Use these slugs when sending requests using the library. Click on the description to learn more about each endpoint.

StoryCreatecreates a story
UserExistschecks to see if the user exists
UserCreatecreates a user
UserFollowcreates a follow relationship
UserFollowersgets all the followers of a user
UserFollowinggets a lits of all users the specified user is following
ObjectsFollowinggets a lits of all objects the user is following
IsFollowingUserchecks to see if a follow relationship exists between the users
IsFollowingObjectchecks to see if the user is following the object
NotifSendsends a notification
NotifSendToFollowerssends a notification to followers of a user
An Easy Example

This page already has the library setup and initialized. All you need to do is paste the code below into the console and you'll see the magic happen.

var options = {
    user_url: 'http://en.wikipedia.org/wiki/Barack_obama'
}
var success = function(response) {
    $.each(response.followers_list, function(index, item) {
        console.log(item.title);
    })
}
var fail = function(response) {
    console.error(response.message_list);
}
IdeaMelt.send('UserFollowers', options, success, fail);