Skip to main content

Quickstart

How to integrate the kapa.ai API into your developer-facing product

This getting started guide will walk you through the process of integrating the kapa.ai API into your developer-facing product. By the end of this guide, you will be able to ask questions, maintain conversation context, and provide feedback using the Query, Thread, and Feedback endpoints.

Step 1: Obtain an API token​

To start using the kapa.ai API, you need an API token for authentication. You can obtain an API token by reaching out the kapa.ai team and they will help you get set up.

Step 2: Ingest your knowledge sources​

kapa.ai supports various technical knowledge sources, including docs, chat histories, forums, blogs, codebases, and YouTube videos. Currently, the kapa.ai team will assist you in onboarding onto the platform and ingesting your sources. Once you reach out, the process typically takes 12-24 hours.

Step 3: Set up your project

Create a new project in your preferred programming language and install any necessary libraries for making HTTP requests. You may use libraries like requests for Python, axios for JavaScript, or http for Go.

Step 4: Make a Query request​

Construct an HTTP GET request to the Query endpoint with your API token and a sample question. Replace <KAPA_API_ENDPOINT> with the actual API endpoint and <KAPA_API_TOKEN> with your generated token.

curl -X GET \
'<KAPA_API_ENDPOINT>/query/v1?query=How+do+I+get+started?' \
-H 'X-API-TOKEN: <KAPA_API_TOKEN>'

In your application, use the appropriate method for making HTTP requests and parse the JSON response to extract the answer, thread_id, and question_answer_id.

Step 5: Make a Thread request​

To ask a follow-up question based on the context of the previous conversation, use the Thread endpoint. Replace <KAPA_API_ENDPOINT>, <KAPA_API_TOKEN>, and <THREAD_ID> with the appropriate values.

curl -X GET \
'<KAPA_API_ENDPOINT>/query/v1/thread/<THREAD_ID>?query=What+was+my+first+query' \
-H 'X-API-TOKEN: <KAPA_API_TOKEN>'

Again, parse the JSON response to extract the answer, thread_id, and question_answer_id for the new question-answer pair.

Step 6: Submit feedback using the Feedback endpoint​

To provide feedback on a specific question-answer pair, use the Feedback endpoint. Replace <KAPA_API_ENDPOINT>, <KAPA_API_TOKEN>, <KAPA_QUESTION_ANSWER_ID> <MY_REACTION>, and <MY_USER_IDENTIFIER> with the appropriate values.

curl -X POST \
'<KAPA_API_ENDPOINT>/query/v1/question-answer/{KAPA_QUESTION_ANSWER_ID}/feedback' \
-H 'X-API-TOKEN: <KAPA_API_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"reaction": <MY_REACTION>,
"user_identifier": <MY_USER_IDENTIFIER>
}'

Parse the JSON response to extract the total_upvotes and total_downvotes for the question-answer pair. This feedback will help kapa.ai improve its understanding and provide more accurate answers to developers.

By following this Getting Started guide, you can integrate kapa.ai into your developer-facing products to create a seamless support experience for your users. As you work with the API, remember to authenticate your requests using the X-API-TOKEN header and your generated API token. If you have any questions or need assistance, feel free to reach out to the kapa.ai team.