# How do i tag 18.5k images for a dataset using Roboflow API and python

**URL:** <https://discuss.roboflow.com/t/how-do-i-tag-18-5k-images-for-a-dataset-using-roboflow-api-and-python/8353>\
**Category:** 🤝  Community Help\
**Created:** [January 23, 2025, 1:32pm UTC](https://discuss.roboflow.com/t/how-do-i-tag-18-5k-images-for-a-dataset-using-roboflow-api-and-python/8353 "2025-01-23T13:32:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeaFIT\_Senior\_Project](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/leafit_senior_project/32/6464_2.png) [@LeaFIT\_Senior\_Project](https://discuss.roboflow.com/u/LeaFIT_Senior_Project)\
**Post date:** [January 23, 2025, 1:32pm UTC](https://discuss.roboflow.com/t/how-do-i-tag-18-5k-images-for-a-dataset-using-roboflow-api-and-python/8353/1 "2025-01-23T13:32:35Z")

</div>

Project Type: Classification  
Operating System & Browser: Microsoft, Google Chrome

I have 18.5k images to annotate and can’t all do it individually. I found this code to do it but I keep getting this error:

-------- Annotations successfully uploaded: {‘error’: ‘Endpoint not found.’} ----------

I have a CSV file and have made sure everything matches.  
For security reasons, I have hidden the actual IDs here.  
The only issue seems to be this line:

f"[https://api.roboflow.com/dataset/{PROJECT\_ID}/annotations?api\_key={ROBOFLOW\_API\_KEY}](https://api.roboflow.com/dataset/%7BPROJECT_ID%7D/annotations?api_key=%7BROBOFLOW_API_KEY%7D)",

What can I do?

* * *

_Here is my code:_

import csv  
import requests

# Roboflow API Key and Project Details

ROBOFLOW\_API\_KEY = “my\_actual\_id”  
WORKSPACE\_ID = “my\_wksp\_id”  
PROJECT\_ID = “my\_proj\_id”

# Load labels from CSV

labels =   
try:  
with open(“labels.csv”, “r”) as csvfile:  
reader = csv.DictReader(csvfile)  
for row in reader:  
labels.append(row)  
except FileNotFoundError:  
print(“Error: ‘labels.csv’ file not found. Make sure it’s in the same directory as the script.”)  
exit()

# Debug: Print parsed CSV content

print(“Parsed CSV Content:”)  
for label in labels:  
print(label)

# Check if CSV contains the necessary columns

if not labels or “image\_id” not in labels[0] or “category” not in labels[0]:  
print(“Error: CSV file must contain ‘image\_id’ and ‘category’ columns.”)  
exit()

# Collect all annotations into a list

annotations =   
for label in labels:  
# Create annotation entries  
annotations.append({  
“image\_id”: label[“image\_id”], # Match your CSV column name  
“annotations”: [{“label”: label[“category”]}] # Use ‘category’ instead of ‘label’  
})

# Debug: Print the payload being sent to the API

print(“Prepared Annotations Payload:”)  
print(annotations)

# Send annotations in bulk

try:  
response = requests.post(  
f"[https://api.roboflow.com/dataset/{PROJECT\_ID}/annotations?api\_key={ROBOFLOW\_API\_KEY}](https://api.roboflow.com/dataset/%7BPROJECT_ID%7D/annotations?api_key=%7BROBOFLOW_API_KEY%7D)",  
json={“annotations”: annotations}  
)

```
# Check the response
if response.status_code == 200:
    print("Annotations successfully uploaded:", response.json())
else:
    print("Failed to upload annotations:")
    print(f"Status Code: {response.status_code}")
    print(f"Response: {response.text}")

```

except requests.exceptions.RequestException as e:  
print(“Error: Failed to connect to Roboflow API.”)  
print(e)

---

<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:** [February 13, 2025, 1:33pm UTC](https://discuss.roboflow.com/t/how-do-i-tag-18-5k-images-for-a-dataset-using-roboflow-api-and-python/8353/2 "2025-02-13T13:33:12Z")

</div>

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