bearni95 / spotify-web-api-node

Fork of spotify-web-api-node to prevent error 429 - Too many requests

Home Page:https://github.com/thelinmichael/spotify-web-api-node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spotify Web API Node - Performance Optimizations

This is a fork from the Spotify Web API Node

The fork was made to implement a solution to the common Web Api Error 429 - Too many requests using superagent (Spotify Web API Node's HTTP client) plugins.

The first lines in src/http-manager.js have changed from:

'use strict';

var superagent = require('superagent'),
    WebApiError = require('./webapi-error');

var HttpManager = {};

To:

'use strict';

var superagent = require('superagent'),
    WebApiError = require('./webapi-error');

require('superagent-cache')(superagent);

var Throttle = require('superagent-throttle');
var throttle = new Throttle({
    active: true,     // set false to pause queue
    rate: 10,          // how many requests can be sent every `ratePer`
    ratePer: 1000,   // number of ms in which `rate` requests may be sent
    concurrent: 2    // how many requests can be sent concurrently
})

var HttpManager = {};

The superagent-cache plugin was implemented to minimize the network usage of redundant requests.

The superagent-throttle plugin takes care of spacing the HTTP requests. The shown settings are the ones we found adequate for our project but feel free to alter them to match your porpuses.

About

Fork of spotify-web-api-node to prevent error 429 - Too many requests

https://github.com/thelinmichael/spotify-web-api-node

License:MIT License


Languages

Language:JavaScript 100.0%