> ## Documentation Index
> Fetch the complete documentation index at: https://docs.labtrace.io/llms.txt
> Use this file to discover all available pages before exploring further.

# API Introduction

> Getting started with the LabTrace API

# API Reference

The LabTrace API provides programmatic access to all platform functionality, enabling developers to integrate blockchain-powered file management into their applications.

## Base URL

All API requests are made to:

```
https://api.labtrace.io
```

## Authentication

<CardGroup cols={2}>
  <Card title="Login" icon="id-card">
    Login to the LabTrace API `/login` to get a JWT token
  </Card>

  <Card title="JWT Tokens" icon="key">
    All API requests require a valid JWT token in the Authorization header
  </Card>
</CardGroup>

### Authentication Example

```bash theme={null}
curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  https://api.labtrace.io/projects
```

## API Endpoints

### Core Resources

The complete API reference is available at:

```
https://api.labtrace.io/docs
```

The core resources are:

<CardGroup cols={2}>
  <Card title="Authentication" icon="user-check" href="/api-reference/authentication">
    User login, registration, and token management
  </Card>

  <Card title="Files" icon="file" href="/api-reference/files">
    Upload, download, and manage files with blockchain verification
  </Card>

  <Card title="Projects" icon="folder" href="/api-reference/projects">
    Create and manage projects, handle user invitations
  </Card>

  <Card title="Users" icon="users" href="/api-reference/users">
    User management, profiles, and blockchain addresses
  </Card>
</CardGroup>

## Request Format

All requests use JSON format with appropriate HTTP methods:

* **GET**: Retrieve data
* **POST**: Create new resources
* **PUT**: Update existing resources
* **DELETE**: Remove resources

### Example Request

```json theme={null}
POST /api/v1/files
Content-Type: application/json
Authorization: Bearer YOUR_JWT_TOKEN

{
  "project_id": "proj_123456",
  "file_name": "research-data.pdf",
  "file_data": "base64_encoded_file_content",
  "tags": ["research", "data"]
}
```

## Response Format

All responses are JSON objects with consistent structure:

```json theme={null}
{
  "success": true,
  "data": {
    "file_id": "file_789012",
    "cid": "bafybeihdwdcefgh4dqkjv67uzcmw7o...",
    "blockchain_tx": "ABC123...",
    "status": "uploaded"
  },
  "message": "File uploaded successfully"
}
```

## Error Handling

<AccordionGroup>
  <Accordion title="HTTP Status Codes">
    <ul>
      <li><strong>200</strong>: Success</li>
      <li><strong>201</strong>: Created</li>
      <li><strong>400</strong>: Bad Request</li>
      <li><strong>401</strong>: Unauthorized</li>
      <li><strong>403</strong>: Forbidden</li>
      <li><strong>404</strong>: Not Found</li>
      <li><strong>500</strong>: Internal Server Error</li>
    </ul>
  </Accordion>

  <Accordion title="Error Response Format">
    ```json theme={null}
    {
      "success": false,
      "error": {
        "code": "INVALID_FILE_TYPE",
        "message": "File type not supported",
        "details": "Only PDF, DOCX, and image files are allowed"
      }
    }
    ```
  </Accordion>
</AccordionGroup>

## SDKs and Libraries

<CardGroup cols={2}>
  <Card title="Python SDK" icon="python" href="/sdk/python">
    Official Python SDK for data science and backend integration
  </Card>
</CardGroup>

## Blockchain Integration

All API operations that modify data are automatically recorded on the blockchain:

* **File operations**: Upload, download, delete
* **Project operations**: Create, invite users, remove access
* **User operations**: Registration, profile updates

## Getting Started

<Steps>
  <Step title="Get API Access">
    Register for a LabTrace account and generate an API key\*\*\*\*\*\*\*\*
  </Step>

  <Step title="Install SDK">
    Install the official SDK for your preferred language
  </Step>

  <Step title="Authenticate">
    Use your API key to authenticate requests
  </Step>

  <Step title="Make Your First Request">
    Try creating a project or uploading a file
  </Step>
</Steps>

## Support

* **Documentation**: Comprehensive API documentation with examples
* **SDKs**: Official SDKs for popular programming languages
* **Community**: Join our developer community for support and discussions
* **Enterprise**: Priority support available for enterprise customers
