The Request Header Parser is a simple API built with Node.js and Express that extracts and parses information from HTTP request headers. It provides endpoints to retrieve details such as IP address, preferred languages, software platform, and other relevant metadata from incoming HTTP requests.
The Request Header Parser is designed to assist developers in retrieving and parsing essential client information from request headers, aiding in various use cases such as user analytics, language preferences, and client compatibility detection.
- IP Address: Obtain the client's IP address from the request headers.
- Preferred Languages: Retrieve the preferred languages set in the client's browser.
- Software Platform: Identify the client's operating system and browser information.
- User-Agent Parsing: Extract user-agent details for detailed device and browser information.
git clone https://github.com/zhid0399123/headerparser.git
cd headerparser
pnpm install
npm start
The server runs on http://0.0.0.0:3000/v0/api/headerparser/whoami by default. You can modify the port in your .env
file
Send a GET request to http://0.0.0.0:3000/v0/api/headerparser/whoami
endpoint to retrieve client's IP address, preferred languages, and user-agent information.
Example:
curl http://0.0.0.0:3000/v0/api/headerparser/whoami
Response:
{
"id": "e7757827-c456-4354-9b98-b9ebfee29705",
"ipAddress": "159.20.14.100",
"languages": "en-US,en;q=0.5",
"userAgent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
}
The headerparser Microservice is deployed and accessible via fly.io, allowing users to interact with the API endpoints. Follow these steps to access the deployed API:
-
Base URL: The deployed API can be accessed at https://headerparser.fly.dev/v0/api/headerparser/whoami.
-
Usage Examples: Here's an example using cURL to convert a timestamp to Unix time:
curl -X GET https://headerparser.fly.dev/v0/api/headerparser/whoami
GET /v0/api/headerparser/whoami
Retrieve request header information.
Contributions are welcome! Feel free to open issues or submit pull requests. Please refer to the Contributing Guidelines to get started.
This project is licensed under the MIT License. Refer to the LICENSE file for more details.