IPFS Block API

The Block API from IPFS — 4 operation(s) for block.

OpenAPI Specification

ipfs-block-api-openapi.yml Raw ↑
openapi: 3.0.0
info:
  title: IPFS RPC Add Block API
  version: v0
  description: 'When a Kubo IPFS node is running as a daemon, it exposes an HTTP RPC API that allows you to control the node and run the same commands you can from the command line.


    In many cases, using this RPC API is preferable to embedding IPFS directly in your program — it allows you to maintain peer connections that are longer lived than your app and you can keep a single IPFS node running instead of several if your app can be launched multiple times. In fact, the `ipfs` CLI commands use this RPC API when operating in online mode.'
  x-providerName: IPFS
  x-logo:
    url: https://raw.githubusercontent.com/ipfs/ipfs-docs/55fe8bc6a53ba3b9023951fb4b432efbbc81fba5/docs/.vuepress/public/images/ipfs-logo.svg
servers:
- description: Local IPFS node
  url: http://localhost:5001
- description: Local IPFS node
  url: http://127.0.0.1:5001
- description: Infura hosted IPFS node
  url: https://ipfs.infura.io:5001
tags:
- name: Block
paths:
  /api/v0/block/get:
    post:
      operationId: block/get
      description: Get a raw IPFS block.
      externalDocs:
        url: https://docs.ipfs.tech/reference/kubo/rpc/#api-v0-block-get
      parameters:
      - name: arg
        in: query
        description: The CID of an existing block to get.
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Successful response
      tags:
      - Block
  /api/v0/block/put:
    post:
      operationId: block/put
      description: Store input as an IPFS block.
      externalDocs:
        url: https://docs.ipfs.tech/reference/kubo/rpc/#api-v0-block-put
      parameters:
      - name: cid-codec
        in: query
        description: Multicodec to use in returned CID.
        schema:
          type: string
          default: raw
      - name: mhtype
        in: query
        description: Multihash hash function.
        schema:
          type: string
          default: sha2-256
      - name: mhlen
        in: query
        description: Multihash hash length.
        schema:
          type: integer
          default: -1
      - name: pin
        in: query
        description: Pin added blocks recursively.
        schema:
          type: boolean
          default: false
      - name: allow-big-block
        in: query
        description: 'Disable block size check and allow creation of blocks bigger than 1MiB. WARNING: such blocks won''t be transferable over the standard bitswap.'
        schema:
          type: boolean
          default: false
      - name: format
        in: query
        description: Use legacy format for returned CID (DEPRECATED).
        deprecated: true
        schema:
          type: string
      requestBody:
        description: Argument `data` is of file type. This endpoint expects one or several files (depending on the command) in the body of the request as 'multipart/form-data'.
        content: {}
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              example:
                Key: <string>
                Size: <int>
      tags:
      - Block
  /api/v0/block/rm:
    post:
      operationId: block/rm
      description: Remove IPFS block(s) from the local datastore.
      externalDocs:
        url: https://docs.ipfs.tech/reference/kubo/rpc/#api-v0-block-rm
      parameters:
      - name: arg
        in: query
        description: CIDs of block(s) to remove.
        required: true
        schema:
          type: string
      - name: force
        in: query
        description: Ignore nonexistent blocks.
        schema:
          type: boolean
      - name: quiet
        in: query
        description: Write minimal output.
        schema:
          type: boolean
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              example:
                Error: <string>
                Hash: <string>
      tags:
      - Block
  /api/v0/block/stat:
    post:
      operationId: block/stat
      description: Print information of a raw IPFS block.
      externalDocs:
        url: https://docs.ipfs.tech/reference/kubo/rpc/#api-v0-block-stat
      parameters:
      - name: arg
        in: query
        description: The CID of an existing block to stat.
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              example:
                Key: <string>
                Size: <int>
      tags:
      - Block
externalDocs:
  url: https://docs.ipfs.tech/reference/kubo/rpc/