Socket
Socket
Sign inDemoInstall

@lonelyplanet/open-planet-node

Package Overview
Dependencies
57
Maintainers
6
Versions
136
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @lonelyplanet/open-planet-node

Node.js client for the Open Planet API.


Version published
Weekly downloads
12
decreased by-69.23%
Maintainers
6
Install size
5.88 MB
Created
Weekly downloads
 

Readme

Source

Open Planet Node

Node.js client for the Open Planet API.

Create a client

Define a few ENV variables...

AUTH_CLIENT_ID=your-client-id
AUTH_HOST=http://connect.qa.lonelyplanet.com
OPENID_HOST=http://connect.qa.lonelyplanet.com
OPEN_PLANET_HOST=http://stable.web.op-api-gateway.qa.lonelyplanet.com

Create a client with...

import createClient from "@lonelyplanet/open-planet-node"

const client = createClient();

Docs

Generate docs with...

npm run docs

Endpoint Examples

User
client.user.find({
  username: "foo.user",
});
client.user.findById("1234");
Bookmark List
client.bookmarkList.findById(":listId");
client.bookmarkList.createList(":userId", { /** list attributes */ });

Filtering

Most endpoints support the following types of filtering...

client.user.find({
  key: "some value",
});
// ?filter[user][key][equals]=some%20value

client.poi.find({
  place_id: {
    has_ancestor: "362228",
  },
});
// ?filter[poi][place_id][has_ancestor]=362228

client.place.find({
  name: {
    like: "nashv",
  },
});
// ?filter[place][name][like]=nashv

Pagination

You can paginate by passing in the following...

client.user.find({
  limit: 10,
  offset: 2
});
// ?page[limit]=10&page[offset]=2

Disable include service caching

If you find yourself getting back cached things via ?include...

client.user.find({
  nocache: true,
});
// ?nocache=true

Pass extra query string arguments

To pass additional non-filter query string arguments, use extras...

client.user.find({
  name: "someusername",
  extras: {
    foo: "bar"
  }
});
// ?filter[user][name][equals]=someusername&foo=bar

Building

npm run build

npm run build -- --watch

Testing

npm run test

Dependency Injection with Inversify and Reflect-Metadata

Make sure to have the following code in the main entrypoint for an application, or included via CDN in the appliaction consuming this library.

import "reflect-metadata";

Open Planet Node uses https://github.com/inversify/InversifyJS for dependency injection whish is depednent upon Reflect.

FAQs

Last updated on 23 Dec 2019

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc