Project Management
Read Project
Request
The projectId for the project to read, or nothing to get a details list of all projects. The /projects/read
API accepts requests in the following format:
ReadProjectRequest Model - Request to get details about a specific project or a details list of all projects. | |
---|---|
projectId | integer Id of the project. If not provided the API will return a details list of all projects. |
Example |
{ "projectId": 23456789 } |
Responses
The /projects/read
API provides a response in the following format:
200 Success
ProjectListResponse Model - Project list response. | |
---|---|
projects | Project Array List of projects for the authenticated user. |
versions | LeanVersion Array List of LEAN versions. |
success | boolean Indicate if the API request was successful. |
errors | string Array List of errors with the API call. |
Example |
{ "projects": [ { "projectId": 23456789, "organizationId": "5cad178b20a1d52567b534553413b691", "name": "string", "modified": "2021-11-26T15:18:27.693Z", "created": "2021-11-26T15:18:27.693Z", "ownerId": 0, "language": "C#", "collaborators": [ { "uid": 0, "liveControl": true, "permission": "read", "publicId": "string", "profileImage": "https://cdn.quantconnect.com/web/i/users/profile/abc123.jpeg", "email": "abc@123.com", "name": "string", "bio": "string", "owner": true } ], "leanVersionId": 0, "leanPinnedToMaster": true, "owner": true, "description": "string", "channelId": "string", "parameters": [ { "name": "string", "value": 0 } ], "libraries": [ { "projectId": 23456789, "libraryName": "string", "ownerName": "string", "access": true } ], "grid": "string", "liveGrid": "string", "paperEquity": 0, "lastLiveDeployment": "2021-11-26T15:18:27.693Z", "liveForm": , "encrypted": true, "codeRunning": true, "leanEnvironment": 0, "encryptionKey": { "id": "string", "name": "string" } } ], "versions": [ { "id": 0, "created": "2021-11-26T15:18:27.693Z", "description": "string", "leanHash": "string", "leanCloudHash": "string", "name": "string", "ref": "string", "public": 0 } ], "success": true, "errors": [ "string" ] } |
Project Model - Response from reading a project by id. | |
---|---|
projectId | integer Project id. |
organizationId | string Orgainization id. |
name | string Name of the project. |
modified | string($date-time) Modified date for the project. |
created | string($date-time) Date the project was created. |
ownerId | integer Owner id. |
language | string Enum Programming language of the project. Options : ['C#', 'Py'] |
collaborators | Collaborator Array List of collaborators. |
leanVersionId | integer The version of LEAN this project is running on. |
leanPinnedToMaster | boolean Indicate if the project is pinned to the master branch of LEAN. |
owner | boolean Indicate if you are the owner of the project. |
description | string The project description. |
channelId | string Channel id. |
parameters | ParameterSet Array Optimization parameters. |
libraries | Library Array The library projects. |
grid | string Configuration of the backtest view grid. |
liveGrid | string Configuration of the live view grid. |
paperEquity | number The equity value of the last paper trading instance. |
lastLiveDeployment | string($date-time) The last live deployment active time. |
liveForm | object The last live wizard content used. |
encrypted | boolean Indicates if the project is encrypted. |
codeRunning | boolean Indicates if the project is running or not. |
leanEnvironment | integer LEAN environment of the project running on. |
encryptionKey | EncryptionKey object Encryption key details. |
Example |
{ "projectId": 23456789, "organizationId": "5cad178b20a1d52567b534553413b691", "name": "string", "modified": "2021-11-26T15:18:27.693Z", "created": "2021-11-26T15:18:27.693Z", "ownerId": 0, "language": "C#", "collaborators": [ { "uid": 0, "liveControl": true, "permission": "read", "publicId": "string", "profileImage": "https://cdn.quantconnect.com/web/i/users/profile/abc123.jpeg", "email": "abc@123.com", "name": "string", "bio": "string", "owner": true } ], "leanVersionId": 0, "leanPinnedToMaster": true, "owner": true, "description": "string", "channelId": "string", "parameters": [ { "name": "string", "value": 0 } ], "libraries": [ { "projectId": 23456789, "libraryName": "string", "ownerName": "string", "access": true } ], "grid": "string", "liveGrid": "string", "paperEquity": 0, "lastLiveDeployment": "2021-11-26T15:18:27.693Z", "liveForm": , "encrypted": true, "codeRunning": true, "leanEnvironment": 0, "encryptionKey": { "id": "string", "name": "string" } } |
Collaborator Model | |
---|---|
uid | integer User ID. |
liveControl | boolean Indicate if the user have live control. |
permission | string Enum The permission this user is given. Options : ['read', 'write'] |
publicId | string The user public ID. |
profileImage | string The url of the user profile image. |
string The registered email of the user. | |
name | string The display name of the user. |
bio | string The biography of the user. |
owner | boolean Indicate if the user is the owner of the project. |
Example |
{ "uid": 0, "liveControl": true, "permission": "read", "publicId": "string", "profileImage": "https://cdn.quantconnect.com/web/i/users/profile/abc123.jpeg", "email": "abc@123.com", "name": "string", "bio": "string", "owner": true } |
ParameterSet Model - Parameter set. | |
---|---|
name | string Name of parameter. |
value | number Value of parameter. |
Example |
{ "name": "string", "value": 0 } |
Library Model | |
---|---|
projectId | integer Project Id of the library project. |
libraryName | string Name of the library project. |
ownerName | string Name of the library project owner. |
access | boolean Indicate if the library project can be accessed. |
Example |
{ "projectId": 23456789, "libraryName": "string", "ownerName": "string", "access": true } |
EncryptionKey Model - Encryption key details. | |
---|---|
id | string Encryption key id. |
name | string Name of the encryption key. |
Example |
{ "id": "string", "name": "string" } |
LeanVersion Model | |
---|---|
id | integer ID of the LEAN version. |
created | string($date-time) Date when this version was created. |
description | string Description of the LEAN version. |
leanHash | string Commit Hash in the LEAN repository. |
leanCloudHash | string Commit Hash in the LEAN Cloud repository. |
name | string Name of the branch where the commit is. |
ref | string Reference to the branch where the commit is. |
public | integer Indicates if the version is available for the public (1) or not (0). |
Example |
{ "id": 0, "created": "2021-11-26T15:18:27.693Z", "description": "string", "leanHash": "string", "leanCloudHash": "string", "name": "string", "ref": "string", "public": 0 } |
401 Authentication Error
UnauthorizedError Model - Unauthorized response from the API. Key is missing, invalid, or timestamp is too old for hash. | |
---|---|
www_authenticate | string Header |
Examples
The following example demonstates creating, reading, updating, and deleting a project through the cloud API.
from base64 import b64encode from hashlib import sha256 from time import time from requests import get, post BASE_URL = 'https://www.quantconnect.com/api/v2/' # You need to replace these with your actual credentials. # You can request your credentials at https://www.quantconnect.com/settings/ # You can find our organization ID at https://www.quantconnect.com/organization/ USER_ID = 0 API_TOKEN = '____' ORGANIZATION_ID = '____' def get_headers(): # Get timestamp timestamp = f'{int(time())}' time_stamped_token = f'{API_TOKEN}:{timestamp}'.encode('utf-8') # Get hased API token hashed_token = sha256(time_stamped_token).hexdigest() authentication = f'{USER_ID}:{hashed_token}'.encode('utf-8') authentication = b64encode(authentication).decode('ascii') # Create headers dictionary. return { 'Authorization': f'Basic {authentication}', 'Timestamp': timestamp } # Authenticate to verify credentials response = post(f'{BASE_URL}/authenticate', headers = get_headers()) print(response.json()) # -------------------- # The project ID of the project to manage project_id = 12345678 ### Create Project # Send a POST request to the /projects/create endpoint to create a new project response = post(f'{BASE_URL}/projects/create', headers=get_headers(), json={ "name": f"Project_{int(time())}", # Unique project name using current timestamp "language": "Py" # Programming language for the project (Python) }) # Parse the JSON response into python managable dict result = response.json() # Extract the project ID from the response project_id = result['projects'][0]['projectId'] # Check if the request was successful and print the result if result['success']: print("Project Created Successfully:") print(result) ### Read Project # Prepare data payload to read project details payload = { "id": project_id # ID of the project to read } # Send a POST request to the /projects/read endpoint to get project details response = post(f'{BASE_URL}/projects/read', headers=get_headers(), json=payload) # Parse the JSON response into python managable dict result = response.json() # Check if the request was successful and print the project details if result['success']: print("Project Details:") print(result) ### Update Project # Send a POST request to the /projects/update endpoint to update project details response = post(f'{BASE_URL}/projects/update', headers=get_headers(), json={ "projectId": project_id, # ID of the project to update "name": f"Project_{project_id}", # New name for the project "description": "The new project name is awesome!" # New description }) # Parse the JSON response into python managable dict result = response.json() # Check if the request was successful and print the result if result['success']: print("Project Updated Successfully:") print(result) ### Delete Project # Prepare data payload to delete the project payload = { "projectId": project_id # ID of the project to delete } # Send a POST request to the /projects/delete endpoint to delete the project response = post(f'{BASE_URL}/projects/delete', headers=get_headers(), json=payload) # Parse the JSON response into python managable dict result = response.json() # Check if the request was successful and print the result if result['success']: print("Project Deleted Successfully:") print(result)