# URI 协议

## **事件流 URL**

每个在ceramic中的流会被识别成一个唯一的URL。该 URL 由 Ceramic 的协议标识符和下面定义的 StreamId 组成。当编码为字符串时，StreamID 前缀带有协议处理程序，并且通常使用 base36 编码 StreamID。这完全描述了流位于哪里以及在哪里可以找到它，在本例中它可以在 Ceramic 网络上找到。

```JSON
ceramic://<StreamId>
```

例如，StreamId 可能如下所示：

```Plaintext
ceramic://kjzl6fddub9hxf2q312a5qjt9ra3oyzb7lthsrtwhne0wu54iuvj852bw9wxfvs
```

事件 ID 也可以以同样的方式进行编码。s

```JSON
ceramic://<EventId>
```

## **StreamID**

**StreamId由一个StreamId代码、流类型和CID组成**，用于引用特定且唯一的事件流。StreamIds类似于IPLD中的CIDs，并使用多格式，但它们提供了与Ceramic事件流相关的附加信息。这也使它们可以与CIDs区分开来。事件流的init事件用于创建StreamId。定义如下：

<pre class="language-JSON"><code class="lang-JSON"><strong>&#x3C;streamid> ::= &#x3C;multibase-prefix>&#x3C;multicodec-streamid>&#x3C;stream-type>&#x3C;init-cid-bytes>
</strong>
# e.g. using CIDv1
&#x3C;streamid> ::= &#x3C;multibase-prefix>&#x3C;multicodec-streamid>&#x3C;stream-type>&#x3C;multicodec-cidv1>&#x3C;multicodec-content-type>&#x3C;multihash-content-address>
</code></pre>

在这里：

* \<multibase-prefix> 是一个[多基数](https://github.com/multiformats/multibase)代码（1或2字节），用以便于将StreamIds编码到各种基数中。注意：当编码明确时，二进制（非文本基础）的协议和格式可能会省略多基数前缀。
* \<multicodec-streamid> 0xce 是一个用来表示这是一个StreamId的[多编码](https://github.com/multiformats/multicodec)，以变长整数编码
* \<stream-type> 是代表流的类型的[变长整数](https://github.com/multiformats/unsigned-varint)。
* \<init-cid-bytes> 是从初始化事件的[CID](https://github.com/multiformats/cid)中获取的字节，去掉了多基数前缀。

StreamID的多编解码器为[0xce](https://github.com/multiformats/multicodec/blob/master/table.csv#L78)。为了与浏览器URL兼容，建议使用\[[base36](https://github.com/multiformats/multibase)]对StreamId进行编码。目前，流类型值在协议级别上没有任何功能。相反，它被构建在Ceramic之上的应用程序（例如ComposeDB）用于区分处理事件时应用的不同逻辑。流类型值必须在[CIP-59](https://github.com/ceramicnetwork/CIP/blob/main/CIPs/CIP-59/CIP-59.md#registered-values)表中注册

## **事件ID**

EventIds 扩展了 StreamIds，以引用特定流中的特定事件。**在StreamId的末尾添加附加字节**。如果它代表创世事件，则添加零字节（0x00），否则添加表示该事件的CID。\
EventIds定义如下：

```JSON
<streamid> ::= <multibase-prefix><multicodec-streamid><stream-type>
  <genesis-cid-bytes>
  <event-reference>

# e.g. using CIDv1 and representing the genesis event
<streamid> ::= <multibase-prefix><multicodec-streamid><stream-type>
  <multicodec-cidv1><multicodec-content-type><multihash-content-address>
  <0x00>

# e.g. using CIDv1 and representing an arbitrary event in the log
<streamid> ::= <multibase-prefix><multicodec-streamid><stream-type>
  <multicodec-cidv1><multicodec-content-type-1><multihash-content-address-1>
  <multicodec-cidv1><multicodec-content-type-2><multihash-content-address-2>
```

其中：\<event-reference> 可以是零字节（0x00）或[ CID 字](https://github.com/multiformats/cid)节。**流版本**每个事件ID也可以被视为是对特定流版本的引用。在任何事件ID处，一个流可以被加载直到该事件和产生的一系列事件都被认为是一个版本的事件流\ <br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ceramic-zhong-wen-wen-dang.gitbook.io/ceramic-zhong-wen-wen-dang/ceramic-xie-yi/stream-shi-jian-liu/uri-xie-yi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
