Skip to main content

Overview

The Search API uses consistent data models across all endpoints. All operations follow an asynchronous job-based workflow with standardized request and response formats.

SearchJobRequest

Request schema for creating a new search job.
interface SearchJobRequest {
  query: string;                      // Search query (required)
  design_standard?: string | null;    // Filter by standard: "us", "eurocode", "aus-nz", "canada"
  document_id?: string | null;        // Search within specific document
  page?: number;                      // Page number (default: 1)
  per_page?: number;                  // Results per page (default: 25, max: 100)
}

Field Details

query
string
required
Search query string (minimum 1 character)Supports:
  • Section numbers: "Section 10.5.3"
  • Code references: "AISC 360-16 G2.1"
  • Technical terms: "reinforcement requirements"
  • Natural language: "What are deflection limits for steel beams?"
"query": "load combinations for seismic design"
design_standard
string
Filter results by regional design standardValid values:
  • "us" - US standards (AISC, ACI, ASCE, etc.)
  • "eurocode" - European codes (EN 1992, etc.)
  • "aus-nz" - Australian/New Zealand (AS codes)
  • "canada" - Canadian codes (CSA)
"design_standard": "us"
document_id
string
Search within a specific document only
"document_id": "asce-7-22"
page
number
default:"1"
Page number for pagination (≥ 1)
"page": 2
per_page
number
default:"25"
Number of results per page (1-100)
"per_page": 50

JobResponse

Response when creating a job or checking its status.
interface JobResponse {
  job_id: string;                // Unique job identifier
  status: "pending" | "in_progress" | "completed" | "failed";
  created_at: string;            // ISO 8601 timestamp
  completed_at?: string | null;  // ISO 8601 timestamp when completed
  results?: SearchResults | null; // Only present when status is "completed"
  error?: ErrorDetails | null;   // Only present when status is "failed"
}

Status Values

StatusDescription
pendingJob queued, not yet started
in_progressSearch currently executing
completedSearch finished successfully
failedSearch encountered an error

Example (Pending)

{
  "job_id": "job_abc123xyz",
  "status": "pending",
  "created_at": "2025-10-17T10:30:00Z",
  "completed_at": null,
  "results": null
}

Example (Completed)

{
  "job_id": "job_abc123xyz",
  "status": "completed",
  "created_at": "2025-10-17T10:30:00Z",
  "completed_at": "2025-10-17T10:30:03.245Z",
  "results": {
    "total": 15,
    "page": 1,
    "per_page": 25,
    "total_pages": 1,
    "matches": [...]
  }
}

SearchResults

Search results with pagination information.
interface SearchResults {
  total: number;                 // Total number of matches
  page: number;                  // Current page number
  per_page: number;              // Results per page
  total_pages: number;           // Total number of pages
  matches: SearchMatch[];        // Array of search results
}

SearchMatch

Individual search result with context and metadata.
interface SearchMatch {
  file_id: string;               // Document identifier
  filename: string;              // Original filename
  description: string;           // Document description
  design_standard: string;       // Regional standard
  snippet: string;               // Matching text excerpt
  page_number: number;           // Page number in PDF
  relevance_score: number;       // Score 0.0 to 1.0
  context: string;               // Surrounding text for context
  content_type: "text" | "table" | "figure_caption";
}

Field Details

file_id
string
Unique document identifier
"asce-7-22"
filename
string
Original PDF filename
"ASCE_7-22.pdf"
description
string
Full document title and description
"ASCE 7-22: Minimum Design Loads and Associated Criteria for Buildings"
design_standard
string
Regional standard category
"us"
snippet
string
The most relevant text excerpt matching the query (typically 100-200 characters)
"...the deflection of structural members shall not exceed L/360 for roof members supporting..."
page_number
number
Page number in the original PDF document
142
relevance_score
number
Match quality score from 0.0 (poor) to 1.0 (excellent)
0.89
context
string
Larger block of surrounding text (400-600 characters) to provide additional context
"Section 10.5.3 - Deflection Limits. The deflection of structural members shall not exceed the following limits..."
content_type
string
Type of content matched
  • "text" - Body text
  • "table" - Content from a table
  • "figure_caption" - Figure or diagram caption
"text"

Complete Example Response

{
  "job_id": "job_abc123xyz",
  "status": "completed",
  "created_at": "2025-10-17T10:30:00Z",
  "completed_at": "2025-10-17T10:30:03.245Z",
  "results": {
    "total": 15,
    "page": 1,
    "per_page": 25,
    "total_pages": 1,
    "matches": [
      {
        "file_id": "asce-7-22",
        "filename": "ASCE_7-22.pdf",
        "description": "ASCE 7-22: Minimum Design Loads and Associated Criteria for Buildings and Other Structures",
        "design_standard": "us",
        "snippet": "...the deflection of structural members shall not exceed L/360 for roof members supporting plaster ceilings...",
        "page_number": 142,
        "relevance_score": 0.92,
        "context": "Section 10.5.3 - Deflection Limits. The deflection of structural members shall not exceed the following limits: (a) L/360 for roof members supporting plaster ceilings, (b) L/240 for roof members supporting nonplaster ceilings...",
        "content_type": "text"
      },
      {
        "file_id": "aisc-steel-manual-16th-2022",
        "filename": "AISC_Steel_Manual_16th.pdf",
        "description": "AISC Steel Construction Manual, 16th Edition",
        "design_standard": "us",
        "snippet": "Table 3-23: Recommended Deflection Limits for Steel Beams",
        "page_number": 87,
        "relevance_score": 0.88,
        "context": "Table 3-23 provides recommended maximum deflections for various structural applications. For roof beams supporting brittle finishes, L/360 is recommended...",
        "content_type": "table"
      }
    ]
  }
}

BuildingCode

Metadata for a building code document.
interface BuildingCode {
  file_id: string;               // Unique identifier
  filename: string;              // PDF filename
  description: string;           // Full title
  design_standard: string;       // Regional category
  path: string;                  // Internal storage path
  added_at: number;              // Unix timestamp
}

Example

{
  "file_id": "asce-7-22",
  "filename": "ASCE_7-22.pdf",
  "description": "ASCE 7-22: Minimum Design Loads and Associated Criteria for Buildings and Other Structures",
  "design_standard": "us",
  "path": "/processed_via_script_v2/ASCE_7-22.pdf",
  "added_at": 1756064601.5558982
}

CodesListResponse

Response when listing available building codes.
interface CodesListResponse {
  stru: BuildingCode[];          // Array of all available codes
}

Example

{
  "stru": [
    {
      "file_id": "aci-318-19",
      "filename": "ACI_318_19.pdf",
      "description": "ACI 318-19: Building Code Requirements for Structural Concrete",
      "design_standard": "us",
      "path": "/processed_via_script_v2/ACI_318_19.pdf",
      "added_at": 1756268806.1990368
    },
    {
      "file_id": "asce-7-22",
      "filename": "ASCE_7-22.pdf",
      "description": "ASCE 7-22: Minimum Design Loads and Associated Criteria for Buildings and Other Structures",
      "design_standard": "us",
      "path": "/processed_via_script_v2/ASCE_7-22.pdf",
      "added_at": 1756064601.5558982
    }
  ]
}

ErrorDetails

Error information when a job fails.
interface ErrorDetails {
  code: string;                  // Error code
  message: string;               // Human-readable message
  details?: any;                 // Additional error context
}

Example

{
  "code": "SEARCH_TIMEOUT",
  "message": "Search operation timed out after 30 seconds",
  "details": {
    "query": "very complex query...",
    "timeout_ms": 30000
  }
}

Common Error Codes

CodeHTTP StatusDescription
INVALID_QUERY400Query string is empty or invalid
INVALID_STANDARD400design_standard value is not recognized
INVALID_DOCUMENT404document_id does not exist
RATE_LIMIT_EXCEEDED429Too many requests in time window
SEARCH_TIMEOUT500Search operation exceeded time limit
INTERNAL_ERROR500Unexpected server error

Validation Rules

  • Required: Must be provided
  • Length: Minimum 1 character, maximum 500 characters
  • Type: Must be a string
  • Optional: Can be omitted for global search
  • Valid values: "us", "eurocode", "aus-nz", "canada"
  • Case-sensitive: Must use exact lowercase values
  • page: Must be ≥ 1
  • per_page: Must be 1-100
  • Maximum results: No single query can return more than 200 total results
  • Optional: Can be omitted
  • Format: Must match available file_id from codes list
  • Example: "asce-7-22", "aci-318-19"