# Data

All commands for Data section are listed below and detailed on their own sections.

## Push data

> This endpoint forms the basis for the customized usage of the PIRI network. Thanks to this feature in the PIRI network, which enables data to be included in transactions and moved, user data can be transferred from any source, address, or recipient (recipient address).\
> \
> Pirichain offers a dynamic method to facilitate the addition of data to the blockchain. Data can be added as a Key & Value pair with different security levels, denoted by "enc," which represents the encryption level. There are three different encryption types for "enc." \*\*0: Non-Encrypted\*\*, where the Key & Value pair is stored openly in the blockchain. \*\*1: Value Encrypted\*\*, where the Key value is stored openly, but the Value is encrypted. \*\*2: Key & Value Encrypted\*\*, where both values are added to the blockchain in an encrypted form.\
> \
> When data is stored encrypted in the PIRI network, two different approaches can be applied. The parameter that enables this is \*\*"to"\*\*. In other words, customData can be made shareable with another PIRI address, beyond belonging to the PIRI address that added it to the system. This is made possible through a "shared key" in the PIRI network.\
> \
> \*\*Once customData is added to the blockchain, it becomes immutable and cannot be altered or deleted, similar to a transaction. This ensures the immutability of the given data.\*\*\
> \
> Thanks to this feature, applications for data-driven web3.0 concepts can be developed without the need for external applications, and the use of this feature with Pirichain Smart Scenarios can also be facilitated.\ <br>

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Data","description":"All commands for Data section are listed below and detailed on their own sections."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/pushData":{"post":{"tags":["Data"],"summary":"Push data","description":"This endpoint forms the basis for the customized usage of the PIRI network. Thanks to this feature in the PIRI network, which enables data to be included in transactions and moved, user data can be transferred from any source, address, or recipient (recipient address).\n\nPirichain offers a dynamic method to facilitate the addition of data to the blockchain. Data can be added as a Key & Value pair with different security levels, denoted by \"enc,\" which represents the encryption level. There are three different encryption types for \"enc.\" **0: Non-Encrypted**, where the Key & Value pair is stored openly in the blockchain. **1: Value Encrypted**, where the Key value is stored openly, but the Value is encrypted. **2: Key & Value Encrypted**, where both values are added to the blockchain in an encrypted form.\n\nWhen data is stored encrypted in the PIRI network, two different approaches can be applied. The parameter that enables this is **\"to\"**. In other words, customData can be made shareable with another PIRI address, beyond belonging to the PIRI address that added it to the system. This is made possible through a \"shared key\" in the PIRI network.\n\n**Once customData is added to the blockchain, it becomes immutable and cannot be altered or deleted, similar to a transaction. This ensures the immutability of the given data.**\n\nThanks to this feature, applications for data-driven web3.0 concepts can be developed without the need for external applications, and the use of this feature with Pirichain Smart Scenarios can also be facilitated.\n\n","operationId":"pushData","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"required":["address","privateKey","customData"],"type":"object","properties":{"address":{"type":"string","description":"PIRI Address"},"privateKey":{"type":"string","description":"Private Key"},"to":{"type":"string","description":"Recipient PIRI Address"},"customData":{"type":"string","description":"Custom data [{\"key\":\"key\",\"value\":\"value\",\"enc\":<0: non-encrypted, 1: value-encrypted, 2: key&value-encrypted>}, ...]"},"indPubKey":{"type":"string","description":"Recipient Public Key"}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/pushData"}}}}},"deprecated":false}}},"components":{"schemas":{"pushData":{"title":"pushData","required":["error","tx","sign","timeStamp"],"type":"object","properties":{"error":{"type":"integer","format":"int32","description":"Error code (0 for success)"},"tx":{"type":"string","description":"Transaction hash"},"sign":{"type":"string","description":"Transaction signature"},"timeStamp":{"type":"integer","format":"int64","description":"Transaction timestamp"}}}}}}
```

## Decrypt

> This endpoint is created for a customData added to the PIRI network, with the intention of enabling decryption by either the data provider or the recipient. The data added with the "pushData1 endpoint" comes with different encryption levels, two of which do not require additional decryption: 1: Value Encrypted, 2: Key & Value Encrypted.\
> \
> In such a scenario, the address that added the data to the blockchain or the address that became the recipient at the time of data addition through the "to" parameter can decrypt this encrypted data or data using this endpoint.\ <br>

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Data","description":"All commands for Data section are listed below and detailed on their own sections."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/decrypt":{"post":{"tags":["Data"],"summary":"Decrypt","description":"This endpoint is created for a customData added to the PIRI network, with the intention of enabling decryption by either the data provider or the recipient. The data added with the \"pushData1 endpoint\" comes with different encryption levels, two of which do not require additional decryption: 1: Value Encrypted, 2: Key & Value Encrypted.\n\nIn such a scenario, the address that added the data to the blockchain or the address that became the recipient at the time of data addition through the \"to\" parameter can decrypt this encrypted data or data using this endpoint.\n\n","operationId":"decrypt","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"required":["customID","privateKey"],"type":"object","properties":{"customID":{"type":"string","description":"Custom Data Id"},"privateKey":{"type":"string","description":"Private Key"},"receiptPub":{"type":"string","description":"Recipient Public Key"}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/decrypt"}}}}},"deprecated":false}}},"components":{"schemas":{"decrypt":{"title":"decrypt","required":["error","key","value"],"type":"object","properties":{"error":{"type":"integer","format":"int32","description":"Error code (0 for success)"},"key":{"type":"string","description":"Decrypted key"},"value":{"type":"string","description":"Decrypted value"}}}}}}
```

## List data

> This endpoint lists the data present in the PIRI network based on the skip and limit parameters.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Data","description":"All commands for Data section are listed below and detailed on their own sections."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/listData":{"post":{"tags":["Data"],"summary":"List data","description":"This endpoint lists the data present in the PIRI network based on the skip and limit parameters.","operationId":"listData","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"required":["limit"],"type":"object","properties":{"limit":{"type":"number","description":"Record count for per page"},"skip":{"type":"number","description":"Page count for skip according to limit value."}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/listData"}}}}},"deprecated":false}}},"components":{"schemas":{"listData":{"title":"listData","required":["data","count"],"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/DataEntry"},"description":"List of data entries"},"count":{"type":"integer","format":"int32","description":"Total count of data entries"}}},"DataEntry":{"title":"DataEntry","required":["_id","txID","key","value","timeStamp","from","enc","__v","blockHeight"],"type":"object","properties":{"_id":{"type":"string","description":"Data entry ID"},"txID":{"type":"string","description":"Transaction ID"},"key":{"type":"string","description":"Data key"},"value":{"type":"string","description":"Data value"},"timeStamp":{"type":"integer","format":"int64","description":"Timestamp"},"from":{"type":"string","description":"Sender address"},"enc":{"type":"integer","format":"int32","description":"Encryption level"},"__v":{"type":"integer","format":"int32","description":"Version key"},"blockHeight":{"type":"integer","format":"int32","description":"Block height"}}}}}}
```

## List data by address

> This endpoint lists the data associated with the PIRI address specified in the \*\*"address"\*\* parameter on the PIRI network, depending on the skip and limit parameters.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Data","description":"All commands for Data section are listed below and detailed on their own sections."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/listDataByAddress":{"post":{"tags":["Data"],"summary":"List data by address","description":"This endpoint lists the data associated with the PIRI address specified in the **\"address\"** parameter on the PIRI network, depending on the skip and limit parameters.","operationId":"listDataByAddress","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"required":["address","limit"],"type":"object","properties":{"address":{"type":"string","description":"PIRI Address"},"limit":{"type":"number","description":"Record count for per page"},"skip":{"type":"number","description":"Page count for skip according to limit value."}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/listDataByAddress"}}}}},"deprecated":false}}},"components":{"schemas":{"listDataByAddress":{"title":"listDataByAddress","required":["data","count"],"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/DataEntry"},"description":"List of data entries by address"},"count":{"type":"integer","format":"int32","description":"Total count of data entries"}}},"DataEntry":{"title":"DataEntry","required":["_id","txID","key","value","timeStamp","from","enc","__v","blockHeight"],"type":"object","properties":{"_id":{"type":"string","description":"Data entry ID"},"txID":{"type":"string","description":"Transaction ID"},"key":{"type":"string","description":"Data key"},"value":{"type":"string","description":"Data value"},"timeStamp":{"type":"integer","format":"int64","description":"Timestamp"},"from":{"type":"string","description":"Sender address"},"enc":{"type":"integer","format":"int32","description":"Encryption level"},"__v":{"type":"integer","format":"int32","description":"Version key"},"blockHeight":{"type":"integer","format":"int32","description":"Block height"}}}}}}
```

## List data by addresses

> List data entries between specific addresses

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Data","description":"All commands for Data section are listed below and detailed on their own sections."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/listDataByAddresses":{"post":{"tags":["Data"],"summary":"List data by addresses","description":"List data entries between specific addresses","operationId":"listDataByAddresses","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"required":["from","to","limit"],"type":"object","properties":{"from":{"type":"string","description":"From address"},"to":{"type":"string","description":"To address"},"limit":{"type":"number","description":"Number of results to return"},"skip":{"type":"number","description":"Number of results to skip"}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/listDataByAddresses"}}}}},"deprecated":false}}},"components":{"schemas":{"listDataByAddresses":{"title":"listDataByAddresses","required":["error","data"],"type":"object","properties":{"error":{"type":"integer","format":"int32","description":"Error code (0 for success)"},"data":{"type":"array","items":{"$ref":"#/components/schemas/DataEntryWithRecipient"},"description":"List of data entries between addresses"}}},"DataEntryWithRecipient":{"title":"DataEntryWithRecipient","required":["_id","txID","key","value","timeStamp","from","to","enc","__v","blockHeight"],"type":"object","properties":{"_id":{"type":"string","description":"Data entry ID"},"txID":{"type":"string","description":"Transaction ID"},"key":{"type":"string","description":"Data key"},"value":{"type":"string","description":"Data value"},"timeStamp":{"type":"integer","format":"int64","description":"Timestamp"},"from":{"type":"string","description":"Sender address"},"to":{"type":"string","description":"Recipient address"},"enc":{"type":"integer","format":"int32","description":"Encryption level"},"__v":{"type":"integer","format":"int32","description":"Version key"},"blockHeight":{"type":"integer","format":"int32","description":"Block height"}}}}}}
```

## Push data raw transaction

> Push data to blockchain using raw transaction format

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Data","description":"All commands for Data section are listed below and detailed on their own sections."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/pushDataRawTransaction":{"post":{"tags":["Data"],"summary":"Push data raw transaction","description":"Push data to blockchain using raw transaction format","operationId":"pushDataRawTransaction","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"required":["address","pubKey","signature","timeStamp","to"],"type":"object","properties":{"address":{"type":"string","description":"Sender address"},"pubKey":{"type":"string","description":"Public key"},"signature":{"type":"string","description":"Transaction signature"},"timeStamp":{"type":"string","description":"Transaction timestamp"},"to":{"type":"string","description":"Recipient address"},"customData":{"type":"string","description":"Custom data array in JSON format"},"indPubKey":{"type":"string","description":"Individual public key"}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/pushDataRawTransaction"}}}}},"deprecated":false}}},"components":{"schemas":{"pushDataRawTransaction":{"title":"pushDataRawTransaction","required":["error","txHash"],"type":"object","properties":{"error":{"type":"integer","format":"int32","description":"Error code (0 for success)"},"txHash":{"type":"string","description":"Transaction hash"}}}}}}
```


---

# 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://api.pirichain.com/data.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.
