leetcode_unofficial_api

Last updated:

0 purchases

leetcode_unofficial_api Image
leetcode_unofficial_api Images
Add to Cart

Description:

leetcode unofficial api

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
copied to clipboard
Then, run:
$ flutter pub get
copied to clipboard
Usage #
Import the package: #
import 'package:leetcode_api/leetcode_api.dart';
copied to clipboard
Initialize the API with your LeetCode username:
await LeetCodeAPI.initializeApp('your_username');
copied to clipboard
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');
copied to clipboard
Methods #
initializeApp #
Initialize the LeetCode API with your username.
await LeetCodeAPI.initializeApp('your_username');
copied to clipboard
userData #
Fetch user details.
final UserData ?userData = await LeetCodeAPI.instance.userData();
copied to clipboard
languageStats #
Fetch language statistics.
final LanguagesAndProblemCounts? languageStats = await LeetCodeAPI.instance.languageStats();
copied to clipboard
userBadges #
Fetch user badges.
final LCBadges? userBadges = await LeetCodeAPI.instance.userBadges();
copied to clipboard
userActiveBadge #
Fetch user's active badge.
final LCBadge? userActiveBadge = await LeetCodeAPI.instance.userActiveBadge();
copied to clipboard
recentSubmissions #
Fetch recent submissions.
final Submissions? recentSubmissions = await LeetCodeAPI.instance.recentSubmissions();
copied to clipboard
solvedProblemCount #
Fetch the count of solved problems.
final SubmitStats? solvedProblemCount = await LeetCodeAPI.instance.solvedProblemCount();
copied to clipboard
dailyProblem #
Fetch the daily problem.
final Problem? dailyProblem = await LeetCodeAPI.instance.dailyProblem();
copied to clipboard
selectProblem #
Fetch a specific problem by its title slug.
final Problem? selectedProblem = await LeetCodeAPI.instance.selectProblem(titleSlug: 'problem_title_slug');
copied to clipboard
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}');
}
copied to clipboard
Contributing: #
We welcome contributions from the community! Feel free to submit pull requests with enhancements, bug fixes, or additional features.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.