Welcome to the Games API! This project is designed to help users find games that are available on both Xbox Ultimate Game Pass and PlayStation Plus Deluxe subscription services. The API provides an easy way to access and share game details across these platforms, making it simpler for gamers to discover games that are available to play on both services.
- Fetch games available on Xbox Ultimate Game Pass.
- Fetch games available on PlayStation Plus Deluxe.
- Retrieve game information such as title, image, and platform tags.
- Store game information in Redis for faster retrieval.
- Node.js: Backend JavaScript runtime.
- Express: Framework for building the REST API.
- Redis: Used for caching game data to reduce API call latency.
- Axios: To make HTTP requests to third-party APIs.
- dotenv: For managing environment variables.
- PM2: Process manager for running the API in production.
- URL:
/api/games/ps
- Method: GET
- Description: Fetches games available on PlayStation Plus Deluxe. The data includes game titles, images, and platform information.
- Response:
{ "games": [ { "title": "Game Title", "image": "https://example.com/image.jpg", "tag": ["plus"] } ], "size": 100 }
- URL:
/api/games/xbox
- Method: GET
- Description: Fetches games available on Xbox Ultimate Game Pass. The data includes game titles, images, and platform tags.
- Response:
{ "games": [ { "title": "Game Title", "image": "https://example.com/image.jpg", "tag": ["ultimate"] } ] }
To get started, clone this repository and install the dependencies:
# Clone the repository
git clone https://github.com/yourusername/games-api.git
# Change to the project directory
cd games-api
# Install dependencies
npm install
To run the project in development mode, use:
npm start
You can also run the project using Docker:
# Build the Docker image
docker build -t games-api .
# Run the Docker container
docker run -p 3000:3000 --env-file .env games-api
The following environment variables need to be set for the project to run properly:
- PORT: The port the server will run on (default: 3000).
- REDIS_HOST: Hostname of your Redis instance.
- REDIS_PORT: Port number for Redis.
- REDIS_PASSWORD: Password for the Redis server.
This project can be easily deployed on Render. To deploy:
- Connect your GitHub repository to Render.
- Create a New Web Service and configure the necessary environment variables.
- Deploy and enjoy!
- When the user makes a request to
/api/games/ps
or/api/games/xbox
, the API first checks if the data is available in Redis. If available, it returns the cached data. - If the data is not available in Redis, the API will make requests to the PlayStation and Xbox APIs to fetch the latest data and store it in Redis for future requests.
- dotenv is used for managing environment variables securely.
- Helmet can be added to enhance security by setting secure HTTP headers (not yet implemented in this version).
Contributions are welcome! Feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.
If you have any questions or need support, feel free to contact me at ahmadalzein06@gmail.com.