Skip to main content

Get Context

POST /api/v1/developer/get-context Retrieve context entries for SDK documentation, CLI commands, or API endpoints. This endpoint searches indexed services and returns relevant documentation, code examples, and usage guides based on your query.

Request

Headers

API-Key: your-api-key
Content-Type: application/json

Body Parameters

query
string
required
Free-text query to search and rank relevant context entries. Be specific about what you’re looking for (e.g., “how to make POST request”, “list S3 buckets”, “authentication example”).
index_id
string
required
The index_id from the list-indexes endpoint. This identifies which indexed service to query.

Example Request

curl -X POST \
  "https://www.goharvest.ai/api/v1/developer/get-context" \
  -H "API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "how to make authenticated POST request",
    "index_id": "scrape_123456"
  }'

Response

Success Response (200)

{
  "ok": true,
  "error": null,
  "data": {
    "context": "## Making POST Requests\n\nTo make a POST request with the requests library:\n\n```python\nimport requests\n\nurl = 'https://api.example.com/data'\ndata = {'key': 'value'}\nheaders = {'Authorization': 'Bearer token'}\n\nresponse = requests.post(url, json=data, headers=headers)\nprint(response.json())\n```\n\n### Authentication\n\nFor authenticated requests, include your API key in the headers:\n\n```python\nheaders = {\n    'Authorization': 'Bearer YOUR_API_KEY',\n    'Content-Type': 'application/json'\n}\n```"
  }
}
ok
boolean
Indicates if the request was successful
error
string | null
Error message if the request failed, null otherwise
data
object
Contains the response data

Query Best Practices

Write effective queries to get the most relevant context:
Good: “how to make authenticated POST request with JSON body”Less Good: “POST request”Include relevant details like authentication, data formats, or specific operations.
Good: “create S3 bucket with public access”, “list all running containers”Less Good: “S3 bucket”, “containers”Start with verbs that describe what you want to accomplish.
Good: “Python requests library timeout configuration”Less Good: “timeout”Mention the library, tool, or framework when relevant.
Good: “How do I handle pagination in REST API responses?”Less Good: “pagination”Phrase your query as a question or complete thought.

Error Responses

{
  "detail": "index_id is required",
  "status_code": 400
}
You must provide index_id in your request.
{
  "detail": "Index not found for the provided index_id",
  "status_code": 404
}
The specified index_id doesn’t exist. Use list-indexes to see available services.
{
  "detail": "API key missing",
  "status_code": 401
}
The API key is missing from request.
{
  "detail": "Invalid API key",
  "status_code": 401
}
The API key provided is invalid.
{
  "detail": "User account not found for user_account_id <user_account_id>",
  "status_code": 404
}
The user account associated with the API key doesn’t exist.
{
  "detail": "No API key found",
  "status_code": 404
}
There are no API keys created.

Use Cases

AI-Powered Code Assistants

Enhance your AI coding assistant with up-to-date library documentation and examples

Developer Tools

Build IDE extensions that provide contextual help based on the user’s current task

Documentation Chatbots

Create chatbots that answer developer questions with accurate, indexed documentation

Learning Platforms

Power educational platforms with dynamic, query-based code examples and tutorials

Best Practices

First List, Then Query: Always call list-indexes first to discover available services and get their index_id values.
Iterate Your Queries: If the returned context isn’t quite right, refine your query to be more specific or try different phrasing.
Context Size: The returned context is optimized for relevance but may be lengthy. Consider implementing pagination or truncation in your application if needed.

Next Steps

I