Learn how to get started with the Senso API by creating your first content and performing a search query.
What You’ll Learn
This quickstart guide will walk you through:
- Setting up API authentication
- Creating your first content in the knowledge base
- Searching for answers using natural language queries
- Understanding the response structure
Prerequisites
Before you begin, make sure you have:
- A Senso API key
- Your preferred programming language environment set up
Creating Your First Content
const API_URL = 'https://sdk.senso.ai/api/v1';
const API_KEY = 'YOUR_API_KEY';
async function createFirstContent() {
try {
// Create your first content item
const contentResponse = await fetch(`${API_URL}/content/raw`, {
method: 'POST',
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({
title: 'Introduction to Senso',
summary: 'Learn about the Senso knowledge base platform',
text: `# Welcome to Senso
Senso is a powerful knowledge base platform that helps you:
- Organize and manage your content effectively
- Search through content using natural language
- Generate new content based on existing knowledge
- Build AI-powered applications with your data
## Key Features
### Smart Search
Find answers instantly with our AI-powered search that understands context and intent.
### Content Generation
Create new content automatically based on your existing knowledge base.
### Easy Integration
Simple REST API that works with any programming language or framework.`
})
});
const content = await contentResponse.json();
console.log('Content created successfully!');
console.log('Content ID:', content.id);
console.log('Processing status:', content.processing_status);
// Wait a moment for processing
await new Promise(resolve => setTimeout(resolve, 2000));
// Search for information
const searchResponse = await fetch(`${API_URL}/search`, {
method: 'POST',
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: 'What are the key features of Senso?',
max_results: 3
})
});
const searchResult = await searchResponse.json();
console.log('\nSearch Results:');
console.log('Answer:', searchResult.answer);
console.log('Sources used:', searchResult.results.length);
} catch (error) {
console.error('Error:', error);
}
}
createFirstContent();
Understanding the Response
When you create content, you’ll receive a response like this:
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": "raw",
"title": "Introduction to Senso",
"processing_status": "processing",
"created_at": "2024-01-15T10:30:00Z"
}
The search response will include:
{
"query": "What are the key features of Senso?",
"answer": "Senso has three key features: Smart Search for instant AI-powered answers, Content Generation for creating new content from existing knowledge, and Easy Integration with a simple REST API.",
"results": [
{
"content_id": "550e8400-e29b-41d4-a716-446655440000",
"chunk_text": "### Smart Search\nFind answers instantly...",
"score": 0.95
}
]
}
Best Practices
- Wait for processing: After creating content, allow a few seconds for the system to process and index it
- Use descriptive titles: Clear titles help with content organization and search relevance
- Structure your content: Use markdown formatting for better readability and parsing
- Keep content focused: Each content item should cover a specific topic or area
Next Steps
Now that you’ve created your first content and searched through it, you can: