# 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](https://docs.datagym.ai/documentation/project/export-data) 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](https://docs.datagym.ai/documentation/project/import-label) 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](https://docs.datagym.ai/documentation/project/import-label#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
