# Ipfs-api **Repository Path**: svier/Ipfs-api ## Basic Information - **Project Name**: Ipfs-api - **Description**: A minimal implementation of IPFS API - **Primary Language**: PHP - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-03-11 - **Last Updated**: 2022-03-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README IPFS API wrapper library in PHP ====================================== A minimal implementation of IPFS API. ----- # 使用说明 ## 安装 This library requires PHP 5.7 and the curl and json extensions. ```bash $ composer require vier/ipfs-api:dev-master $ composer install ``` ```PHP use vier\IpfsApi\Ipfs; // connect to ipfs daemon API server $ipfs = new IPFS("localhost", 5001, "http://yourdomain/ipfs"); // leaving out the arguments will default to these values ``` ## API #### add Adds content to IPFS. **Usage** ```PHP $hash = $ipfs->add("Hello world"); ``` #### addFromPath Adds content to IPFS from a filename (helper method) **Usage** ```PHP $hash = $ipfs->addFromPath("myFile.txt"); ``` #### addFromUrl Adds content ot IPFS from a web URL (helper method) **Usage** ```PHP $hash = $ipfs->addFromUrl('https://mysite.com/img.png'); ``` #### get Retrieves the contents of a single hash. **Usage** ```PHP $ipfs->get($hash); ``` #### ls Gets the node structure of a hash. **Usage** ```PHP $nodes = $ipfs->ls($hash); foreach ($nodes as $node) { echo $node['Hash']; echo $node['Size']; echo $node['Name']; } ``` #### Object size Returns object size. **Usage** ```PHP $size = $ipfs->size($hash); ``` #### Pin Pin or unpin a hash. **Usage** ```PHP $ipfs->pinAdd($hash); $ipfs->pinRm($hash); ``` #### ID Get information about your ipfs node. **Usage** ```PHP print_r($ipfs->id()); ```