### Exemplo de Requisição GET para Dados de CPF Source: https://cpfhub.io/documentacao/api-reference Utilize este endpoint para consultar dados de um CPF específico. Certifique-se de incluir sua API Key no header 'x-api-key' e definir o header 'Accept' como 'application/json'. ```curl curl -X GET 'https://api.cpfhub.io/cpf/00000000000' \ -H 'x-api-key: YOUR_API_KEY' \ -H 'Accept: application/json' ``` -------------------------------- ### CPFHub API Error Response Source: https://cpfhub.io/documentacao/api-reference/cpf Example of an error response from the CPFHub API, indicating an issue such as an invalid CPF. Includes a success flag and an error message. ```json { "success": false, "data": null, "error": { "message": "Invalid CPF" } } ``` -------------------------------- ### CPFHub API Success Response Source: https://cpfhub.io/documentacao/api-reference/cpf Example of a successful response from the CPFHub API when querying CPF data. Includes CPF, name, gender, and birth date details. ```json { "success": true, "data": { "cpf": "00000000000", "name": "Fulano de Tal", "nameUpper": "FULANO DE TAL", "gender": "M", "birthDate": "15/06/1990", "day": 15, "month": 6, "year": 1990 } } ``` -------------------------------- ### Get CPF Data Source: https://cpfhub.io/documentacao/api-reference Retrieve CPF data by providing the CPF number in the path. Authentication is required via an API Key in the request header. ```APIDOC ## GET /cpf/{cpf_number} ### Description Retrieves information associated with a given CPF number. ### Method GET ### Endpoint `https://api.cpfhub.io/cpf/{cpf_number}` ### Parameters #### Path Parameters - **cpf_number** (string) - Required - The CPF number to query. #### Request Headers - **x-api-key** (string) - Required - Your API key for authentication. - **Accept** (string) - Optional - Specifies the desired response format, typically `application/json`. ### Request Example ```bash curl -X GET 'https://api.cpfhub.io/cpf/00000000000' \ -H 'x-api-key: YOUR_API_KEY' \ -H 'Accept: application/json' ``` ### Response #### Success Response (200) - **data** (object) - Contains the CPF information. - **message** (string) - A success message. #### Response Example ```json { "data": { "cpf": "00000000000", "nome": "Fulano de Tal", "data_nascimento": "1990-01-01", "situacao": "REGULAR" }, "message": "CPF found successfully." } ``` #### Error Response (400, 401, 404, 429, 500, 503) - **error** (object) - Contains error details. - **code** (string) - The error code. - **message** (string) - A descriptive error message. #### Error Response Example ```json { "error": { "code": "INVALID_CPF", "message": "The provided CPF number is invalid." } } ``` ``` -------------------------------- ### Query CPF Data with Node.js Source: https://cpfhub.io/documentacao/api-reference/cpf Demonstrates how to query CPF data using the CPFHub API with Node.js. Requires your API key and specifies JSON response format. ```javascript const cpf = '00000000000'; const response = await fetch(`https://api.cpfhub.io/cpf/${cpf}`, { method: 'GET', headers: { 'x-api-key': 'YOUR_API_KEY', 'Accept': 'application/json' } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Consultar CPF Source: https://cpfhub.io/documentacao/api-reference/cpf Query a CPF and retrieve structured data including name, date of birth, and gender. This endpoint requires an API key for authentication. ```APIDOC ## GET /cpf/{cpf} ### Description Query a CPF and retrieve structured data including name, date of birth, and gender. ### Method GET ### Endpoint /cpf/{cpf} ### Parameters #### Path Parameters - **cpf** (string) - Required - CPF with only numbers (e.g., 31592165869) #### Headers - **x-api-key** (string) - Required - Your API key - **Accept** (string) - Optional - Specifies the desired response format, defaults to application/json ### Request Example ```javascript const cpf = '00000000000'; const response = await fetch(`https://api.cpfhub.io/cpf/${cpf}`, { method: 'GET', headers: { 'x-api-key': 'YOUR_API_KEY', 'Accept': 'application/json' } }); const data = await response.json(); console.log(data); ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **data** (object) - Contains the CPF data if successful. - **cpf** (string) - The queried CPF. - **name** (string) - Full name. - **nameUpper** (string) - Full name in uppercase. - **gender** (string) - Gender (M/F). - **birthDate** (string) - Date of birth (DD/MM/YYYY). - **day** (number) - Day of birth. - **month** (number) - Month of birth. - **year** (number) - Year of birth. #### Response Example ```json { "success": true, "data": { "cpf": "00000000000", "name": "Fulano de Tal", "nameUpper": "FULANO DE TAL", "gender": "M", "birthDate": "15/06/1990", "day": 15, "month": 6, "year": 1990 } } ``` #### Error Response - **success** (boolean) - Indicates if the request was successful (will be false). - **data** (null) - Always null in case of an error. - **error** (object) - Contains error details. - **message** (string) - Description of the error. #### Error Response Example ```json { "success": false, "data": null, "error": { "message": "Invalid CPF" } } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.