-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswagger.yaml
More file actions
270 lines (260 loc) · 8.28 KB
/
swagger.yaml
File metadata and controls
270 lines (260 loc) · 8.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
openapi: 3.0.3
info:
title: LeetCode Profile API
description: |
A Flask-based REST API that fetches and processes comprehensive LeetCode user data including user profiles, submission statistics, and progress tracking by year.
This API provides:
- User profile information (name, bio, company, etc.)
- Problem solving statistics by difficulty
- Submission calendar with yearly breakdowns
- Social media links and professional information
- Redis caching for improved performance (1-hour cache)
- CORS support for cross-origin requests
version: 1.0.0
contact:
name: API Support
email: mehr81@my.yorku.ca
license:
name: MIT
url: https://opensource.org/licenses/MIT
servers:
- url: https://leetcode-api-140473619582.us-central1.run.app
description: Production server (Google Cloud Run)
- url: http://127.0.0.1:5000
description: Development server
paths:
/api/user/{username}:
get:
summary: Get comprehensive LeetCode user data
description: |
Retrieves comprehensive user data from LeetCode including profile information,
problem solving statistics, and submission progress organized by year.
**Performance Features:**
- Results are cached in Redis for 1 hour to improve response times
- Subsequent requests for the same user return cached data
- Cache helps comply with LeetCode's rate limiting
parameters:
- name: username
in: path
required: true
description: LeetCode username to fetch data for
schema:
type: string
example: "john_doe"
responses:
"200":
description: Successful response with user data
content:
application/json:
schema:
$ref: "#/components/schemas/UserData"
examples:
successful_response:
summary: Successful user data response
value:
username: "john_doe"
github: "https://github.com/johndoe"
twitter: "https://twitter.com/johndoe"
linkedin: "https://linkedin.com/in/johndoe"
ranking: 12345
realname: "John Doe"
aboutme: "Software Engineer passionate about algorithms"
school: "MIT"
website: ["https://johndoe.dev"]
country_name: "United States"
company: "Tech Corp"
job_title: "Senior Software Engineer"
skill: ["Python", "JavaScript", "Algorithms"]
progress:
current:
daily:
"2024-01-15": 3
"2024-01-16": 5
total: 180
"2024":
daily:
"2024-01-01": 2
"2024-01-02": 1
total: 365
"2023":
daily:
"2023-12-31": 4
total: 200
problem:
easy:
solved: 150
total: 800
medium:
solved: 100
total: 1600
hard:
solved: 25
total: 700
"400":
description: Bad request - invalid username or request blocked
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
invalid_user:
summary: Invalid username
value:
error: "Could not fetch user data. Maybe invalid username or blocked request."
"500":
description: Internal server error
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
server_error:
summary: Server error
value:
error: "An error occurred: Connection timeout"
components:
schemas:
UserData:
type: object
properties:
username:
type: string
description: LeetCode username
example: "john_doe"
github:
type: string
nullable: true
description: GitHub profile URL
example: "https://github.com/johndoe"
twitter:
type: string
nullable: true
description: Twitter profile URL
example: "https://twitter.com/johndoe"
linkedin:
type: string
nullable: true
description: LinkedIn profile URL
example: "https://linkedin.com/in/johndoe"
ranking:
type: integer
nullable: true
description: LeetCode ranking
example: 12345
realname:
type: string
nullable: true
description: User's real name
example: "John Doe"
aboutme:
type: string
nullable: true
description: User's bio/about section
example: "Software Engineer passionate about algorithms"
school:
type: string
nullable: true
description: Educational institution
example: "MIT"
website:
type: array
items:
type: string
description: List of personal websites
example: ["https://johndoe.dev"]
country_name:
type: string
nullable: true
description: User's country
example: "United States"
company:
type: string
nullable: true
description: Current company
example: "Tech Corp"
job_title:
type: string
nullable: true
description: Current job title
example: "Senior Software Engineer"
skill:
type: array
items:
type: string
description: List of skill tags
example: ["Python", "JavaScript", "Algorithms"]
progress:
type: object
description: Submission progress organized by time periods
properties:
current:
$ref: "#/components/schemas/ProgressPeriod"
"2024":
$ref: "#/components/schemas/ProgressPeriod"
"2023":
$ref: "#/components/schemas/ProgressPeriod"
additionalProperties:
$ref: "#/components/schemas/ProgressPeriod"
problem:
$ref: "#/components/schemas/ProblemStatistics"
required:
- username
- progress
- problem
ProgressPeriod:
type: object
properties:
daily:
type: object
description: Daily submission counts
additionalProperties:
type: integer
example:
"2024-01-15": 3
"2024-01-16": 5
total:
type: integer
description: Total submissions in this period
example: 180
required:
- daily
- total
ProblemStatistics:
type: object
properties:
easy:
$ref: "#/components/schemas/DifficultyStats"
medium:
$ref: "#/components/schemas/DifficultyStats"
hard:
$ref: "#/components/schemas/DifficultyStats"
required:
- easy
- medium
- hard
DifficultyStats:
type: object
properties:
solved:
type: integer
description: Number of problems solved
example: 150
total:
type: integer
description: Total number of problems available
example: 800
required:
- solved
- total
ErrorResponse:
type: object
properties:
error:
type: string
description: Error message describing what went wrong
example: "Could not fetch user data. Maybe invalid username or blocked request."
required:
- error
tags:
- name: User Data
description: Operations related to fetching LeetCode user data