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

yasabe-api

v0.0.5

Published

Yasabe API node.js module

Downloads

5

Readme

About

A simple Node.JS wrapper around the YaSabe business directory API

Installation

yasabe-api is available through an installation from npm.

npm install yasabe-api

Usage

To use this library simply require the file and create a new instance of the module like so:

var Yasabe = require('yasabe-api');
var yasabe = new Yasabe(username, password);

Using Debug mode

The debug mode is set to false by default, when switched on the API parameters will be logged out along with the API call that is being called and the response.

yasabe.debugMode(true);

Using Test mode

Test mode is set to false by default, when switched on the module will use the YaSabe development environment to stop test data being added to the actual database.

yasabe.testMode(true);

Pulling records

The parameters for a search are as follows:


terms - fielded value to search for
where - location name (city, state, zipcode, (latitude, longitude))
distance - distance radius from center location
page - page number
size - number of items per page
sort - relevance, distance, buzz, authenticity, alpha, index, social, random


A basic example of use is:

var search_params = {
  terms: {
    phone: "7039554747",
    name: "Da Bizness"
  }
  where: "New York",
  radius: 5
}

yasabe.search(search_params, function(err, search_results) {

  console.log(err, search_results);

})

Adding records

Parameters for adding a record are as follows:


source - your content source identifier
externalid - the id you know this record as
businessMatches - one or more listing id corresponding to YaSabe record/s to be updated
businessContent - content to make available in YaSabe
additionalContent - free text content to make available in YaSabe


Additional parameters you should really be aware of:

// YaSabe accepted payment types
var payment_types = {
  1: "Cash",
  2: "Check",
  3: "Visa",
  4: "Master Card",
  5: "Discover",
  6: "American Express",
  7: "Diners",
  8: "Debit",
  9: "Paypal"
}

// YaSabe accepted languages
var Languages = {
  2: "English",
  3: "Spanish"
}

Basic example:

var yasabe_params = {
  externalid: "afoleyridealongs",
  businessMatches: [],
  source: "cops ride along directorate"
}

yasabe_params.businessContent = {
  language: [2],
  businessname: "Axel Foley",
  tagline: "Ride along with a cop",
  address1: "1154 Summit Dr",
  address2: "",
  city_text: "Beverly Hills",
  province: "Los Angeles",
  state: "CA",
  zipcode: "90210",
  showAddress: true,
  latitude: 34.0731,
  longitude: 118.3994,
  description: "Some text description",
  videoURL: "http://youtu.be/IqG1l4lScsg",
  facebook: "http://www.facebook.com/axel-foley",
  twitter: "http://www.twitter.com/axelf",
  phones: [
    {
      number: 7039554747,
      type: "Primary"
    }
  ],
  emails: [
    "[email protected]"
  ],
  urls: [
    "http://www.axels-super-adventures.com"
  ],
  cat: [
    {
      id: 228000000
    }
  ],
  tags: ["cops","ride along","drugs bust"]
}

yasabe_params.additionalContent = [
  {
    id: "images",
    type: "multimedia",
    items: [
      {
        type: "GALLERY",
        id: "http://imgur.com/GSdzQAx"
      },
      {
        type: "LOGO",
        id: "http://imgur.com/VWJvqVA"
      }
    ]
  },
  {
    id: "price-hours",
    type: "content",
    items: [
      {
        type: "price",
        english: "$$$",
        id: "display"
      },
      {
        type: "hours",
        english: "mon-fri 9am to 5pm",
        id: "display"
      },
    ]
  },
  {
    id: "user-generated-1",
    type: "review",
    items: [
      {
        type: "rating",
        english: "4.3",
        id: "display"
      },
      {
        type: "review",
        english: "Very nice place",
        id: "display"
      }
    ]
  }
]

yasabe.post(yasabe_params, function(err, data) {

  console.log(err, data);

})

Updating a record

Updating a record is just the same as post() but you must pass in the YaSabe id you wish to update in the businessMatches array. This ID can be attained by a simple search.

Deleting a record

Deleteing a record requires the basic parameters for adding or updating but nothing else. An example of this would be:

var yasabe_params = {
  externalid: "afoleyridealongs",
  businessMatches: ["id_of_YaSabe_record"],
  source: "cops ride along directorate"
}

yasabe.delete(yasabe_params, function(err, data) {

  console.log(err, data);

})

Third-party libraries

request
underscore