Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 52 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
</p>

<p align="center">
<img src="https://img.shields.io/github/issues-closed/arnoob16/GeeksForGeeksAPI?style=for-the-badge">
<img src="https://img.shields.io/github/issues-pr-closed/arnoob16/GeeksForGeeksAPI?color=green&style=for-the-badge">
Forked from <a href="https://github.com/arnoob16/GeeksForGeeksAPI">arnoob16/GeeksForGeeksAPI</a>
</p>

---
Expand All @@ -21,9 +20,15 @@

## Endpoints

To access the API, there is only 1 endpoint, *https://geeks-for-geeks-api.vercel.app/yourGeeksForGeeksUsername*
To access the API, there is 2 endpoints,

`Sample URL` - https://geeks-for-geeks-api.vercel.app/arnoob16
1. *https://geeks-for-geeks-stats.vercel.app/userdata/yourGeeksForGeeksUsername* - This endpoint will give you all the data of the user.

`Sample URL` - https://geeks-for-geeks-stats.vercel.app/userdata/sandiplowsnuf

2. *https://geeks-for-geeks-stats.vercel.app/stats/yourGeeksForGeeksUsername* - This endpoint will give you an svg image of the user's profile stats.

`Sample URL` - https://geeks-for-geeks-stats.vercel.app/stats/sandiplowsnuf

## How was it built:
The API was built using Web Scraping the profile page and a server deployed on web.
Expand Down Expand Up @@ -52,53 +57,71 @@ The API was built using Web Scraping the profile page and a server deployed on w
---

### Sample API Responses
#### Success Response


#### Sample stats Image
https://geeks-for-geeks-stats.vercel.app/stats/aganswiar

<img src="https://geeks-for-geeks-stats.vercel.app/stats/aganswiar" alt="sample image" >

---

#### Userdata: Success Response
https://geeks-for-geeks-stats.vercel.app/userdata/aganswiar
```
{
"info": {
"userName": "arnoob16",
"userName": "aganswiar",
"profilePicture": "https://media.geeksforgeeks.org/img-practice/user_web-1598433228.svg",
"instituteRank": "415",
"currentStreak": "00",
"maxStreak": "929",
"institution": "SRM Institute of Science and Technology ",
"languagesUsed": "Java, C++, Python",
"codingScore": "224",
"totalProblemsSolved": "95",
"monthlyCodingScore": ""
"instituteRank": "527",
"currentStreak": "03",
"maxStreak": "1170",
"institution": "National Institute of Technology, Durgapur (NIT Durgapur) ",
"languagesUsed": "C++, Java, Python",
"campusAmbassador": "algo_artisan_sandip",
"codingScore": "357",
"totalProblemsSolved": "144",
"monthlyCodingScore": "28"
},
"solvedStats": {
"school": {
"count": 0,
"questions": []
},
"basic": {
"count": 16,
"count": 19,
"questions": [
{
"question": "Cyclically rotate an array by one",
"questionUrl": "https://practice.geeksforgeeks.org/problems/cyclically-rotate-an-array-by-one2614/0"
"question": "Set the rightmost unset bit",
"questionUrl": "https://practice.geeksforgeeks.org/problems/set-the-rightmost-unset-bit4436/0"
},
{
"question": "Union of two arrays",
"questionUrl": "https://practice.geeksforgeeks.org/problems/union-of-two-arrays3538/0"
"question": "Odd or Even",
"questionUrl": "https://practice.geeksforgeeks.org/problems/odd-or-even3618/0"
},
{
"question": "Middle of Three",
"questionUrl": "https://practice.geeksforgeeks.org/problems/middle-of-three2926/0"
}
...
]
},
"hard": {
"count": 2,
"easy": {
"count": 71,
"questions": [
{
"question": "Merge Without Extra Space",
"questionUrl": "https://practice.geeksforgeeks.org/problems/merge-two-sorted-arrays5135/0"
"question": "Array Leaders",
"questionUrl": "https://practice.geeksforgeeks.org/problems/leaders-in-an-array-1587115620/0"
},
{
"question": "Disjoint set (Union-Find)",
"questionUrl": "https://practice.geeksforgeeks.org/problems/disjoint-set-union-find/0"
},
...
]
},
"hard": {
"count": 1,
"questions": [
{
"question": "Return two prime numbers",
"questionUrl": "https://practice.geeksforgeeks.org/problems/return-two-prime-numbers2509/0"
"question": "Alien Dictionary",
"questionUrl": "https://practice.geeksforgeeks.org/problems/alien-dictionary/0"
}
]
}
Expand Down
17 changes: 15 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
from flask import Flask
from flask import Flask, Response, render_template
from flask_restful import Api, Resource
from modules.scrap import scrap

app = Flask(__name__)
api = Api(app)

@app.route('/')
def index():
return render_template('index.html')

class geeksforgeeksAPI(Resource):
def get(self, username):
scrapper = scrap(username)
return scrapper.fetchResponse()


api.add_resource(geeksforgeeksAPI, "/<string:username>")
api.add_resource(geeksforgeeksAPI, "/userdata/<string:username>")

@app.route('/stats/<string:username>')
def stats(username):
scrapper = scrap(username)
userdata = scrapper.fetchResponse()
svg = render_template('stats.html', userdata=userdata)

return Response(svg, mimetype='image/svg+xml')


if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, debug=True)
20 changes: 17 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
requests==2.31.0
aniso8601==9.0.1
beautifulsoup4==4.12.3
blinker==1.8.2
certifi==2024.8.30
charset-normalizer==3.4.0
click==8.1.7
Flask==2.3.1
Flask_RESTful==0.3.10
beautifulsoup4==4.12.3
Flask-RESTful==0.3.10
idna==3.10
itsdangerous==2.2.0
Jinja2==3.1.4
MarkupSafe==3.0.1
pytz==2024.2
requests==2.31.0
six==1.16.0
soupsieve==2.6
urllib3==2.2.3
Werkzeug==3.0.4
Loading