Getting Started
Overview
Welcome to the Salesbricks GraphQL API – the gateway to seamless access and management of your subscriptions and orders.
Our API offers a robust, introspectable schema, empowering you to effortlessly explore and interact with its extensive capabilities.
Before you begin, ensure you have read the Authentication guide to find your X-SALESBRICKS-KEY
and the correct endpoint for your use case.
Setting up an Apollo Client
In this guide, we leverage Apollo Client, extending the example from their documentation here.
JavaScript
import { ApolloClient, createHttpLink, InMemoryCache } from '@apollo/client';
import { setContext } from '@apollo/client/link/context';
// discovered using the Authentication guide
const SALESBRICKS_API_ENDPOINT = 'https://api.salesbricks.com/api/v1/graphql';
const SALESBRICKS_API_TOKEN = '00000000-0000-0000-0000-000000000000';
const httpLink = createHttpLink({
uri: SALESBRICKS_API_ENDPOINT,
});
const authLink = setContext((_, { headers }) => {
return {
headers: {
...headers,
'X-SALESBRICKS-KEY': SALESBRICKS_API_TOKEN
}
}
});
const client = new ApolloClient({
link: authLink.concat(httpLink),
cache: new InMemoryCache()
});
Query the schema
Once your client is configured, make queries following the defined schema.
Below is an example query to retrieve all orders:
Example Query
JavaScript
client
.query({
query: gql`
query {
companyOrders {
orders {
id
buyer {
id
name
}
}
}
}
`,
})
.then((result) => console.log(result));
Example Response
JSON
{
"data": {
"companyOrders": {
"orders": [
{
"id": "00000000-0000-0000-0000-000000000000",
"buyer": {
"id": "00000000-0000-0000-0000-000000000000",
"name": "Buyer Name"
},
}
]
}
}
}
Explore the powerful features of Salesbricks through this concise GraphQL API.
Let’s dive in! 🚀