
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
npm install anx-api
var Api = require('anx-api');
# Create a new instance with api target
var api = new Api({
target: 'https://api.appnexus.com'
token: 'SESSION_TOKEN' // (optional) see also api.login(...)
});
api.getJson(<serviceName>).then(function (res) {
...
}).catch(function (err) {
...
})
var api = new Api(config);
Authenticates with the API and returns a token to be used with future requests.
api.login('username', 'password').then(function (token) {
// The api object is now logged in. Optionally store the token.
...
})
Issues a GET request
api.get('service url')
api.get(opts) // see Request Options
Returns a promise that fulfills with the response from the api.
Usage and parameters are the same as #get. Response body is parsed as json.
** Experimental Feature **
Usage and parameters are the same as #getJson accept it pages through api calls. Response body is parsed as json.
Issues a POST request with a payload
api.post('service url', 'payload')
api.post(opts, { /* payload obj */ })
api.post(opts) // see Request Options
Returns a promise that fulfills with the response from the api.
Posts a json encoded object payload to the service url. Usage and parameters are the same as #post. Response body is parsed as json.
Issues a PUT request with a payload
api.put('service url', 'payload')
api.put(opts, { /* payload obj */ })
api.put(opts) // see Request Options
Returns a promise that fulfills with the response from the api.
Puts a json encoded object payload to the service url. Usage and parameters are the same as #put. Response body is parsed as json.
Issues a DELETE request
api.delete('service url')
api.delete(opts) // see Request Options
Returns a promise that fulfills with the response from the api.
Usage and parameters are the same as #delete. Response body is parsed as json.
api.switchUser(userId).then(...)
The get, post, put, and delete methods can be called with an opts object. The opts object has the following request options.
// Fetch the third page of 25 creatives
api.get({
uri: 'creative',
startElement: 50,
numElements: 25
})
The following are two different methods of modifying and or spying on requests made to the api.
api._config.request = _.wrap(api._config.request, function (request, opts) {
console.log('DEBUG: ', opts);
return request.call(api, opts);
});
var request = require('request');
function customRequest(opts) {
return new Promise(function (resolve, reject) {
// Customize the request
request(opts, function (err, res) {
if (err) {
// Add additional error handling
reject(err);
} else {
// Customize the response
resolve(res);
}
});
});
}
var api = new Api({
target: process.env.ANX_TARGET,
token: 'SESSION_TOKEN',
request: customRequest
});
Run the unit test suite from the project root, make sure you've run npm install
first:
npm test
Coming soon
See LICENSE file
FAQs
AppNexus Api Wrapper
The npm package anx-api receives a total of 674 weekly downloads. As such, anx-api popularity was classified as not popular.
We found that anx-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.