New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lonelyplanet/open-planet-node

Package Overview
Dependencies
Maintainers
6
Versions
136
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lonelyplanet/open-planet-node

Node.js client for the Open Planet API.

  • 2.46.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
154
decreased by-37.65%
Maintainers
6
Weekly downloads
 
Created
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

Package last updated on 23 Dec 2019

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

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc