This guide demonstrates how to upload files to an Oxen repository using the HTTP API. We’ll break down the process into simple, manageable steps.Documentation Index
Fetch the complete documentation index at: https://docs.oxen.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Uploading a file to Oxen involves three main steps:- Create a repository (if it doesn’t exist)
- Upload the file to a specific branch
- Optionally create additional branches from the uploaded content
Prerequisites
Before you begin, you’ll need:- API Key: Authentication token for your Oxen account
- Server URL: The Oxen server endpoint (e.g.,
https://hub.oxen.aior your local server) - File to upload: The local file you want to add to your repository
Configuration
First, set up your configuration variables:Step 1: Create a Repository
Create a new repository to store your files. If the repository already exists, this step will return a 409 status code and you can continue.Endpoint
Example
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
namespace | string | Yes | Your username or organization name |
name | string | Yes | Repository name |
user.name | string | Yes | Author name for commits |
user.email | string | Yes | Author email for commits |
description | string | No | Repository description |
Response
Step 2: Upload a File
Upload a file to your repository. This creates a commit on the specified branch with your file.Endpoint
Path Parameters
| Parameter | Description | Example |
|---|---|---|
namespace | Your username or organization | your-username |
repo_name | Repository name | my-dataset |
branch | Target branch name | main |
path | Destination path in repository | data/example.txt |
Example
Request Body (Multipart Form Data)
| Field | Type | Required | Description |
|---|---|---|---|
file | file | Yes | The file(s) to upload. Can be multiple files with the same field name |
message | string | Yes | Commit message |
name | string | Yes | Author name |
email | string | Yes | Author email |
file fields with different filenames.
Response
Step 3: Create a Branch (Optional)
After uploading files, you can create additional branches from your main branch.Endpoint
Example
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
new_name | string | Yes | Name of the new branch |
from_name | string | Yes | Source branch to create from |
Response
Complete Example
Here’s a complete Python script that ties everything together:Authentication
All API requests require authentication using a Bearer token in the Authorization header:Getting an API Key
- Log in to your Oxen account at hub.oxen.ai
- Navigate to your account settings
- Generate a new API key
Advanced Usage
Uploading Multiple Files
You can upload multiple files in a single request by including multiplefile fields:
Uploading to Different Branches
Organizing Files in Directories
Files are automatically organized based on theremote_file_path:
Next Steps
- Download Files - Learn how to retrieve files
- List Files - Browse repository contents
- Workspaces - Work with remote data without downloading
- Branches - Manage repository branches