# How to Access Classes defined by Annotation tool from Python?

**URL:** <https://discuss.roboflow.com/t/how-to-access-classes-defined-by-annotation-tool-from-python/4061>\
**Category:** 🤝  Community Help\
**Tags:** export\
**Created:** [December 28, 2023, 6:54pm UTC](https://discuss.roboflow.com/t/how-to-access-classes-defined-by-annotation-tool-from-python/4061 "2023-12-28T18:54:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Francis\_Bacon](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/francis_bacon/32/2140_2.png) [@Francis\_Bacon](https://discuss.roboflow.com/u/Francis_Bacon)\
**Post date:** [December 28, 2023, 6:54pm UTC](https://discuss.roboflow.com/t/how-to-access-classes-defined-by-annotation-tool-from-python/4061/1 "2023-12-28T18:54:08Z")

</div>

How to access Roboflow Class labels created within the Annotation tool, say, with Python?

---

<div class="post-metadata">

**Author:** ![leo](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/leo/32/2228_2.png) [@leo](https://discuss.roboflow.com/u/leo)\
**Post date:** [December 29, 2023, 3:29am UTC](https://discuss.roboflow.com/t/how-to-access-classes-defined-by-annotation-tool-from-python/4061/2 "2023-12-29T03:29:26Z")

</div>

Hi @Francis_Bacon

The Roboflow API returns a `class` property for the [project API endpoint](https://docs.roboflow.com/api-reference/projects/initialize#rest-api). Is that what you’re looking for?

Example based on the documentation:

```auto
{
    "workspace": {
        ...
    },
    "project": {
        ...
        "classes": {
            "class-one": 7,
            "class-two": 8,
            ...
        },
        ...
    }
}

```

---

<div class="post-metadata">

**Author:** ![Francis\_Bacon](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/francis_bacon/32/2140_2.png) [@Francis\_Bacon](https://discuss.roboflow.com/u/Francis_Bacon)\
**Post date:** [January 6, 2024, 5:46pm UTC](https://discuss.roboflow.com/t/how-to-access-classes-defined-by-annotation-tool-from-python/4061/3 "2024-01-06T17:46:23Z")

</div>

This is a bit abstract…can you provide or point me to s snippet of Python code?

---

<div class="post-metadata">

**Author:** ![leo](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/leo/32/2228_2.png) [@leo](https://discuss.roboflow.com/u/leo)\
**Post date:** [January 9, 2024, 7:30pm UTC](https://discuss.roboflow.com/t/how-to-access-classes-defined-by-annotation-tool-from-python/4061/4 "2024-01-09T19:30:57Z")

</div>

Hi @Francis_Bacon

The Python SDK tab of the previously linked docs page has information on how to initialize the project object:

```auto
import roboflow

rf = roboflow.Roboflow(api_key=YOUR_API_KEY_HERE)

# List all projects for your workspace
workspace = rf.workspace()

# get a project
project = rf.workspace().project("PROJECT_ID")

```

You can see the classes of the project by accessing the `classes` property of the project object:

```auto
print(project.classes)

```

This returns a object with:

```auto
{'*class name*': # of images w/ class }

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/1X/bb6edbfa56d0cf2ee603f061e9e09103502cc8cc.png) [@system](https://discuss.roboflow.com/u/system)\
**Post date:** [January 30, 2024, 7:31pm UTC](https://discuss.roboflow.com/t/how-to-access-classes-defined-by-annotation-tool-from-python/4061/5 "2024-01-30T19:31:30Z")

</div>

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
