cpfhub-nim
Official Nim SDK for CPFHub.io — Brazilian CPF lookup API. Get name, gender and date of birth from any CPF in ~300ms.
Summary
| Latest Version | 1.0.0 |
|---|---|
| License | MIT |
| CI Status | Failing |
| Stars | 0 |
| Forks | 0 |
| Open Issues | 0 |
| Last Commit | 2026-05-02 |
| Downloads | 0 |
| Last Indexed | 2026-10-07 10:10 |
Tags
Authors
- CPFHub.io
Installation
nimble install cpfhub-nim
choosenim install cpfhub-nim
git clone https://github.com/cpfhub/cpfhub-nim
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| cpfhub-nim | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Dependencies
| Package | Version | Optional |
|---|---|---|
| nim >= | 2.0.0 | No |
| httpclient >= | 0.1.0 | No |
| jsony >= | 1.1.5 | No |
Source
| Repository | https://github.com/cpfhub/cpfhub-nim |
|---|---|
| Homepage | https://www.cpfhub.io/documentacao/sdks |
| Registry Source | github |
README
cpfhub: Nim SDK for CPFHub.io
🇺🇸 English | 🇧🇷 Português
Official Nim SDK for CPFHub.io — Brazilian CPF Lookup API
What is CPFHub.io?
CPFHub.io is a REST API that returns name, gender, and date of birth from any Brazilian CPF number — in ~300ms, with 99.9% uptime and full LGPD compliance.
10M+ CPFs queried · 1,300+ active companies · 99.9% uptime
Installation
nimble install cpfhub
Quick Start
import cpfhub
let client = newCPFHubClient(apiKey = "YOUR_API_KEY")
let result = client.lookup("00000000000")
echo result.name # "Fulano de Tal"
echo result.gender # "M"
echo result.birthDate # "15/06/1990"
Get your free API key at app.cpfhub.io — no credit card required.
curl Example
curl -X GET "https://api.cpfhub.io/cpf/12345678909" \\
-H "x-api-key: YOUR_API_KEY"
Response:
{
"success": true,
"data": {
"cpf": "12345678909",
"name": "Fulano de Tal",
"nameUpper": "FULANO DE TAL",
"gender": "M",
"birthDate": "15/06/1990",
"day": 15,
"month": 6,
"year": 1990
}
}
API Reference
newCPFHubClient(apiKey: string, timeout: int = 10): CPFHubClient
client.lookup(cpf: string): CPFResult
Looks up a CPF and returns the associated identity data.
Accepts CPF with or without formatting (000.000.000-00 or 00000000000).
CPFResult fields
| Field | Type | Description |
|---|---|---|
cpf |
string |
CPF number (digits only) |
name |
string |
Full name |
nameUpper |
string |
Full name in uppercase |
gender |
string |
"M" or "F" |
birthDate |
string |
Date of birth — "DD/MM/YYYY" |
day |
int |
Birth day |
month |
int |
Birth month |
year |
int |
Birth year |
Error Handling
try:
let result = client.lookup("00000000000")
echo result.name
except CPFHubError as e:
case e.statusCode:
of 400: echo "Invalid CPF format"
of 401: echo "Invalid or missing API key"
of 404: echo "CPF not found"
of 429: echo "Rate limit exceeded"
else: echo "Error: " & e.msg
Examples
Real-world onboarding
import cpfhub
proc onboardUser(cpf, email: string) =
let client = newCPFHubClient(apiKey = getEnv("CPFHUB_API_KEY"))
let identity = client.lookup(cpf)
createUser(cpf = cpf, name = identity.name, email = email, birthYear = identity.year)
Rate Limits
| Plan | Limit |
|---|---|
| Free | 1 request every 2 seconds · 50 requests/month |
| Pro | 1 request per second · 1,000 requests/month |
| Corporate | Custom |
Plans & Pricing
| Plan | Price | Included | Extra |
|---|---|---|---|
| Free | R$ 0/month | 50 lookups | — |
| Pro | R$ 149/month | 1,000 lookups | R$ 0,15/lookup |
| Corporate | Custom | Custom | Custom |
View full pricing at cpfhub.io →
Requirements
- Nim 1.6+
- Nimble
Links
- Documentation
- Nimble Package
- Dashboard
- Status Page
- Pricing
- LGPD Compliance
- OpenAPI Specification
- MCP Server (AI Agents)
License
MIT © CPFHub.io
Português
🇺🇸 English | 🇧🇷 Português
SDK Nim oficial para CPFHub.io — API de Consulta de CPF Brasileiro
O que é o CPFHub.io?
O CPFHub.io é uma API REST que retorna nome, gênero e data de nascimento de qualquer CPF brasileiro — em ~300ms, com 99,9% de uptime e total conformidade com a LGPD.
10M+ CPFs consultados · 1.300+ empresas ativas · 99,9% uptime
Instalação
nimble install cpfhub
Início Rápido
import cpfhub
let client = newCPFHubClient(apiKey = "SUA_CHAVE_DE_API")
let result = client.lookup("00000000000")
echo result.name # "Fulano de Tal"
echo result.gender # "M"
echo result.birthDate # "15/06/1990"
Obtenha sua chave de API gratuita em app.cpfhub.io — sem cartão de crédito.
Exemplo curl
curl -X GET "https://api.cpfhub.io/cpf/12345678909" \\
-H "x-api-key: SUA_CHAVE_DE_API"
Resposta:
{
"success": true,
"data": {
"cpf": "12345678909",
"name": "Fulano de Tal",
"nameUpper": "FULANO DE TAL",
"gender": "M",
"birthDate": "15/06/1990",
"day": 15,
"month": 6,
"year": 1990
}
}
Referência da API
newCPFHubClient(apiKey: string, timeout: int = 10): CPFHubClient
client.lookup(cpf: string): CPFResult
Consulta um CPF e retorna os dados de identidade associados.
Aceita CPF com ou sem formatação (000.000.000-00 ou 00000000000).
Campos de CPFResult
| Campo | Tipo | Descrição |
|---|---|---|
cpf |
string |
CPF (apenas dígitos) |
name |
string |
Nome completo |
nameUpper |
string |
Nome completo em maiúsculas |
gender |
string |
"M" ou "F" |
birthDate |
string |
Data de nascimento — "DD/MM/YYYY" |
day |
int |
Dia de nascimento |
month |
int |
Mês de nascimento |
year |
int |
Ano de nascimento |
Tratamento de Erros
try:
let result = client.lookup("00000000000")
echo result.name
except CPFHubError as e:
case e.statusCode:
of 400: echo "Formato de CPF inválido"
of 401: echo "Chave de API inválida ou ausente"
of 404: echo "CPF não encontrado"
of 429: echo "Limite de requisições excedido"
else: echo "Erro: " & e.msg
Exemplos
Onboarding real
import cpfhub
proc onboardUser(cpf, email: string) =
let client = newCPFHubClient(apiKey = getEnv("CPFHUB_API_KEY"))
let identity = client.lookup(cpf)
createUser(cpf = cpf, name = identity.name, email = email, birthYear = identity.year)
Limites de Requisição
| Plano | Limite |
|---|---|
| Gratuito | 1 requisição a cada 2 segundos · 50 requisições/mês |
| Pro | 1 requisição por segundo · 1.000 requisições/mês |
| Corporativo | Personalizado |
Planos e Preços
| Plano | Preço | Incluído | Extra |
|---|---|---|---|
| Gratuito | R$ 0/mês | 50 consultas | — |
| Pro | R$ 149/mês | 1.000 consultas | R$ 0,15/consulta |
| Corporativo | Personalizado | Personalizado | Personalizado |
Ver preços completos em cpfhub.io →
Requisitos
- Nim 1.6+
- Nimble
Links
- Documentação
- Pacote Nimble
- Dashboard
- Página de Status
- Preços
- Conformidade LGPD
- Especificação OpenAPI
- Servidor MCP (Agentes de IA)
Licença
MIT © CPFHub.io