Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
A light-weight promise-based REST client for accessing pokeapi.co, usable from node.js or in the browser (through the magic of browserify).
var PokeApi = require('pokeapi');
var api = PokeApi.v1();
api.get('pokemon', 1).then(function(bulbasaur) {
console.log("Here's Bulbasaur:", bulbasaur);
api.get(bulbasaur.moves).then(function(moves) {
console.log("Full move list:" + moves);
})
}, function(err) {
console.log('ERROR', err);
});
Resources can be fetched by supplying the resource name and the ID of the resource.
// returns a promise for a single object
api.get('pokemon', 1)
// the ID can also be a string
api.get('pokemon', '1')
// returns a promise for an array of objects
api.get('pokemon', '1,2,3,7-9')
You can also get resources by supplying an object with a
resource_uri
property, or an array of such objects:
// returns a promise for a single object
api.get({ resource_uri: '/api/v1/pokemon/1/' })
// returns a promise for an array of objects
api.get([
{ resource_uri: '/api/v1/pokemon/1/' },
{ resource_uri: '/api/v1/pokemon/2/' }
]);
This is particularly useful since all references to other objects will have this format, making it possible to do things like:
api.get('pokemon', 1).then(function(bulbasaur) {
console.log("Here's Bulbasaur:", bulbasaur);
api.get(bulbasaur.moves).then(function(moves) {
console.log("Full move list:" + moves);
})
});
You can run PokeApi in 'offline' mode, where data is read from locally stored data files rather than fetched from pokeapi.co on every request. This makes sense in cases when you're working with smaller sets of data that you don't expect to change a whole lot, i.e. move types. It's also very useful for working with data inside the browser without having to bother with setting up an AJAX proxy.
The data objects should have the same format as the output from
api.get()
(the CLI command is a good way to export the data). You
can specify muliple data files.
// assuming that types.json and moves.json exists
var types = require('./types');
var moves = require('./moves');
// creating a local client that can be queried for type and move data
var api = PokeApi.local(types, moves).v1();
PokeApi includes a simple CLI:
> npm install -g pokeapi
...
> pokeapi get type 1
{"created":"2013-11-02T12:08:58.787000","id":1,"ineffective":[{"name":"rock","resource_uri":"/api/v1/type/6/"},{"name":"steel","resource_uri":"/api/v1/type/9/"}],"modified":"
PokeApi can be run in the client using browserify. In order to query the pokeapi.co server you proably need to set up an AJAX proxy on your own. If you are running express this is pretty straightforward:
var express = require('express');
var request = require('request');
var app = express();
app.get('/api/*', function(req, res) {
request('http://pokeapi.co' + req.path).pipe(res);
});
When setting up the client you then need to tell it to connect to your own server instead of pokeapi.co:
var api = PokeApi.host('http://myhost').v1()
FAQs
A simple client for pokeapi.co
The npm package pokeapi receives a total of 0 weekly downloads. As such, pokeapi popularity was classified as not popular.
We found that pokeapi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.