Skip to content

This API allows you to generate random quotes based on a given input and language.

Notifications You must be signed in to change notification settings

ryarturogi/random-quotes-generator-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Random Quote Generator API

This API allows you to generate random quotes based on a given input and language.

Getting Started

These instructions will help you to get a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • A Vercel account
  • A GitHub or GitLab repository for the project
  • OpenAI API key
  • npm (comes with Node.js)

Installing

Clone the repository to your local machine
git clone https://github.com/ryarturogi/random-quote-generator-api.git

Go to the project directory
cd random-quote-generator-api

Install the dependencies
npm install

Set your OpenAI API key in the .env file
NEXT_PUBLIC_OPENAI_API_KEY: '<YOUR_API_KEY>',
NEXT_PUBLIC_OPENAI_API_URL: 'https://api.openai.com/v1/completions'

Start the server
npm run dev or yarn dev

The API will be available at http://localhost:3000/api/generate-quote.

Usage

  • Send a POST request to the /api/generate-quote endpoint with a JSON payload containing the input field and the language field.

  • The response will be a JSON object containing the generated quote.

Example

{
"quote": "The quote generated by the API",
"language": "english" // any languague
}

Deployment

To deploy the API to a production environment on Vercel, you should consider the following steps:

  • Connect your repository to your Vercel account
  • Set your OpenAI API key in the .env file as an environment variable in Vercel
  • Use a logging service such as Loggly or Splunk to collect and analyze the logs
  • Use a monitoring service such as New Relic or Prometheus to monitor the performance of the API

Built With

Authors

License

This project is licensed under the MIT License - see the [MIT]((https://github.com/ryarturogi/random-quote-generator-api/LICENSE) file for details