Base URL: https://api.countrylocation.com/
This API provides endpoints for user authentication and postal code management. Below are the details of the available endpoints.
POST /api/register
Registers a new user.
{ "name": "John Doe", "email": "john.doe@example.com", "password": "password123", "password_confirmation": "password123" }
{ "status": "success", "message": "User registered successfully.", "token": "your-access-token" }
POST /api/login
Logs in an existing user.
{ "email": "john.doe@example.com", "password": "password123" }
{ "status": "success", "message": "Login successful.", "token": "your-access-token" }
POST /api/forgot-password
Sends a password reset link to the user’s email.
{ "email": "john.doe@example.com" }
{ "status": "success", "message": "Password reset link sent to your email." }
POST /api/reset-password
Resets the user's password using a valid token.
{ "email": "john.doe@example.com", "token": "reset-token", "password": "newpassword123", "password_confirmation": "newpassword123" }
{ "status": "success", "message": "Password has been reset." }
GET /api/postal-codes
Retrieves a list of postal codes with optional filters.
postal_code
(string) - Filter by postal code.country_code
(string) - Filter by country code.admin_name1
(string) - Filter by administrative region.GET /api/postal-codes?country_code=IN
{ "status": "success", "data": [ { "postal_code": "421605", "country_code": "IN", "place_name": "Phalegaon" } ] }
GET /api/postal-codes/{postalCode}
Gets detailed information about a specific postal code.
GET /api/postal-codes/421605
{ "status": "success", "data": { "postal_code": "421605", "country_code": "IN", "place_name": "Phalegaon", "admin_name1": "Maharashtra" } }
GET /api/postal-codes/nearby/area
Finds postal codes near a specific latitude and longitude.
latitude
(numeric) - Latitude of the location.longitude
(numeric) - Longitude of the location.radius
(numeric, optional) - Search radius in kilometers (default: 10).GET /api/postal-codes/nearby/area?latitude=19.36&longitude=73.32&radius=15
{ "status": "success", "data": [ { "postal_code": "421604", "country_code": "IN", "place_name": "Nearby Place" } ] }