lbry-sdk/docs/index.md

652 lines
17 KiB
Markdown
Raw Normal View History

2017-02-27 23:36:29 +01:00
# LBRY JSON-RPC API Documentation
2017-02-28 18:31:55 +01:00
## blob_announce_all
2017-02-27 23:36:29 +01:00
```text
2017-02-28 18:31:55 +01:00
Announce all blobs to the DHT
2017-02-27 23:36:29 +01:00
Args:
2017-02-28 18:31:55 +01:00
None
Returns:
2017-03-14 00:14:11 +01:00
(str) Success/fail message
2017-02-27 23:36:29 +01:00
```
2017-02-28 18:31:55 +01:00
## blob_delete
2017-02-27 23:36:29 +01:00
```text
2017-02-28 18:31:55 +01:00
Delete a blob
2017-02-27 23:36:29 +01:00
Args:
2017-03-14 00:14:11 +01:00
'blob_hash': (str) hash of blob to get
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(str) Success/fail message
2017-02-27 23:36:29 +01:00
```
## blob_get
```text
2017-02-28 18:31:55 +01:00
Download and return a blob
2017-02-27 23:36:29 +01:00
Args:
2017-03-14 00:14:11 +01:00
'blob_hash': (str) blob hash of blob to get
'timeout'(optional): (int) timeout in number of seconds
'encoding'(optional): (str) by default no attempt at decoding is made,
2017-02-28 18:31:55 +01:00
can be set to one of the following decoders:
2017-03-14 00:14:11 +01:00
'json'
'payment_rate_manager'(optional): if not given the default payment rate manager
2017-02-28 18:31:55 +01:00
will be used. supported alternative rate managers:
2017-03-14 00:14:11 +01:00
'only-free'
2017-02-28 18:31:55 +01:00
2017-02-27 23:36:29 +01:00
Returns
2017-03-14 00:14:11 +01:00
(str) Success/Fail message or (dict) decoded data
2017-02-27 23:36:29 +01:00
```
## blob_list
```text
2017-03-14 00:14:11 +01:00
Returns blob hashes. If not given filters, returns all blobs known by the blob manager
2017-02-27 23:36:29 +01:00
Args:
2017-03-14 00:14:11 +01:00
'uri' (optional): (str) filter by blobs in stream for winning claim
'stream_hash' (optional): (str) filter by blobs in given stream hash
'sd_hash' (optional): (str) filter by blobs in given sd hash
'needed' (optional): (bool) only return needed blobs
'finished' (optional): (bool) only return finished blobs
'page_size' (optional): (int) limit number of results returned
'page' (optional): (int) filter to page x of [page_size] results
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(list) List of blob hashes
2017-02-27 23:36:29 +01:00
```
## blob_reflect_all
```text
Reflects all saved blobs
Args:
None
Returns:
2017-03-14 00:14:11 +01:00
(bool) true if successful
2017-02-27 23:36:29 +01:00
```
## block_show
```text
Get contents of a block
Args:
2017-03-14 00:14:11 +01:00
'blockhash': (str) hash of the block to look up
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(dict) Requested block
2017-02-27 23:36:29 +01:00
```
## claim_abandon
```text
Abandon a name and reclaim credits from the claim
Args:
2017-03-14 00:14:11 +01:00
'txid': (str) txid of claim
'nout': (int) nout of claim
2017-02-27 23:36:29 +01:00
Return:
2017-03-14 00:14:11 +01:00
(dict) Dictionary containing result of the claim
{
txid : (str) txid of resulting transaction
fee : (float) fee paid for the transaction
}
2017-02-27 23:36:29 +01:00
```
## claim_list
```text
Get claims for a name
Args:
2017-03-14 00:14:11 +01:00
'name': (str) search for claims on this name
2017-02-27 23:36:29 +01:00
Returns
2017-03-14 00:14:11 +01:00
(dict) State of claims assigned for the name
2017-03-11 22:04:10 +01:00
{
2017-03-14 00:14:11 +01:00
'claims': (list) list of claims for the name
2017-03-11 22:04:10 +01:00
[
{
2017-03-14 00:14:11 +01:00
'amount': (float) amount assigned to the claim
'effective_amount': (float) total amount assigned to the claim,
including supports
'claim_id': (str) claim ID of the claim
'height': (int) height of block containing the claim
'txid': (str) txid of the claim
'nout': (int) nout of the claim
'supports': (list) a list of supports attached to the claim
'value': (str) the value of the claim
2017-03-11 22:04:10 +01:00
},
]
2017-03-14 00:14:11 +01:00
'supports_without_claims': (list) supports without any claims attached to them
'last_takeover_height': (int) the height of last takeover for the name
2017-03-11 22:04:10 +01:00
}
2017-02-27 23:36:29 +01:00
```
## claim_list_mine
```text
List my name claims
Args:
None
Returns
2017-03-14 00:14:11 +01:00
(list) List of name claims owned by user
2017-03-11 22:04:10 +01:00
[
{
2017-03-14 00:14:11 +01:00
'address': (str) address that owns the claim
'amount': (float) amount assigned to the claim
'blocks_to_expiration': (int) number of blocks until it expires
'category': (str) "claim", "update" , or "support"
'claim_id': (str) claim ID of the claim
'confirmations': (int) number of blocks of confirmations for the claim
'expiration_height': (int) the block height which the claim will expire
'expired': (bool) true if expired, false otherwise
'height': (int) height of the block containing the claim
'is_spent': (bool) true if claim is abandoned, false otherwise
'name': (str) name of the claim
'txid': (str) txid of the cliam
'nout': (int) nout of the claim
'value': (str) value of the claim
2017-03-11 22:04:10 +01:00
},
]
2017-02-27 23:36:29 +01:00
```
## claim_new_support
```text
Support a name claim
Args:
2017-03-14 00:14:11 +01:00
'name': (str) name
'claim_id': (str) claim ID of claim to support
'amount': (float) amount to support by
2017-02-27 23:36:29 +01:00
Return:
2017-03-14 00:14:11 +01:00
(dict) Dictionary containing result of the claim
{
txid : (str) txid of resulting support claim
nout : (int) nout of the resulting support claim
fee : (float) fee paid for the transaction
}
2017-02-27 23:36:29 +01:00
```
## claim_show
```text
2017-03-11 22:04:10 +01:00
Resolve claim info from a LBRY name
2017-02-27 23:36:29 +01:00
Args:
2017-03-14 00:14:11 +01:00
'name': (str) name to look up, do not include lbry:// prefix
'txid'(optional): (str) if specified, look for claim with this txid
'nout'(optional): (int) if specified, look for claim with this nout
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(dict) Dictionary contaning claim info, (bool) false if claim is not
resolvable
2017-03-11 22:04:10 +01:00
2017-03-14 00:14:11 +01:00
{
'txid': (str) txid of claim
'nout': (int) nout of claim
'amount': (float) amount of claim
'value': (str) value of claim
'height' : (int) height of claim takeover
'claim_id': (str) claim ID of claim
'supports': (list) list of supports associated with claim
}
2017-02-27 23:36:29 +01:00
```
## commands
```text
Return a list of available commands
Returns:
2017-03-14 00:14:11 +01:00
(list) list of available commands
2017-02-27 23:36:29 +01:00
```
2017-02-28 18:31:55 +01:00
## daemon_stop
2017-02-27 23:36:29 +01:00
```text
2017-02-28 18:31:55 +01:00
Stop lbrynet-daemon
2017-02-27 23:36:29 +01:00
2017-02-28 18:31:55 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(string) Shutdown message
2017-02-27 23:36:29 +01:00
```
2017-02-28 18:31:55 +01:00
## descriptor_get
2017-02-27 23:36:29 +01:00
```text
2017-02-28 18:31:55 +01:00
Download and return a sd blob
2017-02-27 23:36:29 +01:00
2017-02-28 18:31:55 +01:00
Args:
2017-03-14 00:14:11 +01:00
'sd_hash': (str) hash of sd blob
'timeout'(optional): (int) timeout in number of seconds
'payment_rate_manager'(optional): (str) if not given the default payment rate manager
2017-02-28 18:31:55 +01:00
will be used. supported alternative rate managers:
only-free
Returns
2017-03-14 00:14:11 +01:00
(str) Success/Fail message or (dict) decoded data
2017-02-27 23:36:29 +01:00
```
## file_delete
```text
Delete a lbry file
Args:
2017-03-14 00:14:11 +01:00
'name' (optional): (str) delete file by lbry name,
'sd_hash' (optional): (str) delete file by sd hash,
'file_name' (optional): (str) delete file by the name in the downloads folder,
'stream_hash' (optional): (str) delete file by stream hash,
'claim_id' (optional): (str) delete file by claim ID,
'outpoint' (optional): (str) delete file by claim outpoint,
'rowid': (optional): (int) delete file by rowid in the file manager
'delete_target_file' (optional): (bool) delete file from downloads folder,
defaults to true if false only the blobs and
db entries will be deleted
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(bool) true if deletion was successful
2017-02-27 23:36:29 +01:00
```
## file_list
```text
2017-03-11 22:04:10 +01:00
List files limited by optional filters
2017-02-27 23:36:29 +01:00
Args:
2017-03-14 00:14:11 +01:00
'name' (optional): (str) filter files by lbry name,
'sd_hash' (optional): (str) filter files by sd hash,
'file_name' (optional): (str) filter files by the name in the downloads folder,
'stream_hash' (optional): (str) filter files by stream hash,
'claim_id' (optional): (str) filter files by claim id,
'outpoint' (optional): (str) filter files by claim outpoint,
'rowid' (optional): (int) filter files by internal row id,
'full_status': (optional): (bool) if true populate the 'message' and 'size' fields
2017-03-11 22:04:10 +01:00
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(list) List of files
2017-03-11 22:04:10 +01:00
[
{
2017-03-14 00:14:11 +01:00
'completed': (bool) true if download is completed,
'file_name': (str) name of file,
'download_directory': (str) download directory,
'points_paid': (float) credit paid to download file,
'stopped': (bool) true if download is stopped,
'stream_hash': (str) stream hash of file,
'stream_name': (str) stream name ,
'suggested_file_name': (str) suggested file name,
'sd_hash': (str) sd hash of file,
'name': (str) name claim attached to file
'outpoint': (str) claim outpoint attached to file
'claim_id': (str) claim ID attached to file,
'download_path': (str) download path of file,
'mime_type': (str) mime type of file,
'key': (str) key attached to file,
'total_bytes': (int) file size in bytes, None if full_status is false
'written_bytes': (int) written size in bytes
'message': (str), None if full_status is false
'metadata': (dict) Metadata dictionary
},
2017-03-11 22:04:10 +01:00
]
2017-02-27 23:36:29 +01:00
```
2017-03-27 18:51:19 +02:00
## file_set_status
2017-02-27 23:36:29 +01:00
```text
2017-03-27 18:51:19 +02:00
Start or stop downloading a file
2017-02-27 23:36:29 +01:00
Args:
2017-03-14 00:14:11 +01:00
'status': (str) "start" or "stop"
'name' (optional): (str) start file by lbry name,
'sd_hash' (optional): (str) start file by the hash in the name claim,
'file_name' (optional): (str) start file by its name in the downloads folder,
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(str) Confirmation message
2017-02-27 23:36:29 +01:00
```
## get
```text
2017-03-11 22:04:10 +01:00
Download stream from a LBRY name.
2017-02-27 23:36:29 +01:00
Args:
2017-03-14 00:14:11 +01:00
'name': (str) name to download
'file_name'(optional): (str) a user specified name for the downloaded file
'stream_info'(optional): (str) specified stream info overrides name
'timeout'(optional): (int) download timeout in number of seconds
'download_directory'(optional): (str) path to directory where file will be saved
'wait_for_write'(optional): (bool) defaults to True. When set, waits for the file to
2017-02-27 23:36:29 +01:00
only start to be written before returning any results.
Returns:
2017-03-14 00:14:11 +01:00
(dict) Dictionary contaning information about the stream
2017-03-11 22:04:10 +01:00
{
2017-03-14 00:14:11 +01:00
'completed': (bool) true if download is completed,
'file_name': (str) name of file,
'download_directory': (str) download directory,
'points_paid': (float) credit paid to download file,
'stopped': (bool) true if download is stopped,
'stream_hash': (str) stream hash of file,
'stream_name': (str) stream name ,
'suggested_file_name': (str) suggested file name,
'sd_hash': (str) sd hash of file,
'name': (str) name claim attached to file
'outpoint': (str) claim outpoint attached to file
'claim_id': (str) claim ID attached to file,
'download_path': (str) download path of file,
'mime_type': (str) mime type of file,
'key': (str) key attached to file,
'total_bytes': (int) file size in bytes, None if full_status is false
'written_bytes': (int) written size in bytes
'message': (str), None if full_status is false
'metadata': (dict) Metadata dictionary
2017-03-11 22:04:10 +01:00
}
2017-02-27 23:36:29 +01:00
```
## get_availability
```text
Get stream availability for a winning claim
2017-03-14 00:14:11 +01:00
Args:
'name' : (str) lbry name
'sd_timeout' (optional): (int) sd blob download timeout
'peer_timeout' (optional): (int) how long to look for peers
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(float) Peers per blob / total blobs
2017-02-27 23:36:29 +01:00
```
## help
```text
Return a useful message for an API command
Args:
2017-03-14 00:14:11 +01:00
'command'(optional): (str) command to retrieve documentation for
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(str) if given a command, returns documentation about that command
2017-02-27 23:36:29 +01:00
otherwise returns general help message
```
## peer_list
```text
Get peers for blob hash
Args:
2017-03-14 00:14:11 +01:00
'blob_hash': (str) blob hash
'timeout'(optional): (int) peer search timeout in seconds
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(list) List of contacts
2017-02-27 23:36:29 +01:00
```
## publish
```text
2017-03-28 17:47:01 +02:00
Make a new name claim and publish associated data to lbrynet,
update over existing claim if user already has a claim for name.
2017-02-27 23:36:29 +01:00
Fields required in the final Metadata are:
'title'
'description'
'author'
'language'
'license',
'nsfw'
Metadata can be set by either using the metadata argument or by setting individual arguments
fee, title, description, author, language, license, license_url, thumbnail, preview, nsfw,
or sources. Individual arguments will overwrite the fields specified in metadata argument.
2017-02-27 23:36:29 +01:00
Args:
'name': (str) name to be claimed
2017-03-14 00:14:11 +01:00
'bid': (float) amount of credits to commit in this claim,
'metadata'(optional): (dict) Metadata to associate with the claim.
'file_path'(optional): (str) path to file to be associated with name. If provided,
a lbry stream of this file will be used in 'sources'.
If no path is given but a metadata dict is provided, the source
from the given metadata will be used.
'fee'(optional): (dict) Dictionary representing key fee to download content:
{currency_symbol: {'amount': float, 'address': str, optional}}
supported currencies: LBC, USD, BTC
If an address is not provided a new one will be automatically
generated. Default fee is zero.
'title'(optional): (str) title of the file
'description'(optional): (str) description of the file
'author'(optional): (str) author of the file
'language'(optional): (str), language code
'license'(optional): (str) license for the file
'license_url'(optional): (str) URL to license
'thumbnail'(optional): (str) thumbnail URL for the file
'preview'(optional): (str) preview URL for the file
'nsfw'(optional): (bool) True if not safe for work
'sources'(optional): (dict){'lbry_sd_hash':sd_hash} specifies sd hash of file
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(dict) Dictionary containing result of the claim
{
'tx' : (str) hex encoded transaction
'txid' : (str) txid of resulting claim
'nout' : (int) nout of the resulting claim
'fee' : (float) fee paid for the claim transaction
'claim_id' : (str) claim ID of the resulting claim
}
2017-02-27 23:36:29 +01:00
```
## reflect
```text
Reflect a stream
Args:
2017-03-14 00:14:11 +01:00
'sd_hash': (str) sd_hash of lbry file
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(bool) true if successful
2017-02-27 23:36:29 +01:00
```
## report_bug
```text
Report a bug to slack
Args:
2017-03-14 00:14:11 +01:00
'message': (str) message to send
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(bool) true if successful
2017-02-27 23:36:29 +01:00
```
## resolve_name
```text
2017-03-11 22:04:10 +01:00
Resolve stream info from a LBRY name
2017-02-27 23:36:29 +01:00
Args:
2017-03-14 00:14:11 +01:00
'name': (str) name to look up, do not include lbry:// prefix
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(dict) Metadata dictionary from name claim, None if the name is not
resolvable
2017-02-27 23:36:29 +01:00
```
## send_amount_to_address
```text
Send credits to an address
Args:
2017-03-14 00:14:11 +01:00
'amount': (float) the amount to send
'address': (str) the address of the recipient in base58
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(bool) true if payment successfully scheduled
2017-02-27 23:36:29 +01:00
```
## settings_get
```text
2017-02-28 18:31:55 +01:00
Get daemon settings
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(dict) Dictionary of daemon settings
2017-03-24 18:54:43 +01:00
See ADJUSTABLE_SETTINGS in lbrynet/conf.py for full list of settings
2017-02-27 23:36:29 +01:00
```
## settings_set
```text
2017-02-28 18:31:55 +01:00
Set daemon settings
2017-02-27 23:36:29 +01:00
Args:
2017-03-14 00:14:11 +01:00
'run_on_startup': (bool) currently not supported
'data_rate': (float) data rate,
'max_key_fee': (float) maximum key fee,
'download_directory': (str) path of where files are downloaded,
'max_upload': (float), currently not supported
'max_download': (float), currently not supported
'download_timeout': (int) download timeout in seconds
2017-03-24 18:54:43 +01:00
'search_timeout': (float) search timeout in seconds
'cache_time': (int) cache timeout in seconds
2017-02-27 23:36:29 +01:00
Returns:
2017-03-24 18:54:43 +01:00
(dict) Updated dictionary of daemon settings
2017-02-27 23:36:29 +01:00
```
## status
```text
Return daemon status
Args:
2017-03-14 00:14:11 +01:00
'session_status' (optional): (bool) true to return session status,
default is false
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(dict) Daemon status dictionary
2017-02-27 23:36:29 +01:00
```
## stream_cost_estimate
```text
Get estimated cost for a lbry stream
Args:
2017-03-14 00:14:11 +01:00
'name': (str) lbry name
'size' (optional): (int) stream size, in bytes. if provided an sd blob
won't be downloaded.
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(float) Estimated cost in lbry credits
2017-02-27 23:36:29 +01:00
```
## transaction_list
```text
2017-03-14 00:14:11 +01:00
List transactions belonging to wallet
2017-02-27 23:36:29 +01:00
Args:
None
Returns:
2017-03-14 00:14:11 +01:00
(list) List of transactions
2017-02-27 23:36:29 +01:00
```
## transaction_show
```text
Get a decoded transaction from a txid
Args:
2017-03-14 00:14:11 +01:00
'txid': (str) txid of transaction
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(dict) JSON formatted transaction
2017-02-27 23:36:29 +01:00
```
## version
```text
Get lbry version information
Args:
None
Returns:
2017-03-14 00:14:11 +01:00
(dict) Dictionary of lbry version information
{
2017-03-15 21:31:58 +01:00
'build': (str) build type (e.g. "dev", "rc", "release"),
'ip': (str) remote ip, if available,
'lbrynet_update_available': (bool) whether there's an update available,
2017-03-14 00:14:11 +01:00
'lbrynet_version': (str) lbrynet_version,
'lbryum_version': (str) lbryum_version,
2017-03-15 21:31:58 +01:00
'os_release': (str) os release string
'os_system': (str) os name
'platform': (str) platform string
'processor': (str) processor type,
'python_version': (str) python version,
2017-03-14 00:14:11 +01:00
'remote_lbrynet': (str) most recent lbrynet version available from github
}
2017-02-27 23:36:29 +01:00
```
## wallet_balance
```text
Return the balance of the wallet
Returns:
2017-03-14 00:14:11 +01:00
(float) amount of lbry credits in wallet
2017-02-27 23:36:29 +01:00
```
## wallet_is_address_mine
```text
Checks if an address is associated with the current wallet.
Args:
2017-03-14 00:14:11 +01:00
'address': (str) address to check in base58
2017-02-27 23:36:29 +01:00
Returns:
2017-03-14 00:14:11 +01:00
(bool) true, if address is associated with current wallet
2017-02-27 23:36:29 +01:00
```
2017-03-24 18:54:43 +01:00
## wallet_list
```text
List wallet addresses
Args:
None
Returns:
List of wallet addresses
```
2017-02-27 23:36:29 +01:00
## wallet_new_address
```text
Generate a new wallet address
Args:
None
Returns:
2017-03-14 00:14:11 +01:00
(str) New wallet address in base58
2017-02-27 23:36:29 +01:00
```
## wallet_public_key
```text
Get public key from wallet address
Args:
2017-03-17 20:07:18 +01:00
'address': (str) wallet address in base58
2017-02-27 23:36:29 +01:00
Returns:
2017-03-17 20:07:18 +01:00
(list) list of public keys associated with address.
Could contain more than one public key if multisig.
2017-02-27 23:36:29 +01:00
```
2016-12-09 04:05:31 +01:00
2017-03-27 18:51:19 +02:00
## wallet_unused_address
```text
Return an address containing no balance, will create
a new address if there is none.
Args:
None
Returns:
(str) Unused wallet address in base58
```