API Keys
Alex Johnson avatar
Written by Alex Johnson
Updated over a week ago

Which of Vendr's products is this article applicable to?

Applicable

  • Vendr 2.0

Not Applicable

  • Freemium

  • Premium Intelligence

  • Premium Procurement

Vendr's API Reference Docs: https://developers.vendr.com/

Note: API Under Construction

Thank you for checking out our API. Please be aware that we are in early phases and rapidly iterating on our API and data model, and as a result, there may be some instability. We appreciate your patience and understanding as we work towards making our API more stable and reliable.

We value your feedback and encourage you to share your use cases with us so that we can provide guidance and support as needed. As we progress towards offering stable endpoints for our partners and customers, we will update our API documentation, help desk, and API key section to reflect these changes.

Should you have any questions or concerns, please do not hesitate to Contact Support. We appreciate your interest in our API and look forward to working with you.

Overview

The API Keys page is where you create an API Key, if you wish to access Vendr's API.

Vendr's API is built using GraphQL and allows you to interact with the data in your Vendr account.

To start using the API, you'll need two things:

  1. Create an API Key

  2. Use the API Key + API Reference Docs

Below, you'll find step-by-step directions for creating your API Key, as well more info about our API Reference Docs, GraphQL, and some tips & tricks you might find useful.

Create an API Key

Why do I need an API Key?

API keys allow you to access the official Vendr GraphQL API to interact with your Vendr data.

To safeguard your data, all requests to the Vendr API requires an authorization header containing an API key. This key is bound to a particular user-account in Vendr, and inherits the roles & permissions of that user.

Step 1

Login to your Vendr account as an Admin user; go to https://app.vendr.com/settings/api-keys.

Step 2

Click the "Create API Key" button.

Step 3

Enter a Name for your API Key (Description is optional); click "Create API Key".

Step 4

Click the little clipboard symbol to the right of your hidden API Key to copy your API Key.

Save it in a safe place (do not put it in version control) - we recommend putting it in an environment variable.

Then click "I've copied my API Key" to finish.

Archiving an API Key

If you ever need to archive an API key, it's as simple as:

  1. โ€‹

  2. Find the API Key you'd like to archive

  3. Click the three dots at the right of the screen

  4. Click "Archive"; confirm the action in the popup

Use the API Key + API Reference Docs

Step 1

Use your API Key to authenticate your requests by adding the authorization header to each request.

Here's an Example:

Save your API Key in an environment variable:

$ export VENDR_API_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjdXJpb3VzIjp0cnVlfQ.VZNthmIxc_7_iKQ7nzFEIt6q9j80rFrUygNBkSCR554
Use that variable in your API call - this example uses NodeJS and graphql-request to get the name of the user who created the API Key:
const { GraphQLClient, gql } = require("graphql-request")

const graphQLClient = new GraphQLClient("https://api.vendr.com/prod/graphql", {
headers: {
authorization: process.env.VENDR_API_KEY,
},
})

async function main() {
const query = gql`
{
user {
name
}
}
`
const data = await graphQLClient.request(query)
console.log(`Hello, ${data.user.name}`)
}

main().catch((error) => console.error(error))

Step 2

Use Vendr's API Reference Docs to build the requests you need.

They can be found at: https://developers.vendr.com/

โ€‹

Intro to GraphQL + Tips & Tricks

GraphQL Overview

Vendr's API is built using GraphQL.

GraphQL is a technology for building APIs that provides a well-typed schema describing all operations and data structures, and gives clients the ability to specify exactly the type of data they are looking for, as well as the shape of the returned data.

GraphQL.org provides a great Introduction to GraphQL which explains the various concepts and mechanics in detail.

Additionally, we strongly recommend the use of some great open source tools, such as Altair and GraphiQL to play with and explore GraphQL APIs.

Tips & Tricks

The main thing to understand here is that the entire application is API-driven; the UI is essentially just a front-end skin for the API.

This has two useful consequences:

  1. In your Vendr account, any action that can be taken (or any data that can be accessed) via the UI, can be taken or accessed via the API as well.

  2. If you'd like an example of what the query for any particular API call might want to look like, you can just...

    • open your Vendr account

    • right click and Inspect the page

    • look at the Network tab of the page inspection tool

    • take whatever action you want to replicate via API

    • and you'll see the actual GraphQL query that we use for that action

Did this answer your question?