# Labeled data

## Export Labels

### Fetch your labeled data from a Project:

Wouldn't it be pretty convenient to load the data of our labeled images directly into our python project? In this example we fetch our Dummy Project by providing its name and download the labeled data into our python app. Therefore, we use the `export_labels` method of the Client that requires the Project ID.

```python
dummy_project = client.get_project_by_name(project_name="Dummy_Project")

labeled_data = client.export_labels(project_id=dummy_project.id) 
```

`export_labels` returns the labels as a Python Dictionary that resembles the JSON format introduced in the [Export Data](/documentation/project/export-data.md) section.

### Generate a download link to your data&#x20;

You can also generate a hyperlink to the JSON file if you want to download it with your browser or another programmatic solution.

```python
exported_labels_url = client.export_labels_url(project_id=dummy_project.id)

print(exported_labels_url)
```

{% code title="Output:" %}

```javascript
http://app.datagym.ai/api/v1/export/<PROJECT_ID>?token=<API_KEY>
```

{% endcode %}

## Import Labels

You can not only export your labels but also import annotated image data into your **Data**Gym.ai Project using our [Import Label](/documentation/project/import-label.md) feature.&#x20;

{% hint style="info" %}
Visit our [Jupyter Notebook on GitHub](https://github.com/datagym-ai/datagym-python/blob/master/notebooks/How%20to%20Upload%20Label%20Predictions.ipynb) to learn how to to upload label predictions into **Data**Gym.ai
{% endhint %}

Use the `import_label_data` method of the Client class to import labels. The method takes a Project ID and your pre-labeled image data as Dictionary. Visit our [API documentation](/documentation/project/import-label.md#the-import-format) or [Jupyter Notebook](https://github.com/datagym-ai/datagym-python/blob/master/notebooks/How%20to%20Upload%20Label%20Predictions.ipynb) to learn how to format your labels into a valid JSON format.

```python
project = client.get_project_by_name("<project_name>")

client.import_label_data(project_id=project.id, label_data=label_data)
```

`import_label_data` returns a List of Errors if JSON is malformed or data is invalid


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.datagym.ai/documentation/python-api/labeled-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
