# Website contacts

> POST /website reads a site's public pages after robots.txt and returns the emails, phones and social profiles it publishes, with its name, logo and favicon.

`POST https://api.qelka.com/v1/website`

Get the contacts and brand of a company from its website: the emails, phone numbers and social profiles it publishes, and its name, logo, favicon and theme color. Each lookup costs 1 credit when the homepage could be read; sites that cannot be read, errors and test keys are never billed.

## Request

Send a domain or any URL of the site. Only the host is used: the path, query, port and credentials are dropped. The API reads `https://{host}/`, then `http://{host}/` when the HTTPS site does not answer; a URL that starts with `http://` is read over HTTP only.

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `url` | string | Yes | none | A domain (`example.com`) or a URL of the site, 1 to 2,048 characters. |
| `fresh` | boolean | No | `false` | `true` skips the 7-day result cache and reads the site again. |

Only public hosts are read. An IP address, `localhost`, or a host under `.local`, `.internal`, `.test`, `.invalid`, `.example`, `.home.arpa`, `.onion`, `.lan`, `.intranet` or `.corp` is a `422 unprocessable_input`. Redirects are followed only to public hosts, on ports 80 and 443, without credentials.

A lookup can make several requests to the site, each with a 6-second limit, so every snippet sets a 60-second client timeout.

```bash title="cURL"
curl https://api.qelka.com/v1/website \
  --max-time 60 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "mozilla.org"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/website', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ url: 'mozilla.org' }),
  signal: AbortSignal.timeout(60_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/website",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"url": "mozilla.org"},
    timeout=60,
)
result = response.json()
print(result)
```
```php title="PHP"
<?php
$ch = curl_init('https://api.qelka.com/v1/website');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('QELKA_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode(['url' => 'mozilla.org']),
    CURLOPT_TIMEOUT => 60,
]);
$result = json_decode(curl_exec($ch), true);
print_r($result);
```
```go title="Go"
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"time"
)

func main() {
	payload, _ := json.Marshal(map[string]any{"url": "mozilla.org"})
	request, _ := http.NewRequest(http.MethodPost, "https://api.qelka.com/v1/website", bytes.NewReader(payload))
	request.Header.Set("Authorization", "Bearer "+os.Getenv("QELKA_API_KEY"))
	request.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 60 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	var result map[string]any
	if err := json.NewDecoder(response.Body).Decode(&result); err != nil {
		panic(err)
	}
	fmt.Println(result)
}
```
```ruby title="Ruby"
require 'json'
require 'net/http'

uri = URI('https://api.qelka.com/v1/website')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{ENV.fetch('QELKA_API_KEY')}"
request['Content-Type'] = 'application/json'
request.body = JSON.generate({ url: 'mozilla.org' })

response = Net::HTTP.start(uri.host, uri.port, use_ssl: true, read_timeout: 60) do |http|
  http.request(request)
end
result = JSON.parse(response.body)
puts result
```

## Response

Every public host gets a `200`. Read `status` first: only `ok` means the homepage was read.

| Field | Type | Description |
|---|---|---|
| `id` | string | Identifier of this lookup: `lkp_` followed by 26 characters. |
| `object` | string | Always `website`. |
| `input` | string | The `url` you sent, without surrounding spaces. |
| `url` | string | The homepage that was requested: `https://{host}/` or `http://{host}/`. |
| `final_url` | string or null | The homepage after redirects. `null` when the homepage was not fetched. |
| `host` | string | Host of `final_url`, or of `url` when `final_url` is `null`. |
| `status` | string | `ok`, `robots_disallowed`, `unreachable`, `http_error` or `not_html`. |
| `http_status` | integer or null | HTTP status of the homepage. `null` when it was not fetched. |
| `pages` | array of objects | The pages read: the homepage, then the contact and about pages it links to. Empty unless `status` is `ok`. |
| `pages.url` | string | URL of the page, after redirects. |
| `pages.kind` | string | `home`, `contact` or `about`. |
| `pages.status` | integer | HTTP status of the page. |
| `name` | string or null | Company or site name: the `name` of Organization structured data (JSON-LD), else `og:site_name`, else `application-name`, else the part of the title that contains the domain name. |
| `title` | string or null | The title of the homepage, else `og:title` or `twitter:title`. |
| `description` | string or null | The meta description, else `og:description` or `twitter:description`. |
| `language` | string or null | The `lang` attribute of `html`, else the `content-language` or `og:locale` meta tag, as a BCP 47 tag such as `en-GB`. |
| `theme_color` | string or null | The `theme-color` meta tag, as written. |
| `favicon` | string or null | Absolute URL of the icon the homepage declares, `icon` links first, then SVG and larger sizes. `null` when none is declared. |
| `logo` | string or null | Absolute URL of the logo in the Organization structured data, else of the first image whose class, id, alt text or file name says logo. |
| `emails` | array of strings | Addresses from `mailto:` links, the visible text and the structured data of every page read, lower case, valid syntax only, at most 20. |
| `phones` | array of objects | Valid numbers from `tel:` links, numbers written with `+` in the text, and the structured data, at most 10. |
| `phones.e164` | string | The number in E.164 format. |
| `phones.country` | string or null | ISO 3166-1 alpha-2 code of the number. |
| `socials` | array of objects | Profile links of the pages read and of the structured data, at most 20. Share and intent links are skipped. |
| `socials.network` | string | `linkedin`, `x`, `facebook`, `instagram`, `youtube`, `tiktok`, `github`, `pinterest`, `threads`, `bluesky`, `telegram` or `discord`. |
| `socials.url` | string | The profile URL. |
| `socials.handle` | string or null | The handle read from the URL. |
| `technologies` | array of objects | Software named by `generator` meta tags. Nothing is guessed from scripts or markup. |
| `technologies.name` | string | Software name, such as `WordPress`. |
| `technologies.version` | string or null | Version, when the tag gives one. |
| `credits_used` | integer | Credits debited for this call: 1 when `status` is `ok` with a live key, else `0`. |
| `cached` | boolean | `true` when the answer came from the 7-day cache. |

```json title="Response"
{
  "id": "lkp_01M87667DG10WJTD4J4JF2T4DH",
  "object": "website",
  "input": "mozilla.org",
  "url": "https://mozilla.org/",
  "final_url": "https://www.mozilla.org/en-US/",
  "host": "www.mozilla.org",
  "status": "ok",
  "http_status": 200,
  "pages": [
    { "url": "https://www.mozilla.org/en-US/", "kind": "home", "status": 200 },
    { "url": "https://www.mozilla.org/en-US/contact/", "kind": "contact", "status": 200 },
    { "url": "https://www.mozilla.org/en-US/about/", "kind": "about", "status": 200 }
  ],
  "name": "Mozilla",
  "title": "Mozilla - Internet for people, not profit (US)",
  "description": "We’re working to put control of the internet back in the hands of the people using it.",
  "language": "en",
  "theme_color": null,
  "favicon": "https://www.mozilla.org/media/img/favicons/mozilla/favicon-196x196.e143075360ea.png",
  "logo": "https://www.mozilla.org/media/img/logos/m24/lockup-black.f2ddba3f0724.svg",
  "emails": ["trademark-permissions@mozilla.com"],
  "phones": [],
  "socials": [
    { "network": "bluesky", "url": "https://bsky.app/profile/mozilla.org", "handle": "mozilla.org" },
    { "network": "instagram", "url": "https://www.instagram.com/mozilla", "handle": "mozilla" },
    { "network": "linkedin", "url": "https://www.linkedin.com/company/mozilla-corporation", "handle": "mozilla-corporation" },
    { "network": "tiktok", "url": "https://www.tiktok.com/@mozilla", "handle": "@mozilla" },
    { "network": "bluesky", "url": "https://bsky.app/profile/firefox.com", "handle": "firefox.com" },
    { "network": "instagram", "url": "https://www.instagram.com/firefox", "handle": "firefox" },
    { "network": "youtube", "url": "https://www.youtube.com/user/firefoxchannel", "handle": "firefoxchannel" },
    { "network": "tiktok", "url": "https://www.tiktok.com/@firefox", "handle": "@firefox" },
    { "network": "facebook", "url": "https://www.facebook.com/mozilla", "handle": "mozilla" }
  ],
  "technologies": [],
  "credits_used": 1,
  "cached": false
}
```

## Act on the status

| `status` | What it means | What to do | Billed |
|---|---|---|---|
| `ok` | The homepage was read. | Use the contact and brand fields. An empty array means the pages read publish none. | Yes, and cached 7 days |
| `robots_disallowed` | robots.txt disallows the homepage, or answered a server error, which [RFC 9309](https://www.rfc-editor.org/rfc/rfc9309) treats as a full disallow; or a redirect led to a private host or to a disallowed page. Nothing else is read. | Respect it: the site does not want automated reads. | No |
| `unreachable` | Neither HTTPS nor HTTP answered within the timeout, or the site redirected more than 5 times. | Check the address, or try again later. | No |
| `http_error` | The homepage answered a 4xx or 5xx status, given in `http_status`. | Try again later for a 5xx; check the address for a 4xx. | No |
| `not_html` | The homepage is not an HTML page. | Check that the address points to a website. | No |

Answers other than `ok` are never cached, so the next request reads the site again.

## How the site is read

1. robots.txt is read at `{scheme}://{host}/robots.txt`, up to 512 kB. The rules of the group for the `Qelka` user agent apply, else those of `*`; the longest matching rule wins, and `Allow` wins a tie. A missing robots.txt (any 4xx) allows everything.
2. The homepage is fetched with the User-Agent `Qelka-API/1.0 (+https://qelka.com; support@qelka.com)`, following up to 5 redirects to public hosts. Each request has a 6-second timeout, and each page is cut at 1,500 kB.
3. Comments, scripts, styles, templates, SVG, iframes and embedded objects are removed from the HTML; nothing is run. JSON-LD structured data is read as data.
4. The first link to a contact page (`/contact`, `/contact-us`, `/kontakt`, `/impressum` and the like) and the first link to an about page (`/about`, `/company`, `/a-propos` and the like) on the same site are followed, when robots.txt allows them.
5. Phone numbers are parsed with the engine of the [phone API](https://qelka.com/docs/api-reference/phone), with the region of the page language or the country domain as a hint for numbers written without `+`, and kept only when valid.

## What the API keeps

The API returns only what a website publishes on its public pages, such as a support address or a company profile, and never reads pages behind a login. The request log keeps only the host of the URL you sent. A published email address or phone number can belong to a person: use the contacts the way the site intends them to be used.

## Examples

### Pass a full URL

Any URL of the site works: the API keeps the host and reads the homepage. Test keys return a sample site without fetching anything. With a test key in `QELKA_API_KEY`, this request returns:

```bash title="cURL"
curl https://api.qelka.com/v1/website \
  --max-time 60 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/about?ref=ad"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/website', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ url: 'https://example.com/about?ref=ad' }),
  signal: AbortSignal.timeout(60_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/website",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"url": "https://example.com/about?ref=ad"},
    timeout=60,
)
result = response.json()
print(result)
```

```json title="Response"
{
  "id": "lkp_01M8714MBCYWG373X3SY947Q8G",
  "object": "website",
  "input": "https://example.com/about?ref=ad",
  "url": "https://example.com/",
  "final_url": "https://example.com/",
  "host": "example.com",
  "status": "ok",
  "http_status": 200,
  "pages": [
    { "url": "https://example.com/", "kind": "home", "status": 200 },
    { "url": "https://example.com/contact", "kind": "contact", "status": 200 }
  ],
  "name": "Example Company",
  "title": "Example Company | Simulated website",
  "description": "A simulated website result returned to test keys.",
  "language": "en-US",
  "theme_color": "#1a56db",
  "favicon": "https://example.com/favicon.svg",
  "logo": "https://example.com/logo.svg",
  "emails": ["hello@example.com"],
  "phones": [{ "e164": "+12015550123", "country": "US" }],
  "socials": [{ "network": "linkedin", "url": "https://www.linkedin.com/company/example", "handle": "example" }],
  "technologies": [{ "name": "WordPress", "version": "6.4.2" }],
  "credits_used": 0,
  "cached": false
}
```

## Errors

| Status | Type | When |
|---|---|---|
| 400 | [invalid_request](https://qelka.com/docs/errors#invalid_request) | `url` is missing, empty or longer than 2,048 characters, the body is not a JSON object, or it has a field the request table does not list |
| 401 | [invalid_api_key](https://qelka.com/docs/errors#invalid_api_key) | The key is missing, unknown or revoked |
| 402 | [insufficient_credits](https://qelka.com/docs/errors#insufficient_credits) | Your balance is less than 1 credit (live keys only) |
| 403 | [forbidden](https://qelka.com/docs/errors#forbidden) | The key is restricted to other endpoints |
| 405 | [invalid_request](https://qelka.com/docs/errors#invalid_request) | The method is not `POST` |
| 422 | [unprocessable_input](https://qelka.com/docs/errors#unprocessable_input) | `url` is not a website address, or its host is not public: an IP address, `localhost` or a private suffix |
| 429 | [rate_limited](https://qelka.com/docs/errors#rate_limited) | Too many requests: wait `Retry-After` seconds |
| 500 | [internal_error](https://qelka.com/docs/errors#internal_error) | Unexpected error on our side: retry with backoff |

No error is billed. A site that cannot be read is not an error: it is a `200` with a `status` other than `ok` and `credits_used: 0`.

## Related

- [Website contacts API](https://qelka.com/products/website-contacts)
- Free tool: [website contact finder](https://qelka.com/tools/website-contact-finder)
- [Batch](https://qelka.com/docs/api-reference/batch): up to 100 sites in one call, each item with `type: "website"`
- [Bulk](https://qelka.com/docs/api-reference/bulk): a whole column of domains with `type=website`
- [Caching](https://qelka.com/docs/caching), [Errors](https://qelka.com/docs/errors), [Test mode](https://qelka.com/docs/test-mode)
