Skip to content

LeetCode data pipeline depends on unreliable third-party API hosted on Render free tier #217

@amaydixit11

Description

@amaydixit11

Bug Description

The LeetCode data fetching relies on an unmaintained third-party API (alfa-leetcode-api.onrender.com) that is prone to downtime on Render's free tier.

Affected File

api/leaderboard/views.py:463

Problem

def get_leetcode_data(self, username):
    url = f"https://alfa-leetcode-api.onrender.com/userProfile/{username}"
    response = requests.get(url)

This API:

  1. Is hosted on Render's free tier (sleeps after 15 min of inactivity)
  2. Is not officially maintained by LeetCode
  3. Could be taken down at any time
  4. Introduces a single point of failure for ALL LeetCode data

If this API is down, no LeetCode user data can be refreshed, and the entire LeetCode leaderboard section becomes stale.

Proposed Fix

The codebase already has commented-out code in api/leaderboard/api/views.py (lines 374-418) that queries LeetCode's official GraphQL endpoint at leetcode.com/graphql directly. This should be the primary data source.

LeetCode's GraphQL schema supports:

query { userContestRankingHistory(username: "...") { attended ranking contest { title startTime } } }
query { matchedUser(username: "...") { submitStats: submitStatsGlobal { acSubmissionNum { difficulty count submissions } } profile { reputation ranking reputation } } }

Implement direct calls to https://leetcode.com/graphql with proper query parameters. The existing commented code in get_data_from_url() and ContestRankingsAPIView() shows the pattern already works.

Severity

MEDIUM — Complete data pipeline failure when the third-party API is unavailable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    advancedComplex issues requiring experienced contributorsbugbug d73a4a 'Something isn't working'securitysecurity d73a4a 'Security vulnerability'

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions