# Context

Bijection component for calling the Context.dev API from Bijection functions.

- Package: @bijectionhq/context
- Category: AI & Agents
- Status: Preview
- License: MIT
- Bijection source (repository access required): https://github.com/bijectionhq/context/tree/66af2f57cff6d1df606baf696c0813363231f774
- Upstream: https://github.com/context-dot-dev/convex-component/tree/49e396c1410fe0da5f8f1c77939f5b36af699d08
- Documentation: https://docs.bijection.com/components/using
- Directory: https://bijection.com/components/context

## Get the source

Bijection repository access is required. Request access at https://bijection.com/contact.

```sh
git clone https://github.com/bijectionhq/context.git
cd context
git checkout 66af2f57cff6d1df606baf696c0813363231f774
```

## Before using this component

Read the package README at the recorded revision for setup, dependencies, and API examples. Upstream documentation describes the original package and may differ from the Bijection adaptation. This is a source candidate for evaluation. Catalog inclusion does not establish npm availability or runtime qualification. Check compatibility with your SDK and deployment before adoption. External providers run their own compute.

## Upstream package documentation

Recorded 2026-10-23. This describes @context-dot-dev/convex; check the Bijection adaptation separately.

Context.dev is a Convex component that wraps the Context.dev REST API, exposing it through typed Convex actions. It provides capabilities for web scraping, site crawling, structured data extraction, brand and logo lookup, and web search without requiring you to build or maintain scrapers. The component does not persist data in Convex; caching is handled by the Context.dev API via parameters like `maxAgeMs`.

### Use cases

- Fetching a company's brand assets, logo, and metadata by domain or email without scraping the web yourself
- Extracting structured data from arbitrary URLs using a schema you define, replacing ad-hoc HTML parsing
- Running web searches or AI queries against a domain from within a Convex action as part of a data enrichment pipeline
- Crawling a site to collect content for RAG ingestion or content indexing workflows
- Classifying businesses by NAICS industry code from free-form input in a backend action

### How it works

After installing the package and registering it in your `convex.config.ts` with `app.use(contextDev, { env: { CONTEXT_DEV_API_KEY } })`, the component's actions become available under `components.contextDev`. All calls happen inside Convex actions, since the component makes outbound HTTP requests to the Context.dev API.

You can call the component two ways. The raw action groups like `components.contextDev.brand.retrieve` or `components.contextDev.web.scrapeMarkdown` can be invoked via `ctx.runAction`. Alternatively, instantiate the typed helper client with `new ContextDev(components.contextDev)` and call methods like `contextDev.scrapeMarkdown(ctx, { params: { url } })` or `contextDev.extract(ctx, { body: { url, schema } })` with full TypeScript types derived from the Context.dev OpenAPI spec.

GET endpoints accept a `params` object; POST endpoints accept a `body` object and optionally `params` for query parameters. The component validates both input arguments and API responses at runtime using Convex validators before returning data to your function.

For testing, the package exports `contextDevTest.register(t)` for use with `convex-test`, which mounts the component in test environments without duplicating component internals.

### Upstream README

# Context.dev Convex Component

Use the Context.dev API from Convex actions through an isolated Convex component.

This package is generated against `openapispec.json` and exposes thin wrappers for the Context.dev REST API. It does not persist data in Convex; Context.dev caching behavior is controlled through the API parameters such as `maxAgeMs`.

## Install

```sh
npm install @context-dot-dev/convex
```

Add the component to your Convex app:

```ts
import contextDev from "@context-dot-dev/convex/convex.config";
import { defineApp } from "convex/server";
import { v } from "convex/values";

const app = defineApp({
  env: {
    CONTEXT_DEV_API_KEY: v.string(),
  },
});

app.use(contextDev, {
  env: {
    CONTEXT_DEV_API_KEY: app.env.CONTEXT_DEV_API_KEY,
  },
});

export default app;
```

Set `CONTEXT_DEV_API_KEY` on the Convex deployment, then run:

```sh
npx convex dev
```

## Usage

You can call the component API directly from Convex actions:

```ts
import { v } from "convex/values";

import { components } from "./_generated/api.js";
import { action } from "./_generated/server.js";

export const brand = action({
  args: { domain: v.string() },
  handler: async (ctx, args) => {
    return await ctx.runAction(components.contextDev.brand.retrieve, {
      params: { domain: args.domain },
    });
  },
});
```

Or use the typed helper client:

```ts
import { ContextDev } from "@context-dot-dev/convex";
import { v } from "convex/values";

import { components } from "./_generated/api.js";
import { action } from "./_generated/server.js";

const contextDev = new ContextDev(components.contextDev);

export const scrape = action({
  args: { url: v.string() },
  handler: async (ctx, args) => {
    return await contextDev.scrapeMarkdown(ctx, {
      params: { url: args.url },
    });
  },
});
```

## API Shape

GET endpoints take `params`; POST endpoints take `body` and may also take `params` if the OpenAPI operation defines query parameters.

The helper client types `params`, `body`, and returned data from `openapispec.json`:

- `contextDev.retrieveBrand(ctx, { params: { domain } })`
- `contextDev.retrieveBrandByName(ctx, { params: { company_name } })`
- `contextDev.retrieveBrandByEmail(ctx, { params: { email } })`
- `contextDev.identifyBrandFromTransaction(ctx, { params: { transaction_info } })`
- `contextDev.scrapeMarkdown(ctx, { params: { url } })`
- `contextDev.crawl(ctx, { body: { url, maxPages } })`
- `contextDev.extract(ctx, { body: { url, schema } })`
- `contextDev.search(ctx, { body: { query } })`
- `contextDev.aiQuery(ctx, { body: { domain, data_to_extract } })`
- `contextDev.extractProducts(ctx, { body: { domain } })`
- `contextDev.retrieveNaics(ctx, { params: { input } })`

The component actions also validate their runtime argument shapes with Convex validators. For example, `components.contextDev.web.scrapeMarkdown` requires `params.url`, while `components.contextDev.web.search` requires `body.query`. API responses are validated as JSON objects before they are returned to your Convex function.

Raw component action groups are available under:

- `components.contextDev.brand`
- `components.contextDev.web`
- `components.contextDev.ai`
- `components.contextDev.industry`
- `components.contextDev.people`

## Testing

The package includes a `convex-test` registration helper so app tests can mount the component without duplicating component internals:

```ts
import { convexTest } from "convex-test";
import { describe, expect, it } from "vitest";

import schema from "./schema.js";
import { api } from "./_generated/api.js";
import contextDevTest from "@context-dot-dev/convex/test";

describe("Context.dev usage", () => {
  it("registers the Context.dev component", async () => {
    const t = convexTest(schema);
    contextDevTest.register(t);

    // Call your app functions that use components.contextDev here.
    // await t.action(api.myModule.myAction, { domain: "context.dev" });
  });
});
```

The test entrypoint also exports `schema` and `modules` for tests that need to customize component registration.

## Development

```sh
npm install
npm run build
npm run typecheck
```

`npm run build` regenerates TypeScript types from `openapispec.json` and compiles the package.

After configuring a real Convex deployment, run `npm run codegen` to refresh the component generated files from Convex itself.