Certainly! Below is a basic README for the provided code snippet:


Google Image API Wrapper

This Node.js application provides a simple wrapper for the Google Image Search API, allowing users to perform image searches and retrieve results.

Installation

  1. Clone the repository:
    git clone https://github.com/caliph91/google-image-api.git
  2. Navigate into the project directory:
    cd google-image-api
  3. Install dependencies:
    npm install

Usage

Endpoints

  • Image Search:
    • Performs a Google Image Search based on the query parameters.

Parameters

  • /search Endpoint:
    • Query Parameters:
      • q: The search query (required).
      • nsfw: Whether to include NSFW content (true or false). Defaults to false.

Response

  • Successful Response:

    • Returns a JSON response with status 200 and an array of image results.
    {
      "status": 200,
      "count": 10,
      "result": [
        {
          "url": "https://example.com/image.jpg",
          "width": 800,
          "height": 600
        },
        {
          "url": "https://example.com/image2.jpg",
          "width": 1200,
          "height": 900
        },
        ...
      ]
    }
  • Error Response:

    • Returns a JSON response with status 400 and an error message if the q parameter is missing.
    {
      "status": 400,
      "message": "Missing param 'q'"
    }

License

This project is licensed under the MIT License - see the LICENSE file for details.


Feel free to adjust and expand this README based on additional features, setup instructions, or any other relevant information specific to your project!