Skip to content

bkanhu/metadata-extract-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Metadata Extractor API

This project provides an API for extracting metadata from a given URL using Node.js, Express, Axios, and Cheerio.

Table of Contents

Installation

Clone the repository:

git clone https://github.com/yourusername/metadata-extractor-api.git
cd metadata-extractor-api

Install dependencies:

npm install

Create a .env file in the root directory and add the following:

PORT=8080

Start the server:

npm start

The server will start running on http://localhost:8080.

Usage

Example Request with curl

curl -X POST http://localhost:8080/get-metadata \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com"}'

API Endpoints

GET /

  • URL: /
  • Method: GET
  • Description: Returns a "Hello World!" message to ensure the server is running.

Response 200 OK

Hello World!
  • POST /get-metadata
  • Description: Fetches and returns metadata from a given URL.

POST /get-metadata

  • URL: /get-metadata
  • Method: POST
  • Headers: Content-Type: application/json
  • Body:
{
  "url": "https://example.com"
}

Response 200 OK

{
  "title": "Example Domain",
  "metaDescription": "Example Description",
  "ogImage": "https://example.com/og-image.jpg",
  "ogUrl": "https://example.com",
  "url": "https://example.com"
}

400 Bad Request

{
  "error": "URL is required"
}

500 Internal Server Error

{
  "error": "Failed to fetch URL"
}

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any bugs, improvements, or new features.

  • Fork the repository.
  • Create a new branch (git checkout -b feature-branch).
  • Commit your changes (git commit -m 'Add some feature').
  • Push to the branch (git push origin feature-branch).
  • Open a pull request.

License

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors