Skip to content

Modern C++ client for Yandex.Disk REST API. Simple, lightweight, and static library for integrating Yandex.Disk cloud storage into C++ projects

License

Notifications You must be signed in to change notification settings

Krasnovvvvv/yandex-disk-cpp-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

☁️ Yandex Disk C++ Client

GitHub Tag Documentation License

Ubuntu Windows macOS

CI Ubuntu CI Windows CI macOS

Modern C++ client library for the Yandex.Disk REST API
A simple, lightweight, and efficient static library for integrating Yandex.Disk cloud storage into C++ projects across platforms

🔥 Now available on vcpkg – install in one command!

You can quickly install the library using vcpkg


✨ Features

  • Full API Coverage:
    Upload and download files and directories, manage directories, move and rename resources, handle trash operations, publish/unpublish files, and retrieve public download links

  • Robust File Management:
    Recursive upload/download of directories, existence checks, and detailed resource information retrieval

  • Trash Support:
    List trash contents, restore files/folders to original locations, delete individual items or empty the entire trash

  • Search Functionality:
    Find files and folders by name both on the disk and in the trash, supporting recursive search and multiple matches

  • Cross-Platform Compatibility:
    Works on Windows, Linux, and macOS with support for Unicode paths

  • Minimal Dependencies:
    Depends only on libcurl for HTTP communication and nlohmann/json for JSON parsing

  • Easy Integration:
    Provided as a static library with a clean header interface for straightforward inclusion in your projects


📁 Project Structure

yandex-disk-cpp-client/
├── docs                     # Generated documentation via Doxygen
├── examples/                # Example usage programs
├── include/                 # Public headers (YandexDiskClient.h)
├── src/                     # Library source files (YandexDiskClient.cpp)
├── CMakeLists.txt           # Build configuration
├── README.md                # This file
├── LICENSE                  # License file
├── .gitignore               # Git ignore rules

🚀 Quick Start

🛠️ Prerequisites

  • C++17 compatible compiler (GCC, Clang, MSVC)
  • CMake 3.14 or newer
  • libcurl development files
  • nlohmann/json (header-only, managed via CMake)
  • Environment variable YADISK_TOKEN with your Yandex.Disk OAuth token (full disk access)

⚡ Build and Run Example

git clone https://github.com/Krasnovvvvv/yandex-disk-cpp-client.git
cd yandex-disk-cpp-client
mkdir build && cd build
cmake ..
cmake --build .
./yandex_disk_example

🔥 New! Installation via vcpkg is now available

You can now install yandex-disk-cpp-client directly from the official vcpkg registry
This makes setup and integration seamless for CMake-based projects

Install

Run the following command:

vcpkg install yandex-disk-cpp-client

If you’re using a specific triplet (e.g., MinGW or Linux static), specify it explicitly:

vcpkg install yandex-disk-cpp-client:x64-mingw-static

Use in CMake

Once installed, simply include vcpkg’s toolchain and use find_package to link the library:

find_package(yandex-disk-cpp-client CONFIG REQUIRED)
target_link_libraries(example PRIVATE yandex-disk-cpp-client::yandex-disk-cpp-client)

That’s it!

  • Dependencies such as libcurl and nlohmann-json are automatically resolved by vcpkg
  • Works out of the box on Windows, Linux, and macOS

📖 Example Usage

#include "YandexDiskClient.h"
#include <cstdlib> // for getenv

int main() {
    const char* token = std::getenv("YADISK_TOKEN");
    if (!token) {
        std::cerr << "Please set YADISK_TOKEN environment variable." << std::endl;
        return 1;
    }

    YandexDiskClient yandex(token);

    // Upload a file
    yandex.uploadFile("/backup/data.zip", "C:/local/data.zip");

    // List root directory contents
    auto list = yandex.getResourceList("/");
    std::cout << yandex.formatResourceList(list) << std::endl;

    return 0;
}

For more examples, see examples/


🧭 API Overview

Function Description
getQuotaInfo() Retrieve disk quota info (total, used, trash size)
getResourceList(path) List files and folders at a given disk path
getResourceInfo(path) Get detailed info about a file or folder
uploadFile(disk_path, local_path) Upload a local file to disk
downloadFile(disk_path, local_path) Download a file from disk to local path
uploadDirectory(disk_path, local_path) Recursively upload a directory
downloadDirectory(disk_path, local_path) Recursively download a directory
deleteFileOrDir(path) Delete a file or directory
createDirectory(path) Create a directory
moveFileOrDir(from, to, overwrite) Move or rename a file or directory
publish(path) Publish a file or folder (make public)
unpublish(path) Remove public access
getPublicDownloadLink(path) Get public download URL
exists(path) Check if a file or folder exists
getTrashResourceList(path) List contents of trash
restoreFromTrash(path) Restore file/folder from trash to original location
deleteFromTrash(path) Permanently delete from trash
emptyTrash() Empty the entire trash
findTrashPathByName(name) Find all trash items by name
findResourcePathByName(name, start_path) Find all disk items by name, recursively

📦 Dependencies

These dependencies are automatically handled via CMake (assuming installed on your system or via package managers like vcpkg)


📚 Documentation

Full API documentation is generated using Doxygen and available in the docs/ folder
You can also access the online documentation via GitHub Pages Documentation


🤝 Contribution

Contributions, bug reports, and feature requests are welcome!
Please open issues or pull requests on the GitHub repository


📝 License

This project is licensed under the MIT License — see License