File Storage API

files.tari.africa - Complete API Documentation

Table of Contents

Overview

This API provides file storage functionality similar to Firebase Storage. All endpoints return JSON responses.

Base URL

https://files.tari.africa/api.php

Supported File Types

jpg, jpeg, png, gif, pdf, doc, docx, txt, zip

File Size Limit

10MB per file

Authentication

Most endpoints require authentication using a Bearer token in the Authorization header.

Authorization: Bearer YOUR_TOKEN_HERE
Note: Tokens expire after 24 hours and are automatically renewed on each request.
POST No Authentication Required

Register New User

Endpoint

POST https://files.tari.africa/api.php?path=register

Request Body

{ "username": "your_username", "password": "your_password" }

Requirements

  • Username: 3-20 characters, letters, numbers, and underscores only
  • Password: Minimum 6 characters

Success Response

{ "success": true, "message": "User registered successfully", "user": { "id": 2, "username": "your_username", "role": "user" } }
POST No Authentication Required

Login

Endpoint

POST https://files.tari.africa/api.php?path=auth

Request Body

{ "username": "your_username", "password": "your_password" }

Success Response

{ "success": true, "token": "your_auth_token_here", "user": { "id": 1, "username": "your_username", "role": "user" }, "expires_in": 86400 }
Important: Save the token from the response. You'll need it for all authenticated requests.
POST Authentication Required

Upload File

Endpoint

POST https://files.tari.africa/api.php?path=upload

Headers

Authorization: Bearer YOUR_TOKEN_HERE Content-Type: multipart/form-data

Form Data

files: [file data]

JavaScript Example

const formData = new FormData(); formData.append('files', fileInput.files[0]); fetch('https://files.tari.africa/api.php?path=upload', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_TOKEN_HERE' }, body: formData }) .then(response => response.json()) .then(data => console.log(data));

Success Response

{ "success": true, "message": "File uploaded successfully", "file": { "name": "1234567890_abcdef123456.jpg", "path": "1234567890_abcdef123456.jpg", "url": "https://files.tari.africa/uploads/1234567890_abcdef123456.jpg", "public_url": "https://files.tari.africa/api.php?path=public&name=1234567890_abcdef123456.jpg", "size": 524288, "type": "image/jpeg", "modified": "2024-01-15 10:30:45" } }
GET Authentication Required

List All Files

Endpoint

GET https://files.tari.africa/api.php?path=files

Headers

Authorization: Bearer YOUR_TOKEN_HERE

Success Response

{ "success": true, "files": [ { "name": "1234567890_abcdef123456.jpg", "path": "1234567890_abcdef123456.jpg", "url": "https://files.tari.africa/uploads/1234567890_abcdef123456.jpg", "public_url": "https://files.tari.africa/api.php?path=public&name=1234567890_abcdef123456.jpg", "size": 524288, "type": "image/jpeg", "modified": "2024-01-15 10:30:45" } ], "total": 1 }
GET Authentication Required

Download File

Endpoint

GET https://files.tari.africa/api.php?path=download&name=FILENAME

Headers

Authorization: Bearer YOUR_TOKEN_HERE

Example

GET https://files.tari.africa/api.php?path=download&name=1234567890_abcdef123456.jpg
Note: This endpoint returns the actual file data, not JSON. Use for direct file downloads.
DELETE Authentication Required

Delete File

Endpoint

DELETE https://files.tari.africa/api.php?path=file

Headers

Authorization: Bearer YOUR_TOKEN_HERE Content-Type: application/json

Request Body

{ "name": "1234567890_abcdef123456.jpg" }

Success Response

{ "success": true, "message": "File deleted successfully" }
GET Authentication Required

Get User Profile

Endpoint

GET https://files.tari.africa/api.php?path=profile

Headers

Authorization: Bearer YOUR_TOKEN_HERE

Success Response

{ "success": true, "user": { "id": 1, "username": "your_username", "role": "user" } }
GET No Authentication Required

Public File Access

Endpoint

GET https://files.tari.africa/api.php?path=public&name=FILENAME

Example

GET https://files.tari.africa/api.php?path=public&name=1234567890_abcdef123456.jpg
Note: This endpoint allows public access to files without authentication. Use the public_url from upload/list responses.
GET No Authentication Required

Health Check

Endpoint

GET https://files.tari.africa/api.php?path=health

Success Response

{ "success": true, "status": "healthy", "timestamp": "2024-01-15 10:30:45", "server": "files.tari.africa" }

Error Responses

All endpoints may return error responses in the following format:

{ "success": false, "error": "Error message here", "code": "ERROR_CODE" }

Common Error Codes

Code Status Description
NO_TOKEN 401 Authentication token not provided
INVALID_TOKEN 401 Token is invalid or expired
ENDPOINT_NOT_FOUND 404 API endpoint does not exist
METHOD_NOT_ALLOWED 405 HTTP method not supported for endpoint
INVALID_JSON 400 Request body contains invalid JSON