Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@http-samc/hyper

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@http-samc/hyper

A Javascript SDK for Hyper's API

latest
Source
npmnpm
Version
6.0.9
Version published
Maintainers
1
Created
Source

hyper.js

A Javascript SDK for Hyper's API

Installation

Node.js Projects

npm install @http-samc/hyper

Web Projects

Coming soon!

Usage

Client Initialization

The Hyper API Client is the default export and needs to be supplied to all calls. It validates and holds your API secret key and an (optional) logger function for development purposes. Import and initialize it as follows:

import { Client } from 'hyper'

const client = Hyper('my-hyper-secret-key')

API Calls

Besides the API Client, each 'category' of endpoints are able to be imported on an as-needed basis via named imports. These are provided as namespaces and their methods correspond to available API calls. You can import them as follows:

import { License, Link, Payment, Product, Waitlist } from 'hyper'

// Use the API by calling the methods of the imported namespaces
License.get(...)

If you want to call the namespaces something different, import them directly from their respective directory as follows (you can change the names as you wish):

import * as License from './license'
import * as Link from './link'
import * as Payment from './payment'
import * as Product from './product'
import * as Waitlist from './waitlist'

// Use the API by calling the methods of the imported namespaces
License.get(...)

API Responses

This library is asynchronous, meaning that you'll need to use either await or .then() to wait for a resolved value. All endpoints return a Promise that resolves to a HyperApiResponse. This object contains the response json as-is, straight from the server with the addition of an ok boolean property for easy error checking.

Some endpoints resolve to a HyperApiPaginatedResponse, a child of HyperApiResponse. This type of response adds an intuitive .next() and .previous property, which can be used to quickly navigate paginated endpoints. They return null once you reach a page that doesn't exist, so use the has_more property (supplied on all paginated endpoints) and make sure you aren't calling a page less than 1 before calling either method.

License

This library is open-sourced under an MIT license and was written by Samarth Chitgopekar. It is not officially recognized, endorsed, or maintained by Hyper.

Keywords

hyper

FAQs

Package last updated on 22 May 2022

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