Library

Installation

Browser

<script type="text/javascript" src="path/to/amper-tango.js"></script>

Node

const AmperTango = require('path/to/amper-tango.node');

NOTE: You must install the required dependencies by running npm install or yarn install with the provided package.json.

Usage

// instantiate
const amper_tango = new AmperTango({
    api_key: '<api-key>'
});

Events

// instantiate
const amper_tango = new AmperTango();

// success
amper_tango.on('success', (err, {data, _headers}) => {
    // fires on request success
});

// failure
amper_tango.on('failure', (err, {data, _headers}) => {
    // fires on request failure
});

// before
amper_tango.on('before', (opts) => {
    // fires before each request
    console.log(opts.id);      // id
    console.log(opts.request); // request
    console.log(opts.data);    // data
    console.log(opts.queue);   // count of queued requests
});

// after
amper_tango.on('after', (opts) => {
    // fires after each request
    console.log(opts.id);      // id
    console.log(opts.request); // request
    console.log(opts.data);    // data
    console.log(opts.queue);   // count of queued requests
});

Methods

post_simple_render

Post simple render

post_simple_render(opts, callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.post_simple_render({
    timeline: {...},
    preset: 'MASTER_WAV'
}, (err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.post_simple_render({
    timeline: {...},
    preset: 'MASTER_WAV'
}).then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

get_simple_render

Get simple render

get_simple_render(simple_render_id, callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.get_simple_render('1337', (err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.get_simple_render('1337').then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

poll_simple_render

Poll simple render

poll_simple_render(simple_render_id, opts, callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.poll_simple_render('1337', {
    timeout: 1000,
    onPoll: ({data}) => {
        console.log(data)
    }
}, (err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.poll_simple_render('1337', {
    timeout: 1000,
    onPoll: ({data}) => {
        console.log(data)
    }
}).then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

post_simple_composition

Post simple composition

post_simple_composition(opts, callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.post_simple_composition({
    timeline: {...}
}, (err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.post_simple_composition({
    timeline: {...}
}).then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

get_simple_composition

Get simple composition

get_simple_composition(simple_composition_id, callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.get_simple_composition('1337', (err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.get_simple_composition('1337').then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

poll_simple_composition

Poll simple composition

poll_simple_composition(simple_composition_id, opts, callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.poll_simple_composition('1337', {
    timeout: 1000,
    onPoll: ({data}) => {
        console.log(data)
    }
}, (err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.poll_simple_composition('1337', {
    timeout: 1000,
    onPoll: ({data}) => {
        console.log(data)
    }
}).then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

get_entity_band

Get entity band

get_entity_band(band_id, callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.get_entity_band('1337', (err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.get_entity_band('1337').then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

get_entity_bands

Get list of entity bands

get_entity_bands(callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.get_entity_bands((err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.get_entity_bands().then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

get_entity_descriptor

Get entity descriptor

get_entity_descriptor(descriptor_id, callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.get_entity_descriptor('1337', (err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.get_entity_descriptor('1337').then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

get_entity_descriptors

Get list of entity descriptors

get_entity_descriptors(callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.get_entity_descriptors((err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.get_entity_descriptors().then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

get_entity_hit

Get entity hit

get_entity_hit(hit_id, callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.get_entity_hit('1337', (err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.get_entity_hit('1337').then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

get_entity_hits

Get list of entity hits

get_entity_hits(callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.get_entity_hits((err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.get_entity_hits().then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

get_entity_instrument

Get entity instrument

get_entity_instrument(instrument_id, callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.get_entity_instrument('1337', (err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.get_entity_instrument('1337').then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

get_entity_instruments

Get list of entity instruments

get_entity_instruments(callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.get_entity_instruments((err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.get_entity_instruments().then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

get_entity_mood

Get entity mood

get_entity_mood(mood_id, callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.get_entity_mood('1337', (err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.get_entity_mood('1337').then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

get_entity_moods

Get list of entity moods

get_entity_moods(callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.get_entity_moods((err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.get_entity_moods().then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

get_entity_style

Get entity style

get_entity_style(style_id, callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.get_entity_style('1337', (err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.get_entity_style('1337').then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

get_entity_styles

Get list of entity styles

get_entity_styles(callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.get_entity_styles((err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.get_entity_styles().then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});

get_ping

Get ping

get_ping(callback)

Arguments

Example

const amper_tango = new AmperTango({
    api_key: '...'
});

amper_tango.get_ping((err, {data}) => {
    if (err) {
        console.error(err);

        return;
    }

    console.log(data);
});

// or using Promises

amper_tango.get_ping().then(({data}) => {
    console.log(data);
}).catch((err) => {
    console.error(err);
});