Skip to main content

Get Context

POST /api/v1/developer/get-context Search across all indexed documentation to find relevant context for your query. This endpoint automatically searches all available indexed services (both public and your own) and returns relevant documentation chunks, code examples, and usage guides.

Request

Headers

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

Body Parameters

query
string
required
Search query to find relevant documentation and code examples. Include programming language, version, or framework name for better results (e.g., “Python requests POST with authentication”, “React useState hook examples”, “AWS S3 bucket creation”).
session_id
string
Optional session ID to track responses across multiple requests. When provided, this ID will be included in analytics tracking to help correlate related requests.

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": "Python requests library POST with authentication",
    "session_id": "user-session-123"
  }'

Response

Success Response (200)

{
  "ok": true,
  "error": null,
  "data": {
    "context": [
      {
        "content": "## 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```",
        "score": 0.92,
        "scrape_job_id": "scrape_123456",
        "entity_id": "entity_789",
        "document_id": "doc_abc123"
      },
      {
        "content": "### 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```",
        "score": 0.87,
        "scrape_job_id": "scrape_123456",
        "entity_id": "entity_790",
        "document_id": "doc_abc124"
      }
    ],
    "source": "harvest"
  }
}
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": "No subscription found for account",
  "status_code": 400
}
You need an active subscription to use this endpoint.
{
  "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.

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

Automatic Search: This endpoint automatically searches across all your available indexes (both public and your own), so you don’t need to specify which index to search.
Iterate Your Queries: If the returned chunks aren’t quite right, refine your query to be more specific or try different phrasing. Include programming language, version, or framework names for better results.
Process Multiple Chunks: The response returns an array of chunks ranked by relevance. Consider processing multiple chunks to get comprehensive context, or filter by score threshold for quality control.

Next Steps