# fetch

## fetch

### Overview

The `fetch` RPC method allows you to retrieve files that have been stored on the Lynx blockchain. It provides a mechanism for accessing data by its unique identifier (UUID) and saving it to a specified location on your filesystem. No authentication is required prior to using this function.

### Syntax

```
fetch <uuid> <path> [pubkeyflag]
```

### Description

When you invoke the `fetch` method, the Lynx daemon searches the blockchain for the specified file and downloads it to your designated location. This method is part of the core functionality that enables Lynx to serve as a decentralized data storage solution.

### Parameters

<table><thead><tr><th width="150.99609375">Parameter</th><th width="131.76953125">Type</th><th width="122.23046875">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>uuid</code></td><td>string</td><td>Yes</td><td>The unique identifier of the file you want to retrieve. This is a 64-character hexadecimal string (e.g., 2cf6eabc7af83152d5ad7d4ff9aeeb66f81dde70731b800bb0cd18300d9cb402).</td></tr><tr><td><code>path</code></td><td>string</td><td>Yes</td><td>The full filesystem path where the retrieved file should be stored (e.g., <code>/home/username/downloads</code>). This path must exist before calling the method.</td></tr><tr><td><code>pubkeyflag</code></td><td>string</td><td>No</td><td>Optional parameter that controls tenant public key inclusion in the response. Enter <code>0</code> to omit the tenant information. Default is <code>1</code> (include tenant information).</td></tr></tbody></table>

### Returns

The method returns an array containing a single object with the following fields:

<table><thead><tr><th width="150.33203125">Field</th><th width="183.3828125">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>result</code></td><td>string</td><td>Indicates whether the operation succeeded (<code>success</code>) or failed (<code>failure</code>).</td></tr><tr><td><code>message</code></td><td>string</td><td>Provides additional information about the result. For successful operations, returns <code>n/a</code>. For failures, indicates the reason (e.g., <code>Invalid path /path/to/directory.</code>, <code>Invalid UUID length.</code>, <code>UUID not found.</code>).</td></tr><tr><td><code>tenant</code></td><td>string/number</td><td>When authentication is active and <code>pubkeyflag</code> is set to <code>1</code>, displays the tenant public key associated with the file. Otherwise returns <code>n/a</code>.</td></tr></tbody></table>

### Examples

#### Retrieve a specific file

Retrieve the file with UUID 2cf6eabc7af83152d5ad7d4ff9aeeb66f81dde70731b800bb0cd18300d9cb402 and store it in the `/home/username/downloads` directory:

```
lynx-cli fetch 2cf6eabc7af83152d5ad7d4ff9aeeb66f81dde70731b800bb0cd18300d9cb402 /home/username/downloads
```

Or using JSON-RPC:

```
curl --user username --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "fetch", "params": ["2cf6eabc7af83152d5ad7d4ff9aeeb66f81dde70731b800bb0cd18300d9cb402", "/home/username/downloads"]}' -H 'content-type: text/plain;' http://127.0.0.1:9332/
```

#### Retrieve a file without tenant verification

This method is significantly faster. Retrieve a file without performing tenant verification:

```
lynx-cli fetch 2cf6eabc7af83152d5ad7d4ff9aeeb66f81dde70731b800bb0cd18300d9cb402 /home/username/downloads 0
```

### Error Handling

The method will return a failure result in the following scenarios:

* The specified path doesn't exist on the filesystem
* The UUID has an invalid length (must be 64 characters for a specific file)


---

# 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://docs.getlynx.io/lynx-core/data-storage/fetch.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.
