Getting started
Our Javascript SDK makes it easy to connect to our GraphQL API and includes all the required dependencies you need.
This library provides Typescript support and works both browser and NodeJS environments.
1. Install the SDK 🔧
The first thing you will need to do is add the SDK to your dependencies:
- npm
- Yarn
npm install abowire
yarn add abowire
2. Initiate the SDK and authenticate 🔐
There are multiple ways of authenticating your requests to Abowire.
- Backend apps: You can provide your client credentials or specify your access token.
- Frontend apps: You can generate a session token scoped to a user in the backend and pass it to the frontend.
- Client credentials (Backend)
- Access Token (Backend)
- Session Token (Frontend)
If your connecting a backend application and have API Key pair, you can provide them to the SDK and it will authenticate your calls with them. The SDK authenticates you using the OAuth2 Client Credentials Grant.
info
You can create your backend client credentials by logging into Abowire and going to Settings > API Keys.
import { Abowire } from "abowire";
const abowire = Abowire({
clientId: "<client-id>",
secret: "<your-secret>",
scope: "openid profile full_access",
});
If your connecting a backend application and already issued an access token elsewere, you can provide it to the SDK and it will authenticate your calls with it.
info
Access tokens are issued using OAuth2 flow.
import { Abowire } from "abowire";
const abowire = Abowire({
accessToken: "<your-access-token>",
});
If your connecting a frontend application and already issued an session token, you can provide it to the SDK and it will authenticate your calls with it.
info
Session tokens have to be generated in the backend and are scoped to a particular customer.
import Abowire from "abowire";
const abowire = Abowire({
sessionToken: "<your-session-token>",
});
4. Ready for take off 🚀
You're now ready to make authenticated calls 😎
5. Make a query 🔎
import { Abowire, gql } from "abowire";
const abowire = Abowire({...});
// Define your own GraphQL query
const CUSTOMER_LIST = gql`
query {
customers {
items {
id
email
}
}
}
`;
(async () => {
const customers = await abowire.query(CUSTOMER_LIST);
console.log(customers);
})()
Next steps: Learn more about our GraphQL API!
Learn more about our GraphQL API and what available fields and operations are in our API Reference.
You can use our interactive GraphQL Playground to try out all the possibilities.
info
You will need to authenticate your playground calls. To do this, send an Authorization HTTP header with your access token:
{
"authorization": "Bearer <your-access-token>"
}