Documentation Index
Fetch the complete documentation index at: https://docs.metabind.ai/llms.txt
Use this file to discover all available pages before exploring further.
API keys provide read-only access to published Metabind content for your client applications. This guide covers common usage patterns.
Include the API key in the x-api-key header for all requests:
curl -X GET "https://api.metabind.ai/api/v1/organizations/org123/projects/proj123/content" \
-H "x-api-key: YOUR_API_KEY"
Tags help categorize content and enable filtering in your application.
const discoverTags = async (apiKey) => {
const response = await fetch(
'https://api.metabind.ai/api/v1/organizations/org123/projects/proj123/tags',
{
headers: {
'x-api-key': apiKey
}
}
);
const tags = await response.json();
// Use tags to build filters in your app
return tags.data.map(tag => ({
id: tag.id,
name: tag.name,
slug: tag.slug
}));
};
Executing Saved Searches
Saved searches provide pre-configured queries that return consistent results.
const executeSavedSearch = async (apiKey, searchId, page = 1) => {
const response = await fetch(
`https://api.metabind.ai/api/v1/organizations/org123/projects/proj123/saved-searches/${searchId}/execute?page=${page}`,
{
method: 'POST',
headers: {
'x-api-key': apiKey
}
}
);
const results = await response.json();
// Results will only include published content
return results;
};
Fetching Content Types
Understand the content structure before rendering.
const getContentTypes = async (apiKey) => {
const response = await fetch(
'https://api.metabind.ai/api/v1/organizations/org123/projects/proj123/content-types',
{
headers: {
'x-api-key': apiKey
}
}
);
const types = await response.json();
// Use content type information to properly render content
return types.data.filter(type => type.status === 'published');
};
Fetching Resolved Content
Get content with all dependencies resolved for rendering.
const getResolvedContent = async (apiKey, contentId) => {
const response = await fetch(
`https://api.metabind.ai/api/v1/organizations/org123/projects/proj123/content/${contentId}/resolved`,
{
headers: {
'x-api-key': apiKey
}
}
);
const content = await response.json();
// content includes compiled code, assets, and all dependencies
return content;
};
Subscribing to Real-time Updates
Receive notifications when published content changes.
const subscribeToUpdates = (apiKey) => {
const eventSource = new EventSource(
'https://api.metabind.ai/api/v1/organizations/org123/projects/proj123/events',
{
headers: {
'x-api-key': apiKey
}
}
);
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
// Only published resources will be included
console.log('Published resource updated:', data);
// Update your app's cached content
if (data.resource.type === 'content' && data.event === 'update') {
refreshContent(data.resource.id);
}
};
return eventSource;
};
iOS Integration
import Foundation
class MetabindClient {
let apiKey: String
let baseURL = "https://api.metabind.ai/api/v1"
init(apiKey: String) {
self.apiKey = apiKey
}
func fetchContent(orgId: String, projectId: String) async throws -> [Content] {
var request = URLRequest(url: URL(string: "\(baseURL)/organizations/\(orgId)/projects/\(projectId)/content")!)
request.setValue(apiKey, forHTTPHeaderField: "x-api-key")
let (data, _) = try await URLSession.shared.data(for: request)
let response = try JSONDecoder().decode(ContentResponse.self, from: data)
return response.data
}
}
Android Integration
import io.ktor.client.*
import io.ktor.client.request.*
class MetabindClient(private val apiKey: String) {
private val baseUrl = "https://api.metabind.ai/api/v1"
private val client = HttpClient()
suspend fun fetchContent(orgId: String, projectId: String): List<Content> {
val response = client.get("$baseUrl/organizations/$orgId/projects/$projectId/content") {
header("x-api-key", apiKey)
}
return response.body<ContentResponse>().data
}
}
React Integration
import { useQuery } from '@tanstack/react-query';
const API_KEY = process.env.REACT_APP_METABIND_API_KEY;
const BASE_URL = 'https://api.metabind.ai/api/v1';
const fetchContent = async (orgId, projectId) => {
const response = await fetch(
`${BASE_URL}/organizations/${orgId}/projects/${projectId}/content`,
{
headers: { 'x-api-key': API_KEY }
}
);
return response.json();
};
function ContentList({ orgId, projectId }) {
const { data, isLoading, error } = useQuery({
queryKey: ['content', orgId, projectId],
queryFn: () => fetchContent(orgId, projectId)
});
if (isLoading) return <div>Loading...</div>;
if (error) return <div>Error loading content</div>;
return (
<ul>
{data.data.map(item => (
<li key={item.id}>{item.name}</li>
))}
</ul>
);
}
Best Practices
-
Store keys securely: Never commit API keys to source control. Use environment variables or secure key management.
-
Use separate keys per platform: Create dedicated keys for iOS, Android, and web applications for better tracking and security.
-
Monitor usage: Check the
lastUsed field to identify unused keys that can be revoked.
-
Rotate keys periodically: Create new keys and migrate applications before revoking old ones.
-
Handle errors gracefully: API keys can be revoked at any time. Implement proper error handling for 401 responses.