Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fspv/python-leetcode
python client for leetcode api
https://github.com/fspv/python-leetcode
leetcode python
Last synced: about 1 month ago
JSON representation
python client for leetcode api
- Host: GitHub
- URL: https://github.com/fspv/python-leetcode
- Owner: fspv
- License: mit
- Created: 2021-07-21T17:42:53.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-06T17:31:14.000Z (almost 3 years ago)
- Last Synced: 2024-10-04T01:45:31.768Z (3 months ago)
- Topics: leetcode, python
- Language: Python
- Homepage:
- Size: 372 KB
- Stars: 72
- Watchers: 2
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.generated.md
- License: LICENSE
Awesome Lists containing this project
README
# leetcode
Leetcode API implementation.This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API version: 1.0.1-1
- Package version: 1.0.0
- Build package: io.swagger.codegen.v3.generators.python.PythonClientCodegen## Requirements.
Python 2.7 and 3.4+
## Installation & Usage
### pip installIf the python package is hosted on Github, you can install directly from Github
```sh
pip install git+https://github.com/prius/python-leetcode.git
```
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/prius/python-leetcode.git`)Then import the package:
```python
import leetcode
```### Setuptools
Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
```sh
python setup.py install --user
```
(or `sudo python setup.py install` to install the package for all users)Then import the package:
```python
import leetcode
```## Getting Started
Please follow the [installation procedure](#installation--usage) and then run the following:
```python
from __future__ import print_function
import time
import leetcode
from leetcode.rest import ApiException
from pprint import pprint# Configure API key authorization: cookieCSRF
configuration = leetcode.Configuration()
configuration.api_key['csrftoken'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['csrftoken'] = 'Bearer'
# Configure API key authorization: cookieSession
configuration = leetcode.Configuration()
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
# Configure API key authorization: headerCSRF
configuration = leetcode.Configuration()
configuration.api_key['x-csrftoken'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['x-csrftoken'] = 'Bearer'
# Configure API key authorization: referer
configuration = leetcode.Configuration()
configuration.api_key['Referer'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Referer'] = 'Bearer'# create an instance of the API class
api_instance = leetcode.DefaultApi(leetcode.ApiClient(configuration))
topic = 'topic_example' # str |try:
api_response = api_instance.api_problems_topic_get(topic)
pprint(api_response)
except ApiException as e:
print("Exception when calling DefaultApi->api_problems_topic_get: %s\n" % e)# Configure API key authorization: cookieCSRF
configuration = leetcode.Configuration()
configuration.api_key['csrftoken'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['csrftoken'] = 'Bearer'
# Configure API key authorization: cookieSession
configuration = leetcode.Configuration()
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
# Configure API key authorization: headerCSRF
configuration = leetcode.Configuration()
configuration.api_key['x-csrftoken'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['x-csrftoken'] = 'Bearer'
# Configure API key authorization: referer
configuration = leetcode.Configuration()
configuration.api_key['Referer'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Referer'] = 'Bearer'# create an instance of the API class
api_instance = leetcode.DefaultApi(leetcode.ApiClient(configuration))
body = leetcode.GraphqlQuery() # GraphqlQuery | GraphQL query (optional)try:
api_response = api_instance.graphql_post(body=body)
pprint(api_response)
except ApiException as e:
print("Exception when calling DefaultApi->graphql_post: %s\n" % e)# Configure API key authorization: cookieCSRF
configuration = leetcode.Configuration()
configuration.api_key['csrftoken'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['csrftoken'] = 'Bearer'
# Configure API key authorization: cookieSession
configuration = leetcode.Configuration()
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
# Configure API key authorization: headerCSRF
configuration = leetcode.Configuration()
configuration.api_key['x-csrftoken'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['x-csrftoken'] = 'Bearer'
# Configure API key authorization: referer
configuration = leetcode.Configuration()
configuration.api_key['Referer'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Referer'] = 'Bearer'# create an instance of the API class
api_instance = leetcode.DefaultApi(leetcode.ApiClient(configuration))
problem = 'problem_example' # str |
body = leetcode.TestSubmission() # TestSubmission | Solution to test (optional)try:
api_response = api_instance.problems_problem_interpret_solution_post(problem, body=body)
pprint(api_response)
except ApiException as e:
print("Exception when calling DefaultApi->problems_problem_interpret_solution_post: %s\n" % e)# Configure API key authorization: cookieCSRF
configuration = leetcode.Configuration()
configuration.api_key['csrftoken'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['csrftoken'] = 'Bearer'
# Configure API key authorization: cookieSession
configuration = leetcode.Configuration()
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
# Configure API key authorization: headerCSRF
configuration = leetcode.Configuration()
configuration.api_key['x-csrftoken'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['x-csrftoken'] = 'Bearer'
# Configure API key authorization: referer
configuration = leetcode.Configuration()
configuration.api_key['Referer'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Referer'] = 'Bearer'# create an instance of the API class
api_instance = leetcode.DefaultApi(leetcode.ApiClient(configuration))
problem = 'problem_example' # str |
body = leetcode.Submission() # Submission | Solution to test (optional)try:
api_response = api_instance.problems_problem_submit_post(problem, body=body)
pprint(api_response)
except ApiException as e:
print("Exception when calling DefaultApi->problems_problem_submit_post: %s\n" % e)# Configure API key authorization: cookieCSRF
configuration = leetcode.Configuration()
configuration.api_key['csrftoken'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['csrftoken'] = 'Bearer'
# Configure API key authorization: cookieSession
configuration = leetcode.Configuration()
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
# Configure API key authorization: headerCSRF
configuration = leetcode.Configuration()
configuration.api_key['x-csrftoken'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['x-csrftoken'] = 'Bearer'
# Configure API key authorization: referer
configuration = leetcode.Configuration()
configuration.api_key['Referer'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Referer'] = 'Bearer'# create an instance of the API class
api_instance = leetcode.DefaultApi(leetcode.ApiClient(configuration))
id = leetcode.Id() # Id | Either submission id (int) or interpretation id (string)try:
api_response = api_instance.submissions_detail_id_check_get(id)
pprint(api_response)
except ApiException as e:
print("Exception when calling DefaultApi->submissions_detail_id_check_get: %s\n" % e)
```## Documentation for API Endpoints
All URIs are relative to *https://leetcode.com*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**api_problems_topic_get**](docs/DefaultApi.md#api_problems_topic_get) | **GET** /api/problems/{topic}/ |
*DefaultApi* | [**graphql_post**](docs/DefaultApi.md#graphql_post) | **POST** /graphql |
*DefaultApi* | [**problems_problem_interpret_solution_post**](docs/DefaultApi.md#problems_problem_interpret_solution_post) | **POST** /problems/{problem}/interpret_solution/ |
*DefaultApi* | [**problems_problem_submit_post**](docs/DefaultApi.md#problems_problem_submit_post) | **POST** /problems/{problem}/submit/ |
*DefaultApi* | [**submissions_detail_id_check_get**](docs/DefaultApi.md#submissions_detail_id_check_get) | **GET** /submissions/detail/{id}/check/ |## Documentation For Models
- [AnyOfGraphqlQueryVariables](docs/AnyOfGraphqlQueryVariables.md)
- [AnyOfGraphqlQuestionDetailSolution](docs/AnyOfGraphqlQuestionDetailSolution.md)
- [BaseSubmissionResult](docs/BaseSubmissionResult.md)
- [Difficulty](docs/Difficulty.md)
- [GraphqlData](docs/GraphqlData.md)
- [GraphqlProblemsetQuestionList](docs/GraphqlProblemsetQuestionList.md)
- [GraphqlQuery](docs/GraphqlQuery.md)
- [GraphqlQueryGetQuestionDetailVariables](docs/GraphqlQueryGetQuestionDetailVariables.md)
- [GraphqlQueryProblemsetQuestionListVariables](docs/GraphqlQueryProblemsetQuestionListVariables.md)
- [GraphqlQueryProblemsetQuestionListVariablesFilterInput](docs/GraphqlQueryProblemsetQuestionListVariablesFilterInput.md)
- [GraphqlQueryVariables](docs/GraphqlQueryVariables.md)
- [GraphqlQuestionCodeSnippet](docs/GraphqlQuestionCodeSnippet.md)
- [GraphqlQuestionContributor](docs/GraphqlQuestionContributor.md)
- [GraphqlQuestionDetail](docs/GraphqlQuestionDetail.md)
- [GraphqlQuestionSolution](docs/GraphqlQuestionSolution.md)
- [GraphqlQuestionTopicTag](docs/GraphqlQuestionTopicTag.md)
- [GraphqlResponse](docs/GraphqlResponse.md)
- [GraphqlUser](docs/GraphqlUser.md)
- [Id](docs/Id.md)
- [InlineResponse200](docs/InlineResponse200.md)
- [Interpretation](docs/Interpretation.md)
- [OneOfid](docs/OneOfid.md)
- [OneOfinlineResponse200](docs/OneOfinlineResponse200.md)
- [Problems](docs/Problems.md)
- [Stat](docs/Stat.md)
- [StatStatusPair](docs/StatStatusPair.md)
- [Submission](docs/Submission.md)
- [SubmissionId](docs/SubmissionId.md)
- [SubmissionResult](docs/SubmissionResult.md)
- [TestSubmission](docs/TestSubmission.md)
- [TestSubmissionResult](docs/TestSubmissionResult.md)## Documentation For Authorization
## cookieCSRF
- **Type**: API key
- **API key parameter name**: csrftoken
- **Location**: URL query string## cookieSession
- **Type**: API key
- **API key parameter name**: LEETCODE_SESSION
- **Location**: URL query string## headerCSRF
- **Type**: API key
- **API key parameter name**: x-csrftoken
- **Location**: HTTP header## referer
- **Type**: API key
- **API key parameter name**: Referer
- **Location**: HTTP header## Author