Create and list projects

In this tutorial you will learn how to work with projects using Encord's Python SDK.

ℹ️

Note

Make sure that you have a public-private key pair that you've authenticated with Encord before you start.

Creating projects

New projects are created using the create_project() method. create_project() returns a unique ID known as the <project_hash> of the created project, and the user that calls this method automatically becomes the admin of the project.

ℹ️

Note

Projects cannot be deleted using the SDK or the API. Use the Encord platform to delete projects.

# Import dependencies
from encord.user_client import EncordUserClient

#Authenticate using the path to your private key
user_client = EncordUserClient.create_with_ssh_private_key(ssh_private_key_path='<private_key_path>')

# Create a project my specifying a title, the hashes of the datasets you'd like to attach, and a description
project_hash = user_client.create_project(
    "Example project title",
    ["<dataset_hash_1>", "<dataset_hash_2>"],
    "Example project description",
)

# Prints the hash of the project you've just created
print(project_hash)


# The <project_hash>
"046550d1-13fe-4052-ac99-e6a2d84f9b72"  

Listing existing projects

You can query and list all the available projects for a given user. In the example below, a user authenticates with Encord and then fetches all projects available using the get_projects() method.


# Import dependencies
from encord.user_client import EncordUserClient

#Authenticate using the path to your private key
user_client = EncordUserClient.create_with_ssh_private_key(ssh_private_key_path="<private_key_path>")

# List existing projects
projects = user_client.get_projects()
print(projects)


[
    {
        "project": {
            "created_at": datetime.datetime(...),
            "description": "Example description",
            "last_edited_at": datetime.datetime(...),
            "project_hash": "<project_hash>",
            "title": "Example title"
        },
        "user_role": <ProjectUserRole.ADMIN: 0>
    },
    ...
]

👍

Tip

The get_projects() method has multiple optional arguments that allow you to perform a filtered search when querying projects. For example, if you only want projects with titles starting with “Validation”, you could use userclient.get_project(title_like="Validation%"). Other keyword arguments such as _created_before or edited_after may also be of interest.