🗃ī¸Retrieve Paginated List of Files

Endpoint to retrieve a paginated list of files associated with the authenticated user.

  • HTTP Method: GET

  • Route: /public-api/v1/files

  • Headers:

    • api-key: Token generated through the API key section.

Query Parameters

  • page (optional): Page number for pagination (default: 1).

  • pageSize (optional): Number of items per page (default: 10).

Response

  • Status Code: 200 OK

  • Response Body:

    {
      "files": [
        {
          "ID": 1,
          "Name": "example.txt",
          "UID": "unique_id",
          "Root": "/",
          "CID": "QmXqwe12...",
          "Mime": "text/plain",
          "Size": 1024,
          "EncryptionStatus": "public",
          "CreatedAt": "2023-01-01T12:00:00Z",
          "UpdatedAt": "2023-01-01T12:00:00Z"
        },
        // ... additional file objects
      ],
      "totalItems": 20,
      "totalPages": 2
    }

Error Responses

  • Bad Request (400):

    • If the provided page number or page size is invalid.

Example in JavaScript:

Using Fetch API:

const url = 'base_url/public-api/v1/files';
const apiKey = 'your_api_key';

const page = 2; // Example page number
const pageSize = 15; // Example page size

fetch(`${url}?page=${page}&pageSize=${pageSize}`, {
  method: 'GET',
  headers: {
    'api-key': apiKey,
  },
})
  .then((response) => {
    if (!response.ok) {
      throw new Error(`Network error: ${response.status}`);
    }
    return response.json();
  })
  .then((data) => {
    console.log(data);
  })
  .catch((error) => {
    console.error('There was a problem with the Fetch request:', error);
  });

Using Axios:

const axios = require('axios');

const url = 'base_url/public-api/v1/files';
const apiKey = 'your_api_key';

const page = 2; // Example page number
const pageSize = 15; // Example page size

axios.get(`${url}?page=${page}&pageSize=${pageSize}`, {
  headers: {
    'api-key': apiKey,
  },
})
  .then((response) => {
    console.log(response.data);
  })
  .catch((error) => {
    console.error('There was a problem with the Axios request:', error);
  });

Last updated