node-red-node-google 0.1.1

A set of Node-RED nodes to access various Google services

npm install node-red-node-google

Node-RED nodes to access various Google services, including calendar, directions, geocoding, places and google plus.

Install

Run the following command in the root directory of your Node-RED install

    npm install node-red-node-google

Pre-requisites

You must enable the Google APIs.

In the Google Developer Console under "Api & auth" select "APIs"

Search for "Directions API" click on it and then click "Enable API"

or see - https://code.google.com/apis/console

Usage

###Calendar in

Send a message every time an event occurs in a Google Calendar.

The message sent from the node will have properties:

  • title - the summary string from the calendar entry
  • description - the description from the calendar entry
  • location.description - the location string from the calendar entry
  • data - the raw event from the google calendar query as described in the event list API documentation
  • payload - an object containing:
    • title - the summary string from the calendar entry
    • description - the description from the calendar entry
    • location.description - the location string from the calendar entry
    • start - Javascript Date of start time - midnight for all day event
    • end - Javascript Date of end time - midnight for all day event
    • allDayEvent - true if event is an all day event
    • creator - object containing name and email properties
    • attendees - list of objects containing name and email properties

###Calendar query

Return the next event in a Google Calendar.

The incoming message can provide the following properties:

  • payload - a text search string used to select relevant events
  • calendar - the calendar to retrieve the event from (optional, defaults to the node calendar property or the users primary calendar)

The message sent from the node will have properties:

  • title - the summary string from the calendar entry
  • description - the description from the calendar entry
  • location.description - the location string from the calendar entry
  • data - the raw event from the google calendar query as described in the event list API documentation
  • payload - an object containing:
    • title - the summary string from the calendar entry
    • description - the description from the calendar entry
    • location.description - the location string from the calendar entry
    • start - Javascript Date of start time - midnight for all day event
    • end - Javascript Date of end time - midnight for all day event
    • allDayEvent - true if event is an all day event
    • creator - object containing name and email properties
    • attendees - list of objects containing name and email properties

###Calendar out

Create an entry in a Google Calendar.

The incoming message can provide the following properties:

  • payload - either a string to describe the event using quick add format or an object representing the request body for an insert request
  • calendar - the calendar to add the event to (optional, defaults to the node calendar property or the users primary calendar)
  • sendNotifications - a boolean to determine if notifications should be sent to attendees (optional, defaults to false)

###Directions

Utilizes the Google Direcions API to provide directions between the supplied origin and destination.

####Input Parameters:

Name - Name of the node

All of the following parameters can be supplied as part of the top level msg object.

msg.key - Your application's API key. This key identifies your application for purposes of quota management.

msg.origin - The address or textual latitude,longitude value from which you wish to calculate directions. If you pass an address as a string, the Directions service will geocode the string and convert it to a latitude,longitude coordinate to calculate directions. If you pass coordinates, ensure that no space exists between the latitude and longitude values.

msg.destination - The address or textual latitude,longitude value from which you wish to calculate directions. If you pass an address as a string, the Directions service will geocode the string and convert it to a latitude,longitude coordinate to calculate directions. If you pass coordinates, ensure that no space exists between the latitude and longitude values.

msg.mode - (Defaults to driving). Specifies the mode of transport to use when calculating directions. Valid values and other request details are specified in Travel Modes.

msg.waypoints - Specifies an array of waypoints. Waypoints alter a route by routing it through the specified location(s). A waypoint is specified as either a latitude,longitude coordinate or as an address which will be geocoded. Waypoints are only supported for driving, walking and bicycling directions. (For more information on waypoints, see Using Waypoints in Routes.)

msg.alternatives - If set to true, specifies that the Directions service may provide more than one route alternative in the response. Note that providing route alternatives may increase the response time from the server.

msg.avoid - Indicates that the calculated route(s) should avoid the indicated features. This parameter supports the following arguments:

  • tolls indicates that the calculated route should avoid toll roads/bridges.
  • highways indicates that the calculated route should avoid highways.
  • ferries indicates that the calculated route should avoid ferries.

msg.language - Specifies the language in which to return results. See the list of supported domain languages.

msg.units - Specifies the unit system to use when displaying results. Valid values are specified in Unit Systems.

msg.region - Specifies the region code, specified as a ccTLD ("top-level domain") two-character value. (For more information see Region Biasing.)

msg.departure_time - Specifies the desired time of departure. You can specify the time as an integer in seconds since midnight, January 1, 1970 UTC.

msg.arrival_time - pecifies the desired time of arrival for transit directions, in seconds since midnight, January 1, 1970 UTC. You can specify either departure_time or arrival_time, but not both.

msg.transit_mode - Specifies one or more preferred modes of transit. This parameter may only be specified for transit directions, and only if the request includes an API key or a Google Maps API for Work client ID. The parameter supports the following arguments:

  • bus indicates that the calculated route should prefer travel by bus.
  • subway indicates that the calculated route should prefer travel by subway.
  • train indicates that the calculated route should prefer travel by train.
  • tram indicates that the calculated route should prefer travel by tram and light rail.
  • rail indicates that the calculated route should prefer travel by train, tram, light rail, and subway. This is equivalent to transit_mode=train|tram|subway.

msg.transit_routing_preferences -

####Return values:

msg.status - Will either be 'OK' or provide an error state.

msg.distance - The distance of the trip, provided in meters

msg.duration - The duration of the trip, provided in seconds.

msg.location - Will contain to address objects, start and end, which will each contain a lon, lat, and address.

msg.payload -
{ routes: [ { copyrights, summary, bounds: { northeast:{ lat, lon }, southwest: { lat, lon } }, warnings: [], waypoint_order: [], fare: { currency, value }, legs: [ { distance: { value, text }, duration: { value, text }, duration_in_traffic: { value, text }, departure_time, arrival_time, start_location: { address, lat, lon }, end_location: { address, lat, lon }, steps: [ { distance:{ value, text }, duration:{ value, text }, start_location:{ lat, lon }, end_location:{ lat, lon }, html_instructions, maneuver, travel_mode, transit_details } ] }] } ], status }

For more information, please visit the Google Directions API Developer Docs ###Geocoding

Utilizes the Google Geocoding API to allow conversion of addresses to coordinate sets, and vice versa.

The node can be configured to send a geocode or reverse-geocode request by changing the geocodeBy parameter in the node.

####Input Parameters:

Name - Name of the node

Geocode by - Toggle to switch between a geocode and reverse-geocode request. Switching between the two will toggle the address and latitude,longitude inputs.

All of the following parameters can be supplied as part of the top level msg object.

msg.location.address - Address to be sent to Google in order to be converted to a set of coordinates. (Required if using Geocode by Address)

msg.location.lat - Latitude point to be sent to Google in order to be converted to a human-readable address. (Required if using Geocode by Coordinates)

msg.location.lon - Longitude point to be sent to Google in order to be converted to a human-readable address. (Required if using Geocode by Coordinates)

msg.key - Your application's API key. This key identifies your application for purposes of quota management.

msg.bounds - The bounding box of the viewport within which to bias geocode results more prominently. This parameter will only influence, not fully restrict, results from the geocoder.

msg.language - The language in which to return results.

msg.region - The region code, specified as a ccTLD ("top-level domain") two-character value. This parameter will only influence, not fully restrict, results from the geocoder.

msg.components - The component filters, separated by a pipe (|). Each component filter consists of a component:value pair and will fully restrict the results from the geocoder.

####Return values:

msg.status - Will either be 'OK' or provide an error state.

If msg.status returned 'OK':

msg.location - If provided with an address, msg.location will contain a lat and lon point. If provided with a lat/lon pair, msg.location will contain an address


Otherwise:

msg.error will contain a more detailed error message, if available

For more information, please visit the Google Geocoding API Developer Docs ###Places

Utilizes the Google Places API in order to find and learn more about local establishments.

The node can be configured to send three different types of Places requests by toggling the reqType parameter in the node.

###Google Places Nearby

####Input Parameters:

name - Name of the node

reqType - Toggle to switch between a Places Nearby, Places Text, and Places Details request.

All of the following parameters can be supplied as part of the top level msg object.

msg.key - Your application's API key. This key identifies your application for purposes of quota management. (Required)

msg.location.lat - Latitude point to be sent to Google in order to be converted to a human-readable address. (Required)

msg.location.lon - Longitude point to be sent to Google in order to be converted to a human-readable address. (Required)

msg.location.radius - Defines the distance (in meters) within which to return place results. The maximum allowed radius is 50000 meters. (Required if rankby=prominence. If rankby=distance, radius is not allowed)

msg.keyword - A term to be matched against all content that Google has indexed for this place, including but not limited to name, type, and address, as well as customer reviews and other third-party content.

msg.language - The language in which to return results.

msg.minprice - Restricts results to only those places within the specified price level. Valid values are in the range from 0 (most affordable) to 4 (most expensive), inclusive.

msg.maxprice - Restricts results to only those places within the specified price level. Valid values are in the range from 0 (most affordable) to 4 (most expensive), inclusive.

msg.name - The name of the business to search for.

msg.types - Restricts the results to places matching at least one of the specified types. Types should be separated with a pipe symbol (type1|type2|etc). (Click here for supported types)

msg.opennow - If set to true, will only return results that are currently open now.

####Return values:

msg.status - Will either be 'OK' or provide an error state.

If msg.status returned 'OK':

msg.location - Will contain lat, lon, and address

msg.placeid - A unique identifier for a place. To retrieve information about the place, pass this identifier in the placeId field of a Places API request.

msg.payload -
{
placeid - A unique identifier for a place. To retrieve information about the place, pass this identifier in the placeId field of a Places API request.
name - The name of the establishment
vicinity - Contains a feature name of a nearby location. Often this feature refers to a street or neighborhood within the given results.
types - Contains an array of feature types describing the given result
pricelevel - The price level of the place, on a scale of 0 to 4 (0-Free 1-Inexpensive 2-Moderate 3-Expensive 4-Very Expensive).
rating - Contains the place's rating, from 1.0 to 5.0, based on aggregated user reviews.
opennow - Boolean that shows whether the establishment is currently open.
}

Otherwise:

msg.error will contain a more detailed error message, if available

###Google Places Text

####Input Parameters:

name - Name of the node

reqType - Toggle to switch between a Places Nearby, Places Text, and Places Details request.

All of the following parameters can be supplied as part of the top level msg object.

msg.key - Your application's API key. This key identifies your application for purposes of quota management. (Required)

msg.query - The text string on which to search, for example: "restaurant". The Google Places service will return candidate matches based on this string and order the results based on their perceived relevance. (Required)

msg.location.lat - Latitude point to be sent to Google in order to be converted to a human-readable address.

msg.location.lon - Longitude point to be sent to Google in order to be converted to a human-readable address.

msg.location.radius - Defines the distance (in meters) within which to return place results. The maximum allowed radius is 50000 meters.

msg.keyword - A term to be matched against all content that Google has indexed for this place, including but not limited to name, type, and address, as well as customer reviews and other third-party content.

msg.language - The language in which to return results.

msg.minprice - Restricts results to only those places within the specified price level. Valid values are in the range from 0 (most affordable) to 4 (most expensive), inclusive.

msg.maxprice - Restricts results to only those places within the specified price level. Valid values are in the range from 0 (most affordable) to 4 (most expensive), inclusive.

msg.types - Restricts the results to places matching at least one of the specified types. Types should be separated with a pipe symbol (type1|type2|etc). (Click here for supported types)

msg.opennow - If set to true, will only return results that are currently open now.

####Return values:

msg.status - Will either be 'OK' or provide an error state.

If msg.status returned 'OK':

msg.title - The name of the establishment.

msg.location - Will contain lat, lon, and address

msg.placeid - A unique identifier for a place. To retrieve information about the place, pass this identifier in the placeId field of a Places API request.

msg.payload - Will contain the name and address of the result.

msg.detailsJson -
{
placeid - A unique identifier for a place. To retrieve information about the place, pass this identifier in the placeId field of a Places API request.
name - The name of the establishment
address - Human readable address of the establishment
types - Contains an array of feature types describing the given result
pricelevel - The price level of the place, on a scale of 0 to 4 (0-Free 1-Inexpensive 2-Moderate 3-Expensive 4-Very Expensive).
rating - Contains the place's rating, from 1.0 to 5.0, based on aggregated user reviews.
}

Otherwise:

msg.error will contain a more detailed error message, if available

###Google Places Details

####Input Parameters:

Name - Name of the node

reqType - Toggle to switch between a Places Nearby, Places Text, and Places Details request.

All of the following parameters can be supplied as part of the top level msg object.

msg.key - Your application's API key. This key identifies your application for purposes of quota management. (Required)

msg.placeid - A unique identifier that is returned from a Google Places request. (Required)

msg.language - The language in which to return results.

msg.extensions - Indicates if the Place Details response should include additional fields. Additional fields may include Premium data, requiring an additional license, or values that are not commonly requested. Extensions are currently experimental. Supported values for the extensions parameter are {review_summary}.

####Return values:

msg.status - Will either be 'OK' or provide an error state.

If msg.status returned 'OK':

msg.location - Will contain lat, lon, and address

msg.payload -
{
name - The name of the establishment
address - Human readable address of the establishment
phone - Locally formatted phone number for the establishment
website - The web address for the establishment
rating - Contains the place's rating, from 1.0 to 5.0, based on aggregated user reviews.
pricelevel - The price level of the place, on a scale of 0 to 4 (0-Free 1-Inexpensive 2-Moderate 3-Expensive 4-Very Expensive).
opennow - Boolean that shows whether the establishment is currently open.
open - Will return the day (0-6) and time (0000-2359) that the establishment is open.
close - Will return any day (0-6) that the establishment is closed.
permanently_closed - Will return true if the establishment is permanently closed.
}

Otherwise:

msg.error will contain a more detailed error message, if available

For more information, please visit the Google Geocoding API Developer Docs ###Plus

Interact with the Google+ API to get information about people, activities, and comments.

####Request Types:

People - Allows you to interact with Google+ profiles. You are able to get a particular profile, search for a profile, or gather a list of people that have +1'd or reshared an activity.

Activities - Allows you to interact with Google+ activities. You are able to get a particular activity, search for an activitiy, or gather a list of activities directly related to a person.

Comments - Allows you to interact with Google+ comments. You are able to get a particular comment, or gather a list of comments attached to an activity.


####Inputs:

User Id - The ID of the person to get the profile for. The special value "me" can be used to indicate the authenticated user.

Activity Id - The ID of the activity to get.

Comment Id - The ID of the comment to get.

Collection - The collection of activities to list. Acceptable values are: public: All public activities created by the specified user.

Language - Specify the preferred language to search with. See search language codes for available values.

Max Results - The maximum number of activities to include in the response, which is used for paging.

Sort Order - The order in which to sort the list of comments. Acceptable values are: ascending: Sort oldest comments first. (default); descending: Sort newest comments first.

Order by - Specifies how to order search results. Acceptable values are: best: Sort activities by relevance to the user, most relevant first; recent: Sort activities by published date, most recent first. (default)

Page Token - The continuation token, which is used to page through large result sets. To get the next page of results, set this parameter to the value of "nextPageToken" from the previous response.

Node Info

Version: 0.1.1
Updated 4 months ago
License: Apache-2.0

Downloads

16 in the last day
190 in the last week
1178 in the last month

Nodes

  • google plus
  • google places
  • google-credentials
  • google-api-config
  • google geocoding
  • google directions
  • google calendar in
  • google calendar
  • google calendar out

Keywords

  • node-red
  • google
  • calendar
  • directions
  • places
  • geocoding
  • google plus

Maintainers

  • knolleary
  • dceejay