@http-samc/hyper
v6.0.9
Published
A Javascript SDK for Hyper's API
Downloads
4
Readme
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.