Tagged Data

From Nxtwiki
Revision as of 00:01, 24 January 2020 by Almonte (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Tagged data are similar to prunable plain messages without a recipient, but with additional searchable metadata fields.

Download Tagged Data

Download tagged data as a file if it is still available.

Request:

  • requestType is downloadTaggedData
  • transaction is the transaction ID of the tagged data
  • retrieve is true to retrieve pruned data from other nodes if not available (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response: The downloaded data file named nxt, unless there is an error in the request.

Download Tagged Data Example

http://localhost:7876/nxt?
  requestType=downloadTaggedData&
  transaction=9169681701986886056
Downloaded file named nxt with contents:

d4f167249340d6d746f49441b8ccdb1bd3521feb


Extend Tagged Data

Extend the expiration time of already uploaded tagged data. POST only.

Request:

  • requestType is extendTaggedData
  • transaction is the transaction ID of the tagged data
  • data is the tagged data (optional)
  • file is the pathname of a data file to upload (optional if data provided)
  • filename
  • name
  • description
  • tags
  • type
  • channel
  • isText

Note: The data and metadata (filename, name, description, tags, type, channel and isText) parameters can be omitted if the tagged data has not yet expired; otherwise, the tagged data can be restored to the blockchain only if these fields have exactly the same values as when the data was uploaded (refer to Upload Tagged Data).

Note: Anyone can submit an extension, not only the original uploader. Each extend transaction increases the expiration deadline by two weeks (24 hours on Testnet). Extending an existing tagged data from another account does not change the original submitter account ID by which it is indexed and searchable.

Response: Refer to Create Transaction Response.

Extend Tagged Data Example

http://localhost:7876/nxt?
  requestType=extendTaggedData&
  transaction=9086193976300572942&
  secretPhrase=secretPhrase&
  feeNQT=100000000&
  deadline=60
{
 "signatureHash": "96cee31072bcdc82c85710c78e86d42aa8eac34e90960d97dcb87e9212534cc4",
 "transactionJSON": {
  "senderPublicKey": "10f09c34f225d425306e5be55a4946908156072afbead4d574a512d7e086ef5c",
  "signature": "1be49ba648dcb242620d34762243399053837a32e5c2f0a392b27e70fcf823073f0...",
  "feeNQT": "100000000",
  "type": 6,
  "fullHash": "77c6dcbf770f2ce04ca8ed14ba52cdff8f7e35515bc0a8440079acd156700fb6",
  "version": 1,
  "phased": false,
  "ecBlockId": "9233989544625577248",
  "signatureHash": "96cee31072bcdc82c85710c78e86d42aa8eac34e90960d97dcb87e9212534cc4",
  "attachment": {
   "version.TaggedDataExtend": 1,
   "filename": "",
   "data": "d4f167249340d6d746f49441b8ccdb1bd3521feb",
   "name": "Stargate SG1 full series",
   "channel": "torrent",
   "description": "Hash of the torrent.",
   "type": "",
   "taggedData": "9086193976300572942",
   "isText": true,
   "tags": "video, scifi, torrent"
  },
  "senderRS": "NXT-4VDY-LNVT-LMAY-FMCKA",
  "subtype": 1,
  "amountNQT": "0",
  "sender": "15295723609781267838",
  "ecBlockHeight": 304612,
  "deadline": 60,
  "transaction": "16153302970465568375",
  "timestamp": 47672016,
  "height": 2147483647
 },
 "unsignedTransactionBytes": "0611d06ad7023c0010f09c34f225d425306e5be55a494...",
 "broadcasted": true,
 "requestProcessingTime": 28,
 "transactionBytes": "0611d06ad7023c0010f09c34f225d425306e5be55a49469081560...",
 "fullHash": "77c6dcbf770f2ce04ca8ed14ba52cdff8f7e35515bc0a8440079acd156700fb6",
 "transaction": "16153302970465568375"
}


Get Account Tagged Data

Get all available tagged data uploaded by a given account in reverse chronological order.

Request:

  • requestType is getAccountTaggedData
  • account is the account ID
  • includeData is true to include data (optional)
  • firstIndex is a zero-based index to the first tagged data to retrieve (optional)
  • lastIndex is a zero-based index to the last tagged data to retrieve (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • data (A) is an array of tagged data objects (refer to Get Tagged Data with hash omitted for details)
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)

Get Account Tagged Data Example

http://localhost:7876/nxt?
  requestType=getAccountTaggedData&
  account=NXT-4VDY-LNVT-LMAY-FMCKA&
  lastIndex=0
{
 "data": [
  {
   "data": "d4f167249340d6d746f49441b8ccdb1bd3521feb",
   "channel": "torrent",
   "description": "Hash of the torrent.",
   "type": "",
   "parsedTags": [
    "video",
    "scifi",
    "torrent"
   ],
   "transactionTimestamp": 47843875,
   "tags": "video, scifi, torrent",
   "filename": "",
   "accountRS": "NXT-4VDY-LNVT-LMAY-FMCKA",
   "name": "Stargate SG1 full series",
   "blockTimestamp": 47672045,
   "transaction": "9086193976300572942",
   "account": "15295723609781267838",
   "isText": true
  }
 ],
 "requestProcessingTime": 2
}


Get All Tagged Data

Get all available tagged data in reverse chronological order.

Request:

  • requestType is getAllTaggedData
  • includeData is true to include data (optional)
  • firstIndex is a zero-based index to the first tagged data to retrieve (optional)
  • lastIndex is a zero-based index to the last tagged data to retrieve (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • data (A) is an array of tagged data objects (refer to Get Tagged Data with hash omitted for details)
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)

Get All Tagged Data Example

http://localhost:7876/nxt?
  requestType=getAllTaggedData&
  lastIndex=0
{
 "requestProcessingTime": 1,
 "data": [
  {
   "data": "d4f167249340d6d746f49441b8ccdb1bd3521feb",
   "channel": "torrent",
   "description": "Hash of the torrent.",
   "type": "",
   "parsedTags": [
    "video",
    "scifi",
    "torrent"
   ],
   "transactionTimestamp": 47843875,
   "tags": "video, scifi, torrent",
   "filename": "",
   "accountRS": "NXT-4VDY-LNVT-LMAY-FMCKA",
   "name": "Stargate SG1 full series",
   "blockTimestamp": 47672045,
   "transaction": "9086193976300572942",
   "account": "15295723609781267838",
   "isText": true
  }
 ]
}


Get Channel Tagged Data

Get available tagged data by channel, optionally filtered by account, in reverse chronological order.

Request:

  • requestType is getChannelTaggedData
  • channel is the channel string
  • account is an account ID (optional)
  • includeData is true to include data (optional)
  • firstIndex is a zero-based index to the first tagged data to retrieve (optional)
  • lastIndex is a zero-based index to the last tagged data to retrieve (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • data (A) is an array of tagged data objects (refer to Get Tagged Data with hash omitted for details)
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)

Get Channel Tagged Data Example

http://localhost:7876/nxt?
  requestType=getChannelTaggedData&
  channel=torrent&
  lastIndex=0
{
 "data": [
  {
   "data": "d4f167249340d6d746f49441b8ccdb1bd3521feb",
   "channel": "torrent",
   "description": "Hash of the torrent.",
   "type": "",
   "parsedTags": [
    "video",
    "scifi",
    "torrent"
   ],
   "transactionTimestamp": 47843875,
   "tags": "video, scifi, torrent",
   "filename": "",
   "accountRS": "NXT-4VDY-LNVT-LMAY-FMCKA",
   "name": "Stargate SG1 full series",
   "blockTimestamp": 47672045,
   "transaction": "9086193976300572942",
   "account": "15295723609781267838",
   "isText": true
  }
 ],
 "requestProcessingTime": 1
}


Get Data Tag Count

Get the total number of distinct available data tags.

Request:

  • requestType is getDataTagCount
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • numberOfDataTags (N) is the total number of distinct data tags
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)

Get Data Tag Count Example

http://localhost:7876/nxt?
  requestType=getDataTagCount
{
 "numberOfDataTags": 3,
 "requestProcessingTime": 2
}


Get Data Tags

Get the distinct tags of all available tagged data, with the number of uses of each tag, in order of number of uses, then alphabetical order.

Request:

  • requestType is getDataTags
  • firstIndex is a zero-based index to the first tag to retrieve (optional)
  • lastIndex is a zero-based index to the last tag to retrieve (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • tags (A) is an array of tag objects including the fields:
    • tag (S) is a tag word
    • count (N) is the number of uses of tag among all tagged data
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)

Get Data Tags Example

http://localhost:7876/nxt?
  requestType=getDataTags
{
 "requestProcessingTime": 5,
 "tags": [
  {
   "count": 2,
   "tag": "video"
  },
  {
   "count": 1,
   "tag": "scifi"
  },
  {
   "count": 1,
   "tag": "torrent"
  }
 ]
}


Get Data Tags Like

Prefix search of available data tags, return in alphabetical order.

Request:

  • requestType is getDataTagsLike
  • tagPrefix is the prefix to search for (2 character minimum) among all data tags
  • firstIndex is a zero-based index to the first tag to retrieve (optional)
  • lastIndex is a zero-based index to the last tag to retrieve (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • tags (A) is an array of tag objects including the fields:
    • tag (S) is a tag word
    • count (N) is the number of uses of tag among all tagged data
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)

Get Data Tags Like Example

http://localhost:7876/nxt?
  requestType=getDataTagsLike&
  tagPrefix=sci
{
 "requestProcessingTime": 9,
 "tags": [
  {
   "count": 1,
   "tag": "scifi"
  }
 ]
}


Get Tagged Data

Get available tagged data given a transaction ID.

Request:

  • requestType is getTaggedData
  • transaction is the transaction ID
  • includeData is true to include data (optional)
  • retrieve is true to retrieve pruned data from other nodes if not available (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • data (S) is the tagged data
  • hash (S) is the hash of the tagged data
  • filename (S) is the metadata filename field
  • name (S) is the metadata name field
  • description (S) is the metadata description field
  • tags (S) is the metadata tags field
  • parsedTags (A) is an array of tag words (S) parsed from tags
  • type (S) is the metadata type field
  • channel (S) is the metadata channel field
  • isText (B) is the metadata isText field
  • account (S) is the number of the account that originally uploaded the tagged data
  • accountRS (S) is the Reed-Solomon address of the uploading account
  • transaction (S) is the transaction ID
  • transactionTimestamp (N) is the transaction timestamp (in seconds since the genesis block)
  • blockTimestamp (N) is the block timestamp (in seconds since the genesis block)
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)

Note: Refer to Upload Tagged Data for details about the data and metadata (filename, name, description, tags, type, channel and isText) fields.

Get Tagged Data Example

http://localhost:7876/nxt?
  requestType=getTaggedData&
  transaction=9086193976300572942
{
 "data": "d4f167249340d6d746f49441b8ccdb1bd3521feb",
 "channel": "torrent",
 "description": "Hash of the torrent.",
 "requestProcessingTime": 3,
 "type": "",
 "parsedTags": [
  "video",
  "scifi",
  "torrent"
 ],
 "transactionTimestamp": 47843875,
 "tags": "video, scifi, torrent",
 "filename": "",
 "accountRS": "NXT-4VDY-LNVT-LMAY-FMCKA",
 "name": "Stargate SG1 full series",
 "blockTimestamp": 47672045,
 "transaction": "9086193976300572942",
 "account": "15295723609781267838",
 "isText": true
}


Get Tagged Data Extend Transactions

Retrieves all tagged data extend transactions for a given tagged data upload transaction.

Request:

  • requestType is getTaggedDataExtendTransactions
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • extendTransactions (A) is an array of transactions
  • requestProcessingTime (N) is the API request processing time (in millisec)

Get Tagged Data Extend Transactions Example

http://localhost:7876/nxt?
  requestType=getTaggedDataExtendTransactions&
  transaction=4344513120863790923
{
  "extendTransactions": [
    {
      "senderPublicKey": "631110059365218234cc28fb6c91019f4563cf910471a9e43221795f40ab6e3a",
      "signature": "e4fe406198843207f5255e2c98119b3130b9810812934e0406a4de97a3443b0b205c907284c2e2cfd2534e8dcc17f08afb707db338e557d02673a2e6b0010186",
      "feeNQT": "150000000",
      "transactionIndex": 0,
      "type": 6,
      "confirmations": 31778,
      "fullHash": "86e8bc8c891e1556dfb9114a0ba9c4e119e6df6ba241016a1e9a85223dea42f8",
      "version": 1,
      "phased": false,
      "ecBlockId": "14132969248050944989",
      "signatureHash": "2ed7b6a5d579a66596409b2619375fa0edd54ace2e7d10f0bdbc0a7126f1776c",
      "senderRS": "NXT-G885-AKDX-5G2B-BLUCG",
      "subtype": 1,
      "amountNQT": "0",
      "sender": "10892890577210644675",
      "ecBlockHeight": 725746,
      "block": "18314376737060578519",
      "blockTimestamp": 78357439,
      "deadline": 1440,
      "transaction": "6202897637893269638",
      "timestamp": 78357424,
      "height": 725756
    }
  ],
  "requestProcessingTime": 1
}


Search Tagged Data

Full text search on available tagged data name, description and tags; optionally filtered by tag, channel or uploading account; return in reverse relevance order.

Request:

  • requestType is searchTaggedData
  • query is a full text query on the metadata fields name (S), description (S) and tags (S) in the standard Lucene syntax
  • tag is a word in the tags string (optional)
  • channel is a channel string (optional)
  • account is an account ID (optional)
  • includeData is true to include data (optional)
  • firstIndex is a zero-based index to the first tagged data to retrieve (optional)
  • lastIndex is a zero-based index to the last tagged data to retrieve (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • data (A) is an array of tagged data objects (refer to Get Tagged Data with hash omitted for details)
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)

Search Tagged Data Example

http://localhost:7876/nxt?
  requestType=searchTaggedData&
  query=SG?&
  lastIndex=0
{
 "data": [
  {
   "data": "d4f167249340d6d746f49441b8ccdb1bd3521feb",
   "channel": "torrent",
   "description": "Hash of the torrent.",
   "type": "",
   "parsedTags": [
    "video",
    "scifi",
    "torrent"
   ],
   "transactionTimestamp": 47843875,
   "tags": "video, scifi, torrent",
   "filename": "",
   "accountRS": "NXT-4VDY-LNVT-LMAY-FMCKA",
   "name": "Stargate SG1 full series",
   "blockTimestamp": 47672045,
   "transaction": "9086193976300572942",
   "account": "15295723609781267838",
   "isText": true
  }
 ],
 "requestProcessingTime": 22
}


Upload Tagged Data

Upload and broadcast new tagged data. POST only.

Request: Refer to Create Transaction Request for common parameters.

  • requestType is uploadTaggedData
  • data is the data (optional)
  • file is the pathname of a data file to upload (optional if data provided)
  • filename is a filename to associate with data (optional if file uploaded in which case the uploaded filename is always used)
  • name is the name or title of data (optional if file uploaded in which case the uploaded filename is used, but name takes precedence if provided)
  • description is a description of data (optional)
  • tags is a list of up to 5 words from 3 to 20 characters long and separated by spaces and/or commas, describing the actual content of data; for example: audio,mp3,classical (optional)
  • type is the mime type of data such as torrent, pdf, doc, image, etc. (optional)
  • channel is a data feed label such as pirate bay torrents, wikileaks, etc. (optional)
  • isText is false if data is a hex string (optional)

Note: The maximum length of data plus all associated metadata is 42 kilobytes. The maximum length of description is 1000 bytes. The maximum length of the other metadata (name, tags, type, channel and filename) is 100 bytes each.

Response: Refer to Create Transaction Response.

Upload Tagged Data Example

http://localhost:7876/nxt?
  requestType=uploadTaggedData&
  data=d4f167249340d6d746f49441b8ccdb1bd3521feb&
  name=Stargate SG1 full series&
  description=Hash of the torrent.&
  tags=video, scifi, torrent&
  channel=torrent&
  secretPhrase=secretPhrase&
  feeNQT=100000000&
  deadline=60
{
 "signatureHash": "953a1023c84939a6e31da0db913ed2829b318d59663daddce63bdf2193af912e",
 "transactionJSON": {
  "senderPublicKey": "10f09c34f225d425306e5be55a4946908156072afbead4d574a512d7e086ef5c",
  "signature": "17da947a7dc30a6d722a53f064d817c559f8f9c1387290048793d81b49dbf5082a0...",
  "feeNQT": "100000000",
  "type": 6,
  "fullHash": "0e91b0dd47a5187e26ea5b54f1917e3b879ee3cf096eb597ce22c6833863cdb2",
  "version": 1,
  "phased": false,
  "ecBlockId": "7868019187120003959",
  "signatureHash": "953a1023c84939a6e31da0db913ed2829b318d59663daddce63bdf2193af912e",
  "attachment": {
   "filename": "",
   "data": "d4f167249340d6d746f49441b8ccdb1bd3521feb",
   "name": "Stargate SG1 full series",
   "channel": "torrent",
   "description": "Hash of the torrent.",
   "type": "",
   "version.TaggedDataUpload": 1,
   "isText": true,
   "hash": "06fbac5b5358c00f5a2f19789b06220dca4e242a851b70072633a06ae8e6fb46",
   "tags": "video, scifi, torrent"
  },
  "senderRS": "NXT-4VDY-LNVT-LMAY-FMCKA",
  "subtype": 0,
  "amountNQT": "0",
  "sender": "15295723609781267838",
  "ecBlockHeight": 304598,
  "deadline": 60,
  "transaction": "9086193976300572942",
  "timestamp": 47671075,
  "height": 2147483647
 },
 "unsignedTransactionBytes": "06102367d7023c0010f09c34f225d425306e5be55a494...",
 "broadcasted": true,
 "requestProcessingTime": 284,
 "transactionBytes": "06102367d7023c0010f09c34f225d425306e5be55a49469081560...",
 "fullHash": "0e91b0dd47a5187e26ea5b54f1917e3b879ee3cf096eb597ce22c6833863cdb2",
 "transaction": "9086193976300572942"
}


Verify Tagged Data

Verify expired tagged data downloaded from another node, against the hash in the blockchain.

Request:

  • requestType is verifyTaggedData
  • transaction is the transaction ID of the tagged data
  • data is the tagged data (optional)
  • file is the pathname of a data file to upload (optional if data provided)
  • filename
  • name
  • description
  • tags
  • type
  • channel
  • isText
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Note: The data and metadata (filename, name, description, tags, type, channel and isText) must have exactly the same values as when the data was uploaded (refer to Upload Tagged Data).

Response:

  • verify (B) is true if the hash of the provided data and metadata matches the hash in the blockchain
  • hash (S) is the hash of the tagged data
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)
  • version.TaggedDataUpload (N) is 1, the version number

Note: This call returns an error if there is a hash mismatch.

Verify Tagged Data Example

http://localhost:7876/nxt?
  requestType=verifyTaggedData&
  transaction=9086193976300572942&
  data=d4f167249340d6d746f49441b8ccdb1bd3521feb&
  name=Stargate SG1 full series&
  description=Hash of the torrent.&
  tags=video, scifi, torrent&
  channel=torrent
{
 "verify": true,
 "requestProcessingTime": 7,
 "version.TaggedDataUpload": 1,
 "hash": "06fbac5b5358c00f5a2f19789b06220dca4e242a851b70072633a06ae8e6fb46"
}