This documentation provides details on how to interact with the F2U (File to URL) API programmatically.
Register a new user.
{
"name": "User Name", // Required
"email": "user@example.com" // Optional
}
{
"user": {
"id": "unique-user-id",
"name": "User Name",
"email": "user@example.com",
"created_at": 1617235678901
}
}
Upload one or more files. Use multipart/form-data encoding.
| Parameter | Description | Required |
|---|---|---|
| userId | The user ID | Yes |
| file | The file to upload | Yes |
| file-1, file-2, ... | Additional files to upload | No |
| expiry | Expiry time in hours (omit for permanent file) | No |
{
"files": [
{
"id": "unique-file-id",
"user_id": "user-id",
"filename": "example.jpg",
"content_type": "image/jpeg",
"size": 123456,
"expiry": 1617235678901, // null if permanent
"created_at": 1617235678901,
"url": "https://example.com/f/unique-file-id"
},
...
]
}
List all files for a user.
| Parameter | Description | Required |
|---|---|---|
| userId | The user ID | Yes |
{
"files": [
{
"id": "unique-file-id",
"user_id": "user-id",
"filename": "example.jpg",
"content_type": "image/jpeg",
"size": 123456,
"expiry": 1617235678901, // null if permanent
"created_at": 1617235678901,
"url": "https://example.com/f/unique-file-id"
},
...
]
}
Delete a file.
| Parameter | Description | Required |
|---|---|---|
| file-id | The ID of the file to delete | Yes |
| Parameter | Description | Required |
|---|---|---|
| userId | The user ID | Yes |
{
"success": true
}
Get statistics for a user.
| Parameter | Description | Required |
|---|---|---|
| userId | The user ID | Yes |
{
"stats": {
"user_id": "user-id",
"total_files": 10,
"total_size": 1234567,
"last_upload": 1617235678901,
"user": {
"id": "user-id",
"name": "User Name",
"email": "user@example.com",
"created_at": 1617235678901
},
"current_files": 5
}
}
Download user ID as a text file.
| Parameter | Description | Required |
|---|---|---|
| userId | The user ID | Yes |
A downloadable text file containing the user ID and registration information.
Serve a file directly by its ID.
| Parameter | Description | Required |
|---|---|---|
| file-id | The ID of the file to serve | Yes |
The file content with appropriate content type headers.
import requests
# Register a user
response = requests.post("https://p2fu.objs.app/api/users", json={
"name": "Test User",
"email": "test@example.com"
})
user_data = response.json()
user_id = user_data["user"]["id"]
# Upload a file
files = {"file": open("example.jpg", "rb")}
data = {"userId": user_id, "expiry": "24"} # Expire in 24 hours
response = requests.post("https://p2fu.objs.app/api/files", data=data, files=files)
file_data = response.json()
file_url = file_data["files"][0]["url"]
# List files
response = requests.get(f"https://p2fu.objs.app/api/files?userId={user_id}")
files_list = response.json()["files"]
# Get user stats
response = requests.get(f"https://p2fu.objs.app/api/users/stats?userId={user_id}")
user_stats = response.json()["stats"]
# Download user ID
response = requests.get(f"https://p2fu.objs.app/api/users/download-id?userId={user_id}")
with open("user-id.txt", "wb") as f:
f.write(response.content)
# Delete a file
file_id = files_list[0]["id"]
response = requests.delete(f"https://p2fu.objs.app/api/files/{file_id}?userId={user_id}")