npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rapidapi-connect

v0.0.6

Published

Connect to blocks on the rapidapi.com marketplace

Downloads

2,332

Readme

Overview

RapidAPI is the world's first opensource API marketplace. It allows developers to discover and connect to the world's top APIs more easily and manage multiple API connections in one place.

Set-up:

First of all, download the npm module:

npm install rapidapi-connect --save

Then, require the package in your code:

const RapidAPI = require('rapidapi-connect');

Once required, the last step is to initialize the SDK with your project name and project API Key:

const rapid = new RapidAPI('PROJECT_NAME', 'API_KEY');

That's all, your SDK is set up! You can now use any block by copying the code snippet from the marketplace.

Usage:

To use any block in the marketplace, just copy it's code snippet and paste it in your code. For example, the following is the snippet fot the Delivery.sendSMS block:

rapid.call('Delivery', 'sendSMS', {
    message: 'Hello, connect!',
    to : '4158496404'
})
    .on('success', (payload) => {
        console.log('success');
    })
    .on('error', (err) => {
        console.warn(err);
    });

The following will call the Calculate.add block, and print the result:

rapid.call('Calculate', 'add', {
        num1: 11,
        num2 : 2
    })
    .on('success', (payload) => {
        console.log(payload);
    })
    .on('error', (err) => {
        console.warn(err);
    });

The printed result will be 13.

Notice that the error event will also be called if you make an invalid block call (for example - the package you refer to does not exist).

Files:

Whenever a block in RapidAPI requires a file, you can either pass a URL to the file or a read stream.

URL:

The following code will call the block MicrosoftComputerVision.analyzeImage with a URL of an image:

rapid.call('MicrosoftComputerVision', 'analyzeImage', {
    subscriptionKey : '############################',
    image : 'https://i.ytimg.com/vi/tntOCGkgt98/maxresdefault.jpg
})
    .on('success', (payload) => {
        console.log('S');
        console.log(payload);
    })
    .on ('error', (payload) => {
        console.log('E');
        console.log(payload);
    });

Read Stream

If the file is locally stored, you can read it using fs and pass the read stream to the block, like the following:

rapid.call('MicrosoftComputerVision', 'analyzeImage', {
    subscriptionKey : '############################',
    image : fs.createReadStream(__dirname + '/m.jpeg')
})
    .on('success', (payload) => {
        console.log('S');
        console.log(payload);
    })
    .on ('error', (payload) => {
        console.log('E');
        console.log(payload);
    });

RapidAPI uses the form-data library by @felixge to handle files, so please refer to it for more information.

Webhooks

After setting up the webhook, you can listen to real-time events via websockets like so:

rapid.listen('Slack', 'slashCommand', {token: 'YOUR_TOKEN_HERE', command: '/slash-command'})
    .on('join', msg => { console.log("join: ", msg); })
    .on('error', msg => { console.log("error: ", msg); })
    .on('message', payload => { console.log("message: ", payload); })
    .on('timeout', reason => { console.log("timeout: ", payload); })
    .on('close', reason => { console.log("close: ", reason); });

Issues:

As this is a pre-release version of the SDK, you may expirience bugs. Please report them in the issues section to let us know. You may use the intercom chat on rapidapi.com for support at any time.

Licence:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.