Overview

Our search and chat APIs are available via GraphQL or REST protocols.

The GraphQL API provides an interactive playground and multi-language type safety. The REST API acts as a native, feature-equivalent proxy of the GraphQL API. Contact us for preview documentation of the REST API.

You can use whichever version you prefer for your application. Our APIs can be called from client-side public apps or backend services.

To quickly start testing the API, try our API playground.

GraphQL Clients

Using a GraphQL client gives you the benefits of a better developer experience by handling things like:

  • Type safety
  • Caching
  • Error handling
  • Query batching
  • …and more

Below is an example of how to use two popular GraphQL clients.

Apollo Client (for React browser-side apps)

Apollo Client is a popular GraphQL client for client-side JavaScript web-apps built on React. It also supports server-side rendering scenarios as documented here.

import { ApolloClient, InMemoryCache, gql } from "@apollo/client";

const apiKey: string = "<YOUR_INKEEP_API_KEY>";
const orgId: string = "<YOUR_ORG_ID>";
const integrationId: string = "<YOUR_INTEGRATION_ID>";

const client = new ApolloClient({
  uri: "https://api.inkeep.com/graphql",
  headers: {
    Authorization: `Bearer ${apiKey}`,
  },
  cache: new InMemoryCache(),
});

const MY_QUERY = gql`
  query MyQuery {
    search(
      searchInput: {
        searchQuery: "How do I get started?"
        organizationId: "${orgId}"
        integrationId: "${integrationId}"
        filters: {}
        searchMode: AUTO
      }
    ) {
      searchHits {
        id
        preview
        title
        url
      }
    }
  }
`;

client
  .query({
    query: MY_QUERY,
  })
  .then((result) => console.log(result))
  .catch((error) => console.error(`Apollo Client error: ${error}`));

URQL (for browser and server-side JavaScript apps)

URQL is a lightweight GraphQL client that is great for both client-side and server-side JavaScript apps.

import { createClient, gql } from "urql";

const apiKey: string = "<YOUR_INKEEP_API_KEY>";
const orgId: string = "<YOUR_ORG_ID>";
const integrationId: string = "<YOUR_INTEGRATION_ID>";

const client = createClient({
  url: "https://api.inkeep.com/graphql", // replace with your GraphQL API Endpoint
  fetchOptions: {
    headers: {
      Authorization: `Bearer ${apiKey}`,
    },
  },
});

const MY_QUERY = gql`
  query MyQuery {
    search(
      searchInput: {
        searchQuery: "How do I get started?"
        organizationId: "${orgId}"
        integrationId: "${integrationId}"
        filters: {}
        searchMode: AUTO
      }
    ) {
      searchHits {
        id
        preview
        title
        url
      }
    }
  }
`;

client
  .query(MY_QUERY)
  .toPromise()
  .then((result) => console.log(result.data))
  .catch((error) => console.error(`URQL Client error: ${error}`));