Skip to content

Commit

Permalink
Addition of GFG API and Course Catalog Project
Browse files Browse the repository at this point in the history
  • Loading branch information
Shariq2003 committed Oct 9, 2024
1 parent 92aa0ad commit 88a10ef
Show file tree
Hide file tree
Showing 29 changed files with 22,540 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Web_Development/GFG-API/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
.cache/
59 changes: 59 additions & 0 deletions Web_Development/GFG-API/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# GFG Public API

GFG Public API is a Node.js application that fetches user data from GeeksforGeeks (GFG) using Puppeteer. This API allows you to retrieve details like user profile, rank, coding scores, solved problems, and more.
Deployment : https://gfg-api-tzvp.onrender.com/

## Features

- Fetch user profile data from GFG.
- Retrieve coding scores, ranks, and solved problems.
- Simple and easy-to-use API.

## Prerequisites

- Node.js (>= 14.20.1)
- npm or yarn

## Getting Started

### Installation

1. Clone the repository:

```sh
git clone https://github.com/Shariq2003/GFG_API.git
```

2. Navigate to the project directory:

```sh
cd GFG_API
```

3. Install the dependencies:

```sh
npm install
```

### Running Locally

1. Install Puppeteer and its dependencies:

```sh
npx puppeteer browsers install chrome
```

2. Start the server:

```sh
npm start
```

or

```sh
npm run dev
```

4. Open your browser and navigate to `http://localhost:3000/<username>` to fetch the data for a specific GFG user.
32 changes: 32 additions & 0 deletions Web_Development/GFG-API/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const express=require('express');
const userData = require('./userData');

const app = express();

app.get('/',(req,res)=>{
res.send("GFG API Listening || By Shariq");
})

app.get('/:userName', async (req, res) => {
try{
const userName = req.params.userName;
console.log(userName);
const data = await userData(userName);
console.log(data)
if(!data){
res.send("User name not found !")
}
else{
res.send(data);
}
}
catch{
console.error('Error fetching user data');
res.status(500).send('Internal Server Error');
}
// res.send("GFG API Listening || By Shariq");
})

app.listen(3000,()=>{
console.log("GFG API Listening on PORT 3000");
});
Loading

0 comments on commit 88a10ef

Please sign in to comment.