# 从电子邮箱地址提取名字和性别信号

> 从电子邮箱地址中提取候选名字，并用相应的预测结果和来源字段补充您在 Excel、Google Sheets 或 API 中的工作流，而不覆盖本人提供的信息。

Canonical HTML: https://www.genderapi.io/zh/blog/extract-names-from-email-addresses

Last reviewed: 2026-09-29

## 发布信息

首次发布：2025-06-14T12:00:00.000Z

最后审核：2026-09-29T00:00:00.000Z

## GenderAPI 能从电子邮箱地址中提取名字吗？

可以。对于受支持的个人邮箱，GenderAPI 可以从 @ 之前的部分提取候选名字，并返回性别信号、国家/地区上下文和置信度。这是一种推断，而不是身份验证；通用地址或随机地址可能没有结果。

- [V2 在线演示及其选项](https://www.genderapi.io/zh/blog/extract-names-from-email-addresses#demo)

## 分析电子邮箱地址

提交一个值，查看完整的响应，包括未知结果和已使用的积分。

始终使用 AI（默认）：2 个积分，即使结果未知也同样计费。回退：1 个积分，包括 AI 回退和未知结果。关闭，仅用数据集（不使用 AI）：每次完成的请求 1 个积分，包括未知结果。启用昵称解读时：数据集得出结果为 1 个积分，使用 AI 时总共 2 个积分，即使结果未知也同样计费。

提交的值（完整的电子邮箱地址）会发送给 GenderAPI.io；在默认的“始终使用 AI”模式下或需要 AI 回退时，还会转发给已配置的 AI 服务，“关闭”模式下则不会转发。[了解数据的处理方式](https://www.genderapi.io/zh/data-provenance)。

此真实响应获取于2026年10月1日，仅替换了账户余额。实时值可能不同。预测并不是经过确认的身份。

**真实 V2 响应，获取于2026年10月1日**

```json
{
  "data": {
    "input": {
      "type": "email",
      "value": "mei.lin@example.com",
      "country": null
    },
    "name": "mei",
    "gender": "female",
    "country": null,
    "confidence": 0.98,
    "confidence_kind": "model_reported",
    "sample_count": null,
    "source": "ai",
    "result_status": "identified",
    "reason": null,
    "country_source": null,
    "match": {
      "name": null,
      "method": "model_inference",
      "scope": null,
      "country": null
    }
  },
  "meta": {
    "request_id": "08e6c4c9-b167-4b58-8f10-68a7d885b73c",
    "duration_ms": 379,
    "access": {
      "mode": "api_key",
      "reason": null
    },
    "usage": {
      "charged_credits": 2,
      "remaining_credits": 49999,
      "billing_status": "confirmed",
      "resets_at": null,
      "limit": null,
      "period_seconds": null
    }
  }
}
```

- [创建账户](https://app.genderapi.io/user/register)

## 从电子邮箱地址到结构化数据

- 输入：emilyblack@email.com
- 提取：Emily
- 补充：性别 + 置信度

## 选择处理电子邮箱数据的位置

- [Microsoft Excel 安装插件 →](https://appsource.microsoft.com/en-us/product/office/WA200008555)
- [Google Sheets 打开 Marketplace →](https://workspace.google.com/marketplace/app/gender_api_determines_gender_of_name_or/712811575775)
- [Shopify 查看应用 →](https://apps.shopify.com/gender-api)
- [Excel / CSV 批量处理 打开文件工具 →](https://app.genderapi.io/csv)
- [Airtable 查看扩展 →](https://airtable.com/marketplace/blkqCasjQIqmmBrmb/gender-api-io-determine-gender)
- [REST API 查看端点 →](https://www.genderapi.io/zh/docs/v2/gender-from-email)

## 使用 Excel 插件处理电子邮箱地址列

选择电子邮箱地址的处理方法，然后映射来源列和结果字段。单元格中的动态查询可使用 GENDER.FROM_EMAIL，需要固定结果时可使用侧边栏。

- [观看 Excel 视频教程](https://youtu.be/6j4w-3oMZnA)
- [GenderAPI Excel 插件指南](https://www.genderapi.io/zh/blog/genderize-excel-names-using-genderapi-excel-add-in)
- [Excel GENDER 公式](https://www.genderapi.io/zh/blog/gender-formula-for-microsoft-excel)

## 使用插件或公式分析电子邮箱地址

现有行可使用插件处理，新行可使用兼容的工作流，单个单元格的查询可使用 GENDER 公式。

- [Google Sheets 插件指南](https://www.genderapi.io/zh/blog/%E5%A6%82%E4%BD%95%E5%9C%A8-google-sheets-%E4%B8%AD%E8%AF%86%E5%88%AB%E6%80%A7%E5%88%AB-%E4%BD%BF%E7%94%A8-gender-api-%E6%8F%92%E4%BB%B6)
- [Google Sheets GENDER 公式](https://www.genderapi.io/zh/blog/gender-gongshi-google-sheets-genju-xingming-shibie-xingbie)

## 将电子邮箱地址分析集成到您的后端

从服务器调用经过身份验证的电子邮箱地址端点，不要在浏览器或公开代码中暴露 API 密钥。请明确处理响应结构、错误代码和积分消耗。

此截图来自早期集成的结果，并不反映当前的 V2 响应约定。

- [单个电子邮箱地址的请求](https://www.genderapi.io/zh/docs/v2/gender-from-email)
- [多个电子邮箱地址的请求](https://www.genderapi.io/zh/docs/v2/batch)

## 地址中没有名字时，不要强行给出结果

功能性地址、随机标识符和共享邮箱并不总能提供可靠的信号。请保留 data.result_status、data.reason 和 data.confidence，并单独处理不确定的结果。

电子邮箱地址中的匹配不能确认邮箱持有人的身份或名字。请用您自己的数据衡量质量，不要仅凭这一预测对个人作出高影响的决定。

## 分别保存来源数据与预测结果

请保留原始记录标识符。API 不会打开任何个人资料，不会验证账户持有人，也不会确认任何人的身份。只有在掌握可靠信息时才发送国家/地区上下文，不要根据域名或网站语言推断。

数据集查询会分析 @ 之前的部分，去除以 + 开头的后缀，并评估候选名字。标准请求还可能从复合片段的前缀和后缀中补充有限数量的候选项。如果有多行匹配，会选择记录出现次数最多的一行；该候选项不一定是本人的真实名字。如果您发送了国家/地区，每个候选项会优先使用该国家/地区的行；没有该行时，可能使用全球行。请检查 data.match.scope 和 country_source。

| 记录 | 字段 | 解读 |
| --- | --- | --- |
| 来源记录 | contact_id / original_email | 在您自己的系统中保留来源数据，不要用预测结果覆盖本人提供的名字。这些不是 API 响应字段。 |
| 候选名字 | data.name / data.match | 选中的名字可能为 null。响应中没有经过验证的姓氏字段，匹配结果也不能证明邮箱持有人的身份。 |
| 预测 | data.gender / data.result_status / data.reason | 未知结果在 JSON 中记录为 null。数据集中出现平局的行可能只有候选名字而没有性别。 |
| 依据 | data.source / data.confidence_kind / data.confidence / data.sample_count | confidence 的取值范围为 0 到 1。数据集中的频率与 AI 评分是不同的度量；AI 结果的 sample_count 为 null。 |
| 操作记录 | meta.request_id / meta.usage | 保存请求 ID 和计费状态；响应丢失并不意味着该操作免费或失败。 |

### 选择处理模式与积分费用

单条请求默认使用 fallback；批量请求中的条目默认使用 off。forceToGenderize 对姓名、电子邮箱地址和用户名均为可选项；使用时请省略 ai_mode 或设置为 fallback，因为该选项不能与 off 或 always 组合。已完成的 unknown 结果同样计费。剩余余额为正数即可开始请求；操作完成后，余额可能变为负数。

使用 AI 时，AI 会收到您发送的完整地址，包括域名和 + 后缀，即使它被要求忽略这些部分。forceToGenderize 可能在没有找到真实名字的情况下给出性别；这并不意味着已为您的 CRM 提取出经过验证的名字。

| 选项 | 处理方式 | 每个完成条目的费用 |
| --- | --- | --- |
| options.ai_mode: off | 仅使用数据集 | 1 个积分 |
| options.ai_mode: fallback | 先查询数据集；无法确定性别时使用标准 AI 回退 | 包括 AI 在内共 1 个积分 |
| options.ai_mode: always | 直接使用 AI | 2 个积分 |
| forceToGenderize: true | 先查询数据集；之后解读昵称，不要求有真实名字 | 数据集足够时 1 个积分；使用 AI 时共 2 个积分 |

### 先测试一条仅使用数据集的电子邮箱请求

示例输入并不保证特定的预测结果。请在服务器环境中设置 GENDERAPI_API_KEY，不要把密钥放入公开的客户端代码。V1 和 V2 使用同一个账户 API 密钥和同一份余额。请通过 /api/v2/usage 检查密钥，并确认 meta.access.mode 的值为 api_key。

选择编程语言。[设置您的 API 密钥](https://www.genderapi.io/zh/docs/v2/authentication#environment-setup)，然后在您的服务器上运行示例。

每个预测请求（包括重试）都是一次新的计费操作。这些示例不会自动重试。发送下一个请求之前，请先检查计费状态。

### 运行之前：访问与错误处理

请在您的服务器上运行这些示例。在进程环境中将 GENDERAPI_API_KEY 设置为您现有的 API 密钥。请确认 meta.access.mode 为 api_key：无法识别的密钥可能会转为使用 IP 试用。

对于 HTTP 4xx 和 5xx JSON 响应，示例会保留错误响应体并以非零状态退出。重试前请检查 code、action 和 meta.usage.billing_status。

**cURL**

cURL 7.76+，在 POSIX shell 中运行。在终端中运行。[运行环境文档](https://curl.se/docs/manpage.html)

```bash
curl --silent --show-error --fail-with-body --max-time 30 \
  --request POST 'https://api.genderapi.io/api/v2/gender' \
  --header "Authorization: Bearer ${GENDERAPI_API_KEY:?Set GENDERAPI_API_KEY}" \
  --header 'Content-Type: application/json' \
  --data '{
  "type": "email",
  "value": "alice.smith@example.com",
  "options": {
    "ai_mode": "off"
  }
}'
```

**JavaScript / Node.js**

Node.js 22+；内置 fetch。保存为 example.mjs，然后运行 node example.mjs。[运行环境文档](https://nodejs.org/api/globals.html#fetch)

```javascript
// Server-side Node.js. Save as example.mjs.
const apiKey = process.env.GENDERAPI_API_KEY;
if (!apiKey) throw new Error("Set GENDERAPI_API_KEY");
const body = {
  "type": "email",
  "value": "alice.smith@example.com",
  "options": {
    "ai_mode": "off"
  }
};

const response = await fetch("https://api.genderapi.io/api/v2/gender", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(body),
  signal: AbortSignal.timeout(30_000),
  redirect: "error",
});
const raw = await response.text();
if (!(response.headers.get("content-type") ?? "").includes("json")) {
  throw new Error(`HTTP ${response.status}: expected JSON; request ID ${response.headers.get("x-request-id")}`);
}
const result = JSON.parse(raw); // Also accepts application/problem+json.
if (!response.ok) {
  console.error(`HTTP ${response.status}`, result);
  process.exitCode = 1; // A retry is a new operation; inspect billing first.
} else {
  console.log(JSON.stringify(result, null, 2));
  // For batches, inspect every item: HTTP 200 may contain item errors.
}
```

**Python**

Python 3.10+；标准库。保存为 example.py，然后运行 python3 example.py。[运行环境文档](https://docs.python.org/3/library/urllib.request.html)

```python
import json
import os
import sys
import urllib.error
import urllib.request

api_key = os.environ.get("GENDERAPI_API_KEY")
if not api_key:
    raise RuntimeError("Set GENDERAPI_API_KEY")
body = json.loads("{\"type\":\"email\",\"value\":\"alice.smith@example.com\",\"options\":{\"ai_mode\":\"off\"}}")

class NoRedirect(urllib.request.HTTPRedirectHandler):
    def redirect_request(self, req, fp, code, msg, headers, newurl):
        return None

request = urllib.request.Request(
    "https://api.genderapi.io/api/v2/gender",
    method="POST",
    data=json.dumps(body).encode("utf-8"),
    headers={
        "Authorization": "Bearer " + api_key,
        "Content-Type": "application/json",
    },
)
opener = urllib.request.build_opener(NoRedirect())
try:
    response = opener.open(request, timeout=30)
except urllib.error.HTTPError as error:
    response = error  # Keep the Problem Details body on non-2xx responses.
with response:
    status = response.status
    raw = response.read().decode("utf-8")
    if "json" not in response.headers.get("Content-Type", ""):
        raise RuntimeError(f"HTTP {status}: expected a JSON response")
    result = json.loads(raw)
print(json.dumps(result, indent=2), file=sys.stderr if status >= 300 else sys.stdout)
if not 200 <= status < 300:
    sys.exit(1)  # Inspect code, action and billing before retrying.
# For batches, inspect every item even when HTTP status is 200.
```

**PHP**

PHP 8+，需要 cURL 扩展。保存为 example.php，然后运行 php example.php。[运行环境文档](https://www.php.net/manual/en/book.curl.php)

```php
<?php
$apiKey = getenv('GENDERAPI_API_KEY');
if (!$apiKey) {
    throw new RuntimeException('Set GENDERAPI_API_KEY');
}
$body = json_decode('{"type":"email","value":"alice.smith@example.com","options":{"ai_mode":"off"}}', true, 512, JSON_THROW_ON_ERROR);

$ch = curl_init('https://api.genderapi.io/api/v2/gender');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . $apiKey,
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode($body, JSON_THROW_ON_ERROR),
]);
$raw = curl_exec($ch);
if ($raw === false) {
    throw new RuntimeException(curl_error($ch));
}
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($ch);
if (strpos($contentType, 'json') === false) {
    throw new RuntimeException("HTTP $status: expected a JSON response");
}
$result = json_decode($raw, true, 512, JSON_THROW_ON_ERROR);
$output = json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) . PHP_EOL;
if ($status < 200 || $status >= 300) {
    fwrite(STDERR, $output); // Preserve the Problem Details body.
    exit(1);
}
echo $output;
// For batches, inspect every item; HTTP 200 can contain item errors.
```

**Java**

Java 17+；标准 HTTP 客户端。保存为 GenderApiExample.java，然后运行 java GenderApiExample.java。[运行环境文档](https://docs.oracle.com/en/java/javase/17/docs/api/java.net.http/java/net/http/HttpClient.html)

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.Duration;

public class GenderApiExample {
    private static String requiredEnv(String name) {
        String value = System.getenv(name);
        if (value == null || value.isBlank()) throw new IllegalStateException("Set " + name);
        return value;
    }

    public static void main(String[] args) throws Exception {
        String apiKey = requiredEnv("GENDERAPI_API_KEY");
        String body = "{\"type\":\"email\",\"value\":\"alice.smith@example.com\",\"options\":{\"ai_mode\":\"off\"}}";
        HttpClient client = HttpClient.newBuilder()
            .connectTimeout(Duration.ofSeconds(10))
            .followRedirects(HttpClient.Redirect.NEVER)
            .build();
        HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.genderapi.io/api/v2/gender"))
            .timeout(Duration.ofSeconds(30))
            .header("Authorization", "Bearer " + apiKey)
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(body, StandardCharsets.UTF_8))
            .build();
        HttpResponse<String> response = client.send(request,
            HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8));
        if (!response.headers().firstValue("content-type").orElse("").contains("json")) {
            throw new IllegalStateException("HTTP " + response.statusCode() + ": expected JSON");
        }
        // JSON text; parse with your application's JSON library when integrating.
        if (response.statusCode() < 200 || response.statusCode() >= 300) {
            System.err.println(response.body()); // Includes Problem Details.
            System.exit(1);
        }
        System.out.println(response.body());
        // For batches, inspect each item's data or error, including on HTTP 200.
    }
}
```

**C# / .NET**

.NET 8+ 控制台应用。在控制台项目中作为 Program.cs 使用，然后运行 dotnet run。[运行环境文档](https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient)

```csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;

string RequiredEnv(string name) =>
    !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(name))
        ? Environment.GetEnvironmentVariable(name)!
        : throw new InvalidOperationException($"Set {name}");

var apiKey = RequiredEnv("GENDERAPI_API_KEY");
using var handler = new HttpClientHandler { AllowAutoRedirect = false };
using var client = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(30) };
using var request = new HttpRequestMessage(HttpMethod.Post, "https://api.genderapi.io/api/v2/gender");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
request.Content = new StringContent("{\"type\":\"email\",\"value\":\"alice.smith@example.com\",\"options\":{\"ai_mode\":\"off\"}}", Encoding.UTF8, "application/json");

using var response = await client.SendAsync(request);
var raw = await response.Content.ReadAsStringAsync();
if (!(response.Content.Headers.ContentType?.MediaType?.Contains("json") ?? false))
    throw new InvalidOperationException($"HTTP {(int)response.StatusCode}: expected JSON");
using var result = JsonDocument.Parse(raw);
if (!response.IsSuccessStatusCode)
{
    Console.Error.WriteLine(result.RootElement); // Preserve Problem Details.
    Environment.ExitCode = 1;
}
else
{
    Console.WriteLine(result.RootElement);
    // For batches, inspect every item even on HTTP 200.
}
```

**Go**

Go 1.22+；标准库。保存为 main.go，然后运行 go run main.go。[运行环境文档](https://pkg.go.dev/net/http)

```go
package main

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

func requiredEnv(name string) string {
    value := os.Getenv(name)
    if value == "" { panic("Set " + name) }
    return value
}

func run() error {
    apiKey := requiredEnv("GENDERAPI_API_KEY")
    body := "{\"type\":\"email\",\"value\":\"alice.smith@example.com\",\"options\":{\"ai_mode\":\"off\"}}"
    request, err := http.NewRequest("POST", "https://api.genderapi.io/api/v2/gender", strings.NewReader(body))
    if err != nil { return err }
    request.Header.Set("Authorization", "Bearer " + apiKey)
    request.Header.Set("Content-Type", "application/json")
    client := &http.Client{
        Timeout: 30 * time.Second,
        CheckRedirect: func(req *http.Request, via []*http.Request) error {
            return http.ErrUseLastResponse
        },
    }
    response, err := client.Do(request)
    if err != nil { return err }
    defer response.Body.Close()
    raw, err := io.ReadAll(response.Body)
    if err != nil { return err }
    if !strings.Contains(response.Header.Get("Content-Type"), "json") || !json.Valid(raw) {
        return fmt.Errorf("HTTP %d: expected a JSON response", response.StatusCode)
    }
    if response.StatusCode < 200 || response.StatusCode >= 300 {
        return fmt.Errorf("HTTP %d: %s", response.StatusCode, raw)
    }
    fmt.Println(string(raw))
    // For batches, inspect every item even on HTTP 200.
    return nil
}

func main() {
    if err := run(); err != nil {
        fmt.Fprintln(os.Stderr, err) // Keep Problem Details for error handling.
        os.Exit(1)
    }
}
```

- [错误与重试指南 →](https://www.genderapi.io/zh/docs/v2/errors-and-retries)

### 处理列表结果与重复请求

POST /api/v2/gender/batch 使用 API 密钥时最多接受 50 个条目，使用 IP 试用时最多 10 个。请为每个条目分别提供 type、value 和 options。如需标准 AI 回退，请在每个条目中明确设置 fallback。id 在同一批次内必须唯一；index 在所提交的批次内从零开始。请单独保存您自己的任务标识符和来源行标识符。

HTTP 200 并不表示所有条目都已完成。请分别处理 identified、unknown 和 error 结果；meta.summary.succeeded 同时统计 identified 和 unknown。请综合评估 data.gender、source、confidence_kind、confidence、match 和 reason。不要把 AI 评分与数据集中的频率视为等同。

如果 meta.usage.billing_status 的值为 confirmed，只重试允许重新请求的操作错误。如果状态为 unconfirmed，或响应已丢失，请停止并检查计费情况。重新发送同一条目（包括已完成的 unknown 结果）会产生一次新的计费操作；切勿盲目重新发送整个列表。

[批量请求约定](https://www.genderapi.io/zh/docs/v2/batch) · [响应字段](https://www.genderapi.io/zh/docs/v2/responses) · [AI 选项](https://www.genderapi.io/zh/docs/v2/ai-options) · [准确性与置信度评估](https://www.genderapi.io/zh/accuracy-methodology) · [隐私政策](https://www.genderapi.io/zh/privacy-policy)

Excel 和 Google Sheets 插件以及其他现成集成可能使用各自的连接方式和结果格式。不要假定它们的输出遵循此 V2 JSON 结构；请查阅相应集成的当前指南。

## 从电子邮箱地址获取名字和性别

### 可以从电子邮箱地址中提取名字吗？

对于受支持的个人邮箱，GenderAPI 可以从 @ 之前的部分提取候选名字，并在有结果时返回性别、国家/地区和置信度信息。候选名字是一种推断，并不是邮箱持有人经过验证的名字。

### 每个电子邮箱地址都能提供名字吗？

不能。功能性地址、随机标识符以及不含真实名字的 @ 前部分，并不总能提供可靠的信号。请检查 V2 响应中的 data.result_status、data.reason、data.confidence 和 data.confidence_kind。

### 电子邮箱查询会被保存吗？

根据已公布的政策，电子邮箱查询不会作为可重复使用的查询记录保留。单独的技术日志和安全日志遵循隐私政策中所述的保留期限。请勿在公开演示中输入敏感个人数据。

### 可以在 Excel 和 Google Sheets 中使用吗？

可以。电子邮箱地址列可以通过 Excel 插件、Google Sheets 插件或 Excel/CSV 文件导入工具处理。这些集成有各自的结果格式，与 V2 JSON 不同。

### API 会返回哪些字段？

V2 返回 data.name、data.gender、data.match 以及来源和置信度字段，并在 meta 中返回请求 ID 和积分消耗。候选名字或性别可能为 null。响应中没有经过验证的姓氏字段。

### 什么时候会使用 AI？

在 V2 单条请求中，标准 AI 回退默认开启。在本演示中，您可以使用标准请求或 forceToGenderize；off 和 always 需在 API 请求中设置。标准 AI 回退共消耗 1 个积分，always 消耗 2 个积分。使用 forceToGenderize 时，数据集给出结果消耗 1 个积分，使用 AI 时共消耗 2 个积分；结果仍可能为 unknown。

### 可以免费试用吗？

账户每天包含 200 个免费积分，共享的 IP 试用为每个公网 IP 地址每 24 小时提供 10 个积分。API 密钥缺失或无法识别时，可能会使用 IP 试用；请检查响应中的 meta.access.mode 字段。这里计算的是积分，而不是请求次数。
