SDK Functions | Parallel Developer Documentation
Parallel Developer Documentation Legacy – v1.x
This is documentation for Parallel Developer Documentation Legacy – v1.x, which is no longer actively maintained.
For up-to-date documentation, see the latest version (Current – v2.x).
Version: Legacy – v1.x
The Parallel Javascript SDK includes the following functions on the Parallel object if you're including our JavaScript directly or via the NPM Module.
- React Module
- ES Module
- Manual Loading
import { useParallel } from '@parallelmarkets/react'
const ButtonBox = () => {
const { parallel } = useParallel()
// library may still be loading
if (!parallel) return null
// you can now call any of the functions below on the `parallel` variable
return <button onClick={() => parallel.login()}>Custom Parallel Button</button>
}
import { loadParallel } from '@parallelmarkets/vanilla'
const parallel = await loadParallel({
client_id: '123',
environment: 'demo',
flow_type: 'overlay',
})
// initiate a flow
parallel.login()
<script src="https://app.parallelmarkets.com/sdk/v1/parallel.js"></script>
<script>
Parallel.init({
client_id: '123',
environment: 'demo',
flow_type: 'overlay',
})
// initiate a flow
Parallel.login()
</script>
| Function | Description |
|---|---|
api(path, callback) |
Call any of the Parallel APIs, and define callback functions for handling the response. See this page for more information on calling Server APIs from JavaScript. |
getLoginStatus(callback) |
Get the login status of a user. It takes a single argument that is a callback function, which will be called once the user's login status can be determined. The callback function will be called with one argument described here. |
hideButton() |
Hide the Parallel Login button that was rendered inside any elements on the page with the class parallel-login-button. |
init(config) |
Initialize the Parallel Javascript SDK. Takes a single argument that is an object containing a client_id and any other desired configuration options. |
login(opts) |
Initiate a Parallel Markets user login flow explicitly. This is useful if you want to start a flow based on some user action (apart from clicking a Parallel Passport button). Takes a single optional argument that is an object. The following optional keys are supported: |
email: A user's email, used to pre-fill the signup page form.first_name: A user's first name, used to pre-fill the signup page form.last_name: A user's last name, used to pre-fill the signup page form.expected_entity_id: A connected entity ID that can be used to send a user directly into the desired flow(s) for the User or Business after authenticating, skipping the entity selection step.expected_entity_type: Eitherselfor abusiness_type. Providingselfwill initiate desired flows for the user as an individual (skipping the option to select a business). Abusiness_typecan be used to send a user directly to the creation page for a new Business after authenticating, with theexpected_entity_typepre-filled in the form.expected_business_name: The legal name of a Business. Used with the name of an existing Business to send a user directly into the desired flow(s) for the Business after authentication, skipping the entity selection step. Otherwise, used to send a user directly to the creation page for a new Business, with theexpected_business_nameprefilled in the form.handoff_id: A unique reference to this handoff which can be used in the Handoff API. Note: only the first 255 characters will be usedpartner_supporting: If data will be shared with any downstream organizations (e.g. Investment management platforms with many issuers), your client's name can be set here. This will update the messaging on the OAuth consent screen to indicate that the user is sharing data with your organization for the purposes of onboarding with your client. | |logout()| End the user's session on your site. Note that this will only invalidate the authentication tokens from the context of your site and will not affect the user's session (if any) on parallelmarkets.com. | |showButton()| Show the Parallel Login button inside any elements on the page with the classparallel-login-button. | |subscribe(event, callback)| Subscribe to a range of events by passing a string value which is the name of the event and defining a callback function for when the event fires. The callback will take in a response object containing any relevant status values, errors, authentication responses, etc. | |subscribeWithButton(callback, errback)| Show the Login button if user is not authenticated, and if/when user is authenticatedcallbackwill be called with one argument. On authentication issue or user cancelation,errbackwill be called. | |unsubscribe(event, callback)| Un-subscribe a callback from any events previously subscribed to usingsubscribe(). |