Exciting news!Announcing our $4.6M Series Seed. Learn more
Socket
LoveBlogFAQ
Install
Log in

@lonelyplanet/open-planet-node

Package Overview
Dependencies
6
Maintainers
6
Versions
136
Issues
File Explorer

Advanced tools

@lonelyplanet/open-planet-node

Node.js client for the Open Planet API.

    2.46.1latest

Version published
Maintainers
6
Yearly downloads
6,375
decreased by-27.24%

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.

Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc