Impequid API
A JavaScript/Node.js API to easily interact with Impequid.
Works best with WebPack or Node.js.
default class ImpequidAPI ({token, server='impequid.com', port=443, secure=true, debug=false})
Completely Promise-based, making it easy to interact with it, especially using yield
and await
.
;const iqa = token;
The following API method examples assume the above code is present.
In addition to that, they also omit this:
;
If you want or need error handling, you should definitely not omit that code.
+ [none
]
verify iqa;
+ [user.id
, user.name
]
getUser Beware that usernames may change. If you want to store information about a user, store it using the userId
and impequidServer
.
Depending on your permissions you may get less information.
iqa;
+ [any:background
]
getBackgroundToken Fetch a background-access token from the server. This token can be used until the user revokes it and never gets IP-blocked.
The permission scope of a background-access token is completely separate from a client-access token.
For example: if you want to notify users about changes in the background, you should request the background.notify
permission.
Tip: You can easily spot a background token, because it begins with the letter d
, while the normal token begins with a n
.
iqa;
+ [none
]
get/set token Gets or sets the used token. Useful if you want to switch to a background-token or if you want to use one ImpequidAPI
instance for multiple users.
iqatoken = token;console;
+ [notify
]
notify (Object options) Sends a notification to the user.
iqa;
+ [none
]
getPermissions Retrieves all permissions associated to the token.
iqa;
+ [none
]
requestPermissions Allows you to request new permissions. If you set a permission to false
it will get disabled for your app.
The following example will request user.name
permissions for the normal and background tokens. It will also disable the background.notify
permission.
When requesting permissions, it's recommended to be as specific as possible, since you will otherwise get unnecessary permissions and users are more likely to decline your request.
iqa
+ [none
]
isBackground const isBackground = iqa;console
class ServiceProvider ({server='services.impequid.com', cacheDuration=60000, secure=true, port=443, debug=false})
;const isp = ;isp;