Code Monkey home page Code Monkey logo

trustspot's Introduction

trustspot

Node.js library for trustspot.io API

Works in Node.js 8 and above.

Install

npm i trustspot

Find your API key

Go to your Account Settings and find the key there.

Create API client instance

import Trustspot from "trustspot";
// or
const Trustspot = require("trustspot");

In Node.js 18 and above:

const trustspot = Trustspot({ key: MY_KEY });

In Node.js 16 and below:

const trustspot = Trustspot({ key: MY_KEY, fetch: require("node-fetch") });

Fetch data

getCompanyReviews({limit=10, offset=0, sort='date desc'})

  • limit - number
  • offset - number
  • sort - string, one of: 'date desc', 'rating desc', 'rating asc'
const reviews = await trustspot.getCompanyReviews({ offset: 12 });
console.log(reviews);

Will print something like this:

{
  error: '',
  company_name: 'Acme Inc',
  review_count: '49',
  average_rating: 4.8,
  limit: 10,
  offset: 12,
  sort: 'date desc',
  company_reviews: [{
    reviewID: '959582',
    fullname: 'Alex Alex',
    rating: '5',
    recommend: '10',
    comments: 'Quick and easy. Great and responsive customer service. They answered any questions I had in a timely manner.',
    date: '2017-10-24',
    response: null,
    response_date: null
  }, {
...SNIP ...
  }, {
    reviewID: '957945',
    fullname: 'Angus Jalex',
    rating: '5',
    recommend: '10',
    comments: 'I\'ve used a lot. Everything just works like you designed it just for yourself.',
    date: '2017-10-10',
    response: 'Thanks Angus for your feedback. We're appreciating your comments and hope to see you again soon.',
    response_date: '2017-10-10'
  }]
}

Changing the baseUrl

If your API is running not on the default domain here is how to use this module against a different URL.

const Trustspot = require("trustspot").props({
  baseUrl: "localhost:8081",
});

const trustspot = Trustspot({ key: MY_KEY });

Hardcode the key

If you don't want to pass the API key every time you can set the default API key for all object instances.

const Trustspot = require("trustspot").props({ key: MY_KEY });

const trustspot = Trustspot(); // No need to pass the key any more!

Contributing

This is an Open Open Source. Whoever submits a meaningful PR gets the write access.

trustspot's People

Contributors

koresar avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.