> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trynia.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Grep package source

> Regex search over public package source code (npm, PyPI, crates.io, Go modules).



## OpenAPI

````yaml /openapi-docs.yaml post /packages/grep
openapi: 3.1.0
info:
  title: Nia AI API
  version: 1.1.0
  description: >-
    Nia AI API provides a single, consistent `sources` resource for all indexed
    content.


    ## Core Resources


    **Sources** (`/sources`)

    - `repository`

    - `documentation`

    - `research_paper`

    - `huggingface_dataset`

    - `local_folder`


    **Search** (`/search`)

    - `mode`: query | web | deep | universal


    Legacy endpoints are deprecated and will be removed in a future version.
    Prefer `/sources` and `/search` for new integrations.
servers:
  - url: https://apigcp.trynia.ai/v2
    description: Production API
  - url: http://localhost:8000/v2
    description: Local development
security:
  - ApiKeyAuth: []
tags:
  - name: Auth
    description: API-first signup, login, and API key bootstrapping
  - name: Sources
    description: >-
      Unified source management (repositories, documentation, papers, datasets,
      local folders)
  - name: Search
    description: Unified search endpoint with mode discriminator
  - name: Context Sharing
    description: Cross-agent context management and retrieval
  - name: Categories
    description: Category management for organizing indexed sources
  - name: GitHub Search
    description: Live GitHub search and repository exploration
  - name: Advisor
    description: Context-aware code advisor against indexed documentation
  - name: Dependencies
    description: Dependency analysis and documentation subscription
  - name: Usage
    description: Usage tracking and bulk operations
paths:
  /packages/grep:
    post:
      tags:
        - Usage
      summary: Grep package source
      description: >-
        Regex search over public package source code (npm, PyPI, crates.io, Go
        modules).
      operationId: package_search_grep_v2_v2_packages_grep_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PackageSearchGrepRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    PackageSearchGrepRequest:
      properties:
        registry:
          type: string
          title: Registry
          description: 'Registry: crates_io, golang_proxy, npm, py_pi, or ruby_gems'
        package_name:
          type: string
          title: Package Name
          description: Package name
        pattern:
          type: string
          title: Pattern
          description: Regex pattern to search
        version:
          anyOf:
            - type: string
            - type: 'null'
          title: Version
          description: Package version
        language:
          anyOf:
            - type: string
            - type: 'null'
          title: Language
          description: Language filter
        filename_sha256:
          anyOf:
            - type: string
            - type: 'null'
          title: Filename Sha256
          description: File SHA256 filter
        a:
          anyOf:
            - type: integer
            - type: 'null'
          title: A
          description: Lines after match
        b:
          anyOf:
            - type: integer
            - type: 'null'
          title: B
          description: Lines before match
        c:
          anyOf:
            - type: integer
            - type: 'null'
          title: C
          description: Lines before and after match
        head_limit:
          anyOf:
            - type: integer
            - type: 'null'
          title: Head Limit
          description: Limit results
        output_mode:
          type: string
          title: Output Mode
          description: 'Output mode: content, files_with_matches, or count'
          default: content
      type: object
      required:
        - registry
        - package_name
        - pattern
      title: PackageSearchGrepRequest
      description: Request model for package grep search
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key must be provided in the Authorization header

````