\n\n

Introduction

The Fake Address Generator API allows developers to programmatically generate fake addresses and related data for testing purposes. This documentation provides information on how to use our API endpoints, request formats, and response structures.

Note: This API is currently in beta. Features and endpoints may change without notice.

Base URL

https://api.fakeaddressgenerator.com/v1

Authentication

All API requests require an API key. You can obtain an API key by registering for a developer account.

Include your API key in the request header:

X-API-Key: your_api_key_here

Rate Limiting

Free tier accounts are limited to 100 requests per day. Premium accounts have higher limits based on the subscription plan.

Endpoints

GET /status

Check the status of the API.

Request:

GET /api.php?endpoint=status

Response:

{
  "status": "active",
  "version": "1.0.0",
  "timestamp": 1672531200
}

POST /generate

Generate a fake address.

Request:

{
  "endpoint": "generate",
  "country": "US",
  "include_phone": true,
  "include_email": true
}

Response:

{
  "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
  "name": "John Smith",
  "street": "123 Main St",
  "city": "Anytown",
  "state": "CA",
  "zip": "90210",
  "country": "US",
  "phone": "+1 555-123-4567",
  "email": "john.smith@example.com"
}

POST /generate/bulk

Generate multiple fake addresses in a single request.

Request:

{
  "endpoint": "generate/bulk",
  "count": 5,
  "country": "UK",
  "include_phone": true,
  "include_email": false
}

Response:

{
  "addresses": [
    {
      "id": "a1b2c3d4-e5f6-7890-a1b2-c3d4e5f67890",
      "name": "Emma Wilson",
      "street": "45 Park Lane",
      "city": "London",
      "state": "",
      "zip": "SW1A 1AA",
      "country": "UK",
      "phone": "+44 20 1234 5678"
    },
    // Additional addresses...
  ],
  "count": 5
}

Error Handling

The API uses standard HTTP status codes to indicate the success or failure of a request.

  • 200 OK: The request was successful.
  • 400 Bad Request: The request was invalid or cannot be served.
  • 401 Unauthorized: Authentication failed or user doesn't have permissions.
  • 404 Not Found: The requested resource could not be found.
  • 429 Too Many Requests: Rate limit exceeded.
  • 500 Internal Server Error: An error occurred on the server.

Error responses will include a JSON object with an error message:

{
  "error": "Invalid country code",
  "code": "INVALID_PARAMETER"
}

Code Examples

JavaScript

fetch('https://api.fakeaddressgenerator.com/v1/generate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your_api_key_here'
  },
  body: JSON.stringify({
    endpoint: 'generate',
    country: 'US',
    include_phone: true,
    include_email: true
  })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

PHP

$url = 'https://api.fakeaddressgenerator.com/v1/generate';
$data = array(
  'endpoint' => 'generate',
  'country' => 'US',
  'include_phone' => true,
  'include_email' => true
);

$options = array(
  'http' => array(
    'header'  => "Content-type: application/json\r\nX-API-Key: your_api_key_here\r\n",
    'method'  => 'POST',
    'content' => json_encode($data)
  )
);

$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);

if ($result === FALSE) { /* Handle error */ }

var_dump(json_decode($result));

Support

If you encounter any issues or have questions about the API, please contact our support team at api-support@fakeaddressgenerator.com or visit our Help Center.

\n \n \n