Socket
Book a DemoInstallSign in
Socket

@nearest/nearest-sdk

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nearest/nearest-sdk

Node.js SDK for Nearest! services

0.3.7
latest
Source
npmnpm
Version published
Weekly downloads
9
800%
Maintainers
2
Weekly downloads
 
Created
Source

Nearest! JavaScript SDK npm version

Setup

Install the NPM Package by using

npm i @nearest/nearest-sdk -S

Now you can use the SDK by importing it. The code is isomophic ready.

Init SDK

import { NearestClient } from 'nearest-sdk';

const nearest = NearestClient({
  apiKey: 'your-api-public-key',
  app: 'your-appId',
});

The API

The API works with schema SDK.$topic.$action(options, [callback]). All methods return a Promise except callback is defined.

Methods

App

get (options, [callback])

Request parameters
ParameterDescription
lang: StringThe language code (de) for translations.

Nodes

get (options, [callback])

Request parameters
ParameterDescription
id: [String]!      Required: The node id (_id)
lang: StringThe language code (de) for translated content.

nearest (options, [callback])

Request parameters
ParameterDescription
lat: Float      A latitude for specifying a center point. Requires lng and radius.
lng: FloatA longitude for specifying a center point. Requires lat and radius.
radius: IntMax. distance in meters a node is located from the center. Refuires lat and lng.
lang: StringThe language code (de) for translated content.
limit: IntLimit amount of nodes.

getByBound (options, [callback])

Request parameters
ParameterDescription
bound: [[Float]]!   Required: Array of coordinates, representing a bounding box.
limit: Int    Limit amount of nodes. Default 10.

getByRegion (options, [callback])

Request parameters
ParameterDescription
regionId: [Int]!   Required: Array of regionIds (osm_ids)
limit: IntMax. amount of nodes. Default 10.

Stats

getStats (options, [callback])

Request parameters
ParameterDescription
regions: [Int]!Required: Ids of the region

getCountriesNodesAvailable (options, [callback])

Request parameters
ParameterDescription

getRegionsNodesAvailable (options, [callback])

Request parameters
ParameterDescription
region: Int!Required: Array of region ids (osm_id).

Regions

get (options, [callback])

Request parameters
ParameterDescription
id: [Int]!Required: Array of regionIds (osm_id)
lang: StringThe language code (de) for translated content.

getByPath (options, [callback])

Request parameters
ParameterDescription
path: String!Required: Path of a region (Germany/Berlin/Kreuzberg)
lang: StringThe language code (de) for translated content.

getByName (options, [callback])

Request parameters
ParameterDescription
name: String!Required: Name of a region (Bologna)
lang: StringThe language code (de) for translated content.

getByNameAndPoint (options, [callback])

Request parameters
ParameterDescription
name: String!Required: Name of a region (Bologna)
lat: Float!Required: Latitiude of a Point within a region
lng: Float!Required: Longitude of a Point within a region
lang: StringThe language code (de) for translated content.

Directions

get (options, [callback])

Request parameters
ParameterDescription
steps: [[Float]]!Required: The steps of a direction in lng,lat order. [[Lng,Lat],...,[Lng,Lat]]
mode: StringMode of the direction (car or foot)

Server

Information from the server. Could be used for testing.

  • info: Get info of Endpoint Server

server.version

SDK.server.info({}).then((serverInfo) => {
  const { version } = serverInfo;
  // do smth with it
}, (err) => {
  // work with the err
});

Keywords

Nearest

FAQs

Package last updated on 28 Jun 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.