Welcome to Locale API, your ultimate resource for geographical information about Nigeria! Whether you're a developer building applications for Nigeria's vast population or simply curious about its regions, states, and local government areas (LGAs), Locale API has you covered. This documentation provides an overview of the API endpoints, authentication procedures, and usage guidelines to help you leverage Locale's features effectively.
The base URL for accessing Locale API is:
https://locale-4z2n.onrender.com
To access Locale API endpoints, developers must authenticate their requests using API keys. Each developer must sign up to generate their unique API key, which will be used for subsequent requests.
Method: POST
Description: Registers a new user and generates an API key.
Request Body:
json
{ "fname": "First Name", "lname": "Last Name", "email": "example@example.com", "pwd": "your_password", "cpwd": "confirm_password" }
Response:
json
{ "fname": "First Name", "lname": "Last Name", "email": "example@example.com", "token": "your_access_token" }
Logging In
Endpoint: /login
Method: POST
Description: Logs in an existing user and provides an access token.
Request Body:
json
{ "email": "example@example.com", "pwd": "your_password" }
Response:
json
{ "access_token": "your_access_token", "token_type": "bearer", "user": { "id": 1, "fname": "First Name", "lname": "Last Name", "email": "example@example.com", "api_key": "your_api_key" } }
Endpoint: /logout
Method: POST
Description: Logs out a user from the current session.
Request Header:
Authorization: Bearer your_access_token
Response:
json
{ "message": "Logout successful" }
Endpoint: /users
Method: GET
Description: Retrieves all registered users.
Response Body: Array of user objects.
Endpoint: /users/{id}
Method: GET
Description: Retrieves user details by ID.
Response Body: User object.
Endpoint: /users/{id}
Method: PUT
Description: Updates user profile information.
Request Body: User object with updated fields.
Response Body: Updated user object.
Endpoint: /api-key/{api_key}
Method: GET
Description: Retrieves the user's API key.
Response Body: API key object.
Endpoint: /regions
Method: GET
Description: Retrieves all regions in Nigeria.
Response Body: Array of region objects.
Endpoint: /regions/{region_id}
Method: GET
Description: Retrieves region details by ID.
Response Body: Region object.
Endpoint: /regions/region/{regionSearch}
Method: GET
Description: Retrieves region details by name.
Response Body: Region object.
Endpoint: /states
Method: GET
Description: Retrieves all states in Nigeria.
Response Body: Array of state objects.
Endpoint: /states/{state_id}
Method: GET
Description: Retrieves state details by ID.
Response Body: State object.
Endpoint: /states/state/{stateSearch}
Method: GET
Description: Retrieves state details by name.
Response Body: State object.
Endpoint: /lgas
Method: GET
Description: Retrieves all local government areas (LGAs) in Nigeria.
Response Body: Array of LGA objects.
Endpoint: /lgas/{lga_id}
Method: GET
Description: Retrieves LGA details by ID.
Response Body: LGA object.
Endpoint: /cities
Method: GET
Description: Retrieves all cities in Nigeria.
Response Body: Array of city objects.
Endpoint: /cities/{city_id}
Method: GET
Description: Retrieves city details by ID.
Response Body: City object.
Locale API provides comprehensive access to geographical information about Nigeria, empowering developers to build innovative solutions tailored to the needs of Nigeria's diverse population. By leveraging Locale's endpoints and authentication mechanisms, developers can seamlessly integrate geographical data into their applications, unlocking new possibilities for exploration and development. Start exploring Nigeria with Locale API today!