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

# JavaScript and TypeScript

> Install the JavaScript and TypeScript SDK, scrape a webpage, and retrieve brand data.

The [JavaScript and TypeScript SDK](https://github.com/context-dot-dev/context-typescript-sdk) supports current Node.js LTS releases. This example uses an ES module; the same SDK calls work in TypeScript.

## Install the SDK

```bash theme={null}
npm install context.dev
```

## Set your API key

Get a secret API key from the [dashboard](https://context.dev/dashboard). Set it in the terminal where you will run the example:

```bash theme={null}
export CONTEXT_DEV_API_KEY="ctxt_secret_..."
```

Keep the key in server-side code. Do not expose it in a browser or commit it to source control.

## Scrape a webpage

Save this as `scrape.mjs`:

```javascript scrape.mjs theme={null}
import ContextDev from "context.dev";

const client = new ContextDev({
  apiKey: process.env.CONTEXT_DEV_API_KEY,
});

const response = await client.web.webScrapeMd({
  url: "https://example.com",
  useMainContentOnly: true,
});

console.log(response.markdown);
```

Run it from the same directory:

```bash theme={null}
node scrape.mjs
```

<Accordion title="Run the example in TypeScript">
  Save the same example as `scrape.mts`. Install `tsx` as a development dependency, then run it:

  ```bash theme={null}
  npm install --save-dev tsx
  npx tsx scrape.mts
  ```
</Accordion>

## Check the result

The example prints the page content as Markdown. Look for the `Example Domain` heading; the remaining text and formatting may vary.

```markdown Expected heading theme={null}
# Example Domain
```

If you receive an error, check the key and request details in [Troubleshooting](/optimization/troubleshooting). See the [Markdown API reference](/api-reference/web-scraping/markdown) for all parameters and response fields.

## Retrieve brand data

Replace the request and final `console.log` with this lookup. It prints the matched company name.

```typescript theme={null}
const response = await client.brand.retrieve({
  type: "by_domain",
  domain: "stripe.com",
});

console.log(response.brand.title);
```

## Next steps

<CardGroup cols={2}>
  <Card title="Scrape a webpage" icon="globe" href="/guides/scrape-websites-to-markdown">
    Choose which page content to include.
  </Card>

  <Card title="Retrieve brand data" icon="palette" href="/guides/get-brand-data">
    Look up profiles with other company identifiers.
  </Card>
</CardGroup>
