This guide will walk you through the essential steps to integrate Unturned into your AI application. Follow these steps to make your first API call.
1. Sign Up / Log In
Visit to access your dashboard.
2. API Authentication
All API requests must include your API key in the request header:
Copy X-API-Key: YOUR_API_KEY
You can obtain your API key from the dashboard after creating your first project.
3. Create Your First Project
Enter a name and description for your project
Note down your project_id
from the project settings page. You'll need it for API calls.
4. Generate an API Key
In your project settings, go to the "API Keys" section
Enter a name for your key
The API key will be displayed once. Make sure to copy and store it securely.
5. Upload a Document
Now, let's add some data to your project. You can upload files directly.
Copy # Example using curl
curl -X POST "https://unturned.ai/api/v1/projects/<your_project_id>/documents/upload" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F "file=@/path/to/your/document.pdf" \
-F "metadata={\"source\":\"upload\", \"type\":\"manual\"}" # Optional metadata as JSON string
Copy # Example using Python requests library
import requests
import json
api_key = "YOUR_API_KEY"
project_id = "<your_project_id>"
file_path = "/path/to/your/document.pdf" # Path to your local file
url = f"https://unturned.ai/api/v1/projects/{project_id}/documents/upload"
headers = {
"X-API-Key": api_key
}
files = {
'file': (file_path.split('/')[-1], open(file_path, 'rb'))
}
# Optional: Add metadata
data = {
'metadata': json.dumps({"source": "upload", "type": "manual"})
}
response = requests.post(url, headers=headers, files=files, data=data)
if response.status_code == 201: # Assuming 201 Created for upload
document_data = response.json()["data"]
print("Document uploaded successfully!")
print(f"Document ID: {document_data['document_uuid']}")
print(f"Status: {document_data['status']}")
# Store the document_id
else:
print(f"Error: {response.status_code}", response.json())
Unturned will start processing the document. You can check its status using the document ID.
6. Make an API Call (List Documents)
Let's list the documents in your project.
Copy # Example using curl
curl -X GET "https://unturned.ai/api/v1/projects/<your_project_id>/documents/" \
-H "X-API-Key: YOUR_API_KEY" \
-H "X-Project-Id: <your_project_id>"
Copy # Example using Python requests library
import requests
api_key = "YOUR_API_KEY"
project_id = "<your_project_id>"
url = f"https://unturned.ai/api/v1/projects/{project_id}/documents/"
headers = {
"X-API-Key": api_key,
"X-Project-Id": project_id
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
documents_list = response.json()["data"]
print("Successfully retrieved documents:")
for doc in documents_list:
print(f"- ID: {doc['document_uuid']}, Status: {doc['status']}")
else:
print(f"Error: {response.status_code}", response.json())
Congratulations! You've successfully set up a project, added data, and made your first call to the Unturned API. Explore the other sections of this documentation to learn more about specific features and endpoints.