random-pexels-image
Simple Node.js application that provides an endpoint to search Pexels and return a randomly selected image. It allows hotlinking images by directly returning the image data.
A Node.js application that provides an endpoint to search Pexels and return a randomly selected image, allowing hotlinking by directly returning the image data. It fetches images from the Pexels API based on query parameters such as size, keyword, and orientation, and when no keyword is supplied it picks a random word from a list of 300. It is intended for web applications or services that need to dynamically fetch and display Pexels images without storing them locally. The server reads a Pexels API key and port from a .env file and exposes a /search-image GET endpoint.
Installation
-
Clone the repository
git clone https://github.com/jparkerweb/pexels-image-search-api.git cd pexels-image-search-api -
Install the dependencies
npm install -
Create a
.envfile in the root directory and add your Pexels API key and server portPEXELS_API_KEY=your_pexels_api_key PORT=8000 -
Optionally adjust the
random-words.jsonfile with random words if a keyword is not submited with each search request