Coder Social home page Coder Social logo

leetcode_unofficial_api's Introduction

LeetCode Unofficial API

A Dart package providing an unofficial API for interacting with LeetCode. This package allows you to fetch user details, language statistics, user badges, recent submissions, solved problem counts, and more.

Features:

Scrape problem data: Access problem titles, difficulties, categories, acceptance rates, and potentially other publicly available information (subject to LeetCode's website structure changes).

Retrieve user data: Fetch details like profile information, language-wise problem counts, badges earned, recent submissions, and solved problem count.

Get problem details: Obtain information about the daily challenge problem or a specific problem by its title slug.

Lightweight and flexible: Designed for ease of use in various programming environments.

Unofficial and community-driven: Continuously maintained and improved by the developer community.

Disclaimer:

Unofficial: This API is not affiliated with or endorsed by LeetCode.

Respectful usage: Use responsibly and ethically, adhering to LeetCode's terms of service and avoiding excessive scraping that could overload their servers.

Rate limiting: Be prepared to implement rate limiting mechanisms in your code to prevent overwhelming LeetCode's infrastructure. LeetCode may throttle requests or block IP addresses if usage patterns violate their guidelines.

Installation

To use this package, add leetcode_api as a dependency in your pubspec.yaml file:

dependencies:
  leetcode_api: ^1.0.0

Then, run:

$ flutter pub get

Usage

Import the package:

import 'package:leetcode_api/leetcode_api.dart';

Initialize the API with your LeetCode username:

await LeetCodeAPI.initializeApp('your_username');

Now, you can use the provided methods to interact with the LeetCode API:

final UserData? userData = await LeetCodeAPI.instance.userData();
final LanguagesAndProblemCounts? = await LeetCodeAPI.instance.languageStats();
final LCBadges? userBadges = await LeetCodeAPI.instance.userBadges();
final LCBadge? userActiveBadge = await LeetCodeAPI.instance.userActiveBadge();
final Submissions? recentSubmissions = await LeetCodeAPI.instance.recentSubmissions();
final SubmitStats? solvedProblemCount = await LeetCodeAPI.instance.solvedProblemCount();
final Problem dailyProblem = await LeetCodeAPI.instance.dailyProblem();
final Problem selectedProblem = await LeetCodeAPI.instance.selectProblem(titleSlug: 'two-sum');

Methods

initializeApp

Initialize the LeetCode API with your username.

await LeetCodeAPI.initializeApp('your_username');

userData

Fetch user details.

final UserData ?userData = await LeetCodeAPI.instance.userData();

languageStats

Fetch language statistics.

final LanguagesAndProblemCounts? languageStats = await LeetCodeAPI.instance.languageStats();

userBadges

Fetch user badges.

final LCBadges? userBadges = await LeetCodeAPI.instance.userBadges();

userActiveBadge

Fetch user's active badge.

final  LCBadge? userActiveBadge = await LeetCodeAPI.instance.userActiveBadge();

recentSubmissions

Fetch recent submissions.

final Submissions? recentSubmissions = await LeetCodeAPI.instance.recentSubmissions();

solvedProblemCount

Fetch the count of solved problems.

final SubmitStats? solvedProblemCount = await LeetCodeAPI.instance.solvedProblemCount();

dailyProblem

Fetch the daily problem.

final Problem? dailyProblem = await LeetCodeAPI.instance.dailyProblem();

selectProblem

Fetch a specific problem by its title slug.

final Problem? selectedProblem = await LeetCodeAPI.instance.selectProblem(titleSlug: 'problem_title_slug');

Exception Handling

The API methods may throw LeetCodeAPIException if not initialized or if the user does not exist.

try {
  // API method calls
} on LeetCodeAPIException catch (e) {
  print('LeetCode API Exception: ${e.errorCode}');
}

Contributing:

We welcome contributions from the community! Feel free to submit pull requests with enhancements, bug fixes, or additional features.

leetcode_unofficial_api's People

Contributors

vijaykarthiktk avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.