0.3.7 • Published 7 years ago

@nearest/nearest-sdk v0.3.7

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

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
});
0.3.7

7 years ago

0.3.6

8 years ago

0.3.5

8 years ago

0.3.4

8 years ago

0.3.3

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago