Skip to content

feat: add TypeScript sample for Copilot Search API#290

Open
smita-MSFT wants to merge 4 commits intomicrosoft:mainfrom
smita-MSFT:feat/copilot-search-api-sample
Open

feat: add TypeScript sample for Copilot Search API#290
smita-MSFT wants to merge 4 commits intomicrosoft:mainfrom
smita-MSFT:feat/copilot-search-api-sample

Conversation

@smita-MSFT
Copy link
Copy Markdown

What

Adds a TypeScript sample demonstrating how to use the Microsoft Graph Search API for Microsoft 365 Copilot scenarios.

The sample exposes a local Express-based REST API that performs semantic + keyword search against Microsoft 365 content using /beta/search/query.


Features

  • Express REST API server — exposes endpoints for search operations
  • Microsoft Graph Search integration — calls /beta/search/query
  • Hybrid search support — semantic + lexical query handling
  • Path-based filtering — KQL-style path:"..." filtering
  • Configurable pagination — supports pageSize parameter
  • Azure AD authentication:
    • ClientSecretCredential (app-only)
    • DeviceCodeCredential (interactive login)
  • Structured JSON responses — normalized output with searchHits and skipToken
  • Environment-based configuration — .env driven credentials
  • TypeScript implementation — aligned with existing typescript/samples pattern
  • Clean project structure — src/ + dist/ build output

Path

typescript/samples/copilot-search-api/

How to Run

npm install
npm run build
npm start

Server runs at:

http://localhost:3000

Health check:

GET /health

Search endpoint:

POST /api/search

Testing

Manually tested locally:

  • TypeScript build successful (npm run build)
  • Server runtime verified (npm start)
  • /health endpoint validated
  • /api/search endpoint validated
  • Authentication verified with both credential types

@smita-MSFT
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Microsoft"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant