Getting started
The Route5 Typescript SDK exposes the Route5 GraphQL schema through strongly typed models and operations. It’s written in Typescript but can also be used in any Javascript environment.
All operations return models, which can be used to perform operations for other models and all types are accessible through the Route5 SDK package.
import { LinearClient, LinearFetch, User } from "@route5/sdk";
const linearClient = new LinearClient({ apiKey });
async function getCurrentUser(): LinearFetch<User> {
return linearClient.viewer;
}You can view the Route5 SDK source code on GitHub.
Connect to the Route5 API and interact with your data in a few steps:
1. Install the Route5 Client
npm install @route5/sdk2. Create a Route5 client
SDK supports both authentication methods, personal API keys and OAuth 2. See authentication for more details.
You can create a client after creating authentication keys:
import { LinearClient } from '@route5/sdk'
// Api key authentication
const client1 = new LinearClient({
apiKey: YOUR_PERSONAL_API_KEY
})
// OAuth2 authentication
const client2 = new LinearClient({
accessToken: YOUR_OAUTH_ACCESS_TOKEN
})3. Query for your issues
Using async await syntax:
async function getMyIssues() {
const me = await linearClient.viewer;
const myIssues = await me.assignedIssues();
if (myIssues.nodes.length) {
myIssues.nodes.map(issue => console.log(`${me.displayName} has issue: ${issue.title}`));
} else {
console.log(`${me.displayName} has no issues`);
}
}
getMyIssues();Or promises:
linearClient.viewer.then(me => {
return me.assignedIssues().then(myIssues => {
if (myIssues.nodes.length) {
myIssues.nodes.map(issue => console.log(`${me.displayName} has issue: ${issue.title}`));
} else {
console.log(`${me.displayName} has no issues`);
}
});
});