API 文档
Generate Random IBAN API 可通过编程方式生成和校验结构有效(ISO 13616 / MOD-97)的测试 IBAN。所有响应均为 JSON。生成的 IBAN 仅用于测试,绝不对应真实银行账户。
基础 URL
https://generaterandomiban.com/api/v1
鉴权
除服务索引外,所有端点都需要 API 密钥。请在 X-API-Key 请求头中发送(也可使用 Authorization: Bearer 令牌)。请妥善保管密钥,切勿在客户端代码中暴露。
curl -H "X-API-Key: YOUR_KEY" https://generaterandomiban.com/api/v1/countries
API 密钥由人工签发。如需申请,请发送邮件并简要说明您的使用场景,我们会将密钥回复给您。
速率限制
请求按密钥限流——默认每分钟 60 次,或为您的密钥分配的自定义上限。超出限制将返回 HTTP 429(Too Many Requests)。
端点
/api/v1
public
Public service index: metadata and the list of endpoints. No API key required.
curl https://generaterandomiban.com/api/v1
{
"name": "Generate Random IBAN API",
"version": "v1",
"documentation": "https://generaterandomiban.com/zh/apis/docs",
"authentication": { "type": "api_key", "header": "X-API-Key" }
}
/api/v1/countries
List every supported country with its IBAN format.
curl -H "X-API-Key: YOUR_KEY" https://generaterandomiban.com/api/v1/countries
{
"count": 45,
"countries": [
{
"code": "DE",
"name": "Germany",
"slug": "germany",
"iban_length": 22,
"bban_length": 18,
"bban_format": "8n10n",
"structure": "DEkk bbbb bbbb cccc cccc cc",
"example": "DE89370400440532013000"
}
]
}
/api/v1/countries/{code}
Get the IBAN format for a single country.
| Parameter | In | Description |
|---|---|---|
code |
path | ISO 3166-1 alpha-2 country code (e.g. DE, FR, IT). |
curl -H "X-API-Key: YOUR_KEY" https://generaterandomiban.com/api/v1/countries/DE
{
"country": {
"code": "DE",
"name": "Germany",
"iban_length": 22,
"bban_format": "8n10n",
"example": "DE89370400440532013000"
}
}
/api/v1/generate/{country}
Generate one or more random, valid IBANs for a country.
| Parameter | In | Description |
|---|---|---|
country |
path | ISO 3166-1 alpha-2 country code. |
count |
query | How many IBANs to return, 1–100 (default 1). |
curl -H "X-API-Key: YOUR_KEY" "https://generaterandomiban.com/api/v1/generate/DE?count=2"
{
"country": { "code": "DE", "name": "Germany", "iban_length": 22 },
"count": 2,
"ibans": [
{
"iban": "DE89370400440532013000",
"formatted": "DE89 3704 0044 0532 0130 00",
"country": "DE",
"check_digits": "89",
"bban": "370400440532013000",
"length": 22,
"valid": true
}
]
}
/api/v1/generate
Generate IBANs from a JSON body.
| Parameter | In | Description |
|---|---|---|
country |
body | ISO 3166-1 alpha-2 country code (required). |
count |
body | How many IBANs to return, 1–100 (default 1). |
curl -X POST -H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"country":"FR","count":3}' https://generaterandomiban.com/api/v1/generate
{
"country": { "code": "FR", "name": "France", "iban_length": 27 },
"count": 3,
"ibans": [ /* … */ ]
}
/api/v1/validate/{iban}
Validate an IBAN passed in the URL (spaces removed).
| Parameter | In | Description |
|---|---|---|
iban |
path | The IBAN to validate (letters and digits only). |
curl -H "X-API-Key: YOUR_KEY" https://generaterandomiban.com/api/v1/validate/DE89370400440532013000
{
"iban": "DE89370400440532013000",
"valid": true,
"country_code": "DE",
"country_supported": true,
"check_digits": "89",
"bban": "370400440532013000",
"length": 22,
"expected_length": 22,
"checks": { "mod97": true, "length": true, "format": true, "country_supported": true }
}
/api/v1/validate
Validate an IBAN from a JSON body.
| Parameter | In | Description |
|---|---|---|
iban |
body | The IBAN to validate (required). |
curl -X POST -H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"iban":"DE89 3704 0044 0532 0130 00"}' https://generaterandomiban.com/api/v1/validate
{
"iban": "DE89370400440532013000",
"valid": true,
"country_code": "DE",
"checks": { "mod97": true, "length": true, "format": true, "country_supported": true }
}
错误与状态码
错误会返回标准 HTTP 状态码,以及包含 code 和 message 的 error 对象 JSON。常见状态:401(缺少或无效密钥)、404(未知国家或端点)、422(参数无效)和 429(超出限流)。
{
"error": {
"code": "invalid_request",
"message": "The \"count\" parameter must be an integer between 1 and 100."
}
}