Skip to content

Commit

Permalink
Added API Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
super3 committed Jun 23, 2015
1 parent 74e782d commit 5485953
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions README.md
Expand Up @@ -99,6 +99,81 @@ Success Examples:
1CgLoZT1ZuSHPBp3H4rLTXJvEUDV3kK7QK | Last Seen: 13 second(s) | Last Audit: 11 hour(s)
1QACy1Tx5JFzGDyPd8J3oU8SrjhkZkru4H | Last Seen: 14 second(s) | Last Audit: 11 hour(s)

### New Contract
Farmer want to get a new contract. We want to give them a "proof of capacity" contract, also known as a state "0" contract.

GET /api/contract/new/<btc_address>

Success Example:

GET /api/contract/new/191GVvAaTRxLmz3rW3nU5jAV1rF186VxQc/
RESPONSE:
Status Code: 200
Text:
{
"btc_addr": "191GVvAaTRxLmz3rW3nU5jAV1rF186VxQc"
"contract-type": 0,
"file_hash": "c059c8035bbd74aa81f4c787c39390b57b974ec9af25a7248c46a3ebfe0f9dc8",
"byte_size": 510,
"seed": "someseed"
}

Partial-Fail Example:

Generating state "0" contracts takes a little processing power on the node side. We have to use [RandomIO](https://github.com/Storj/RandomIO) to first generate the file for ourselves. If the number of clients requesting data outstrips the nodes capacity to generate this data, you will get this error.

GET /api/contract/new/191GVvAaTRxLmz3rW3nU5jAV1rF186VxQc/
Status Code: 102
Text: No available contracts.
Fail Example:

GET /api/contract/new/notvalidaddress/
RESPONSE:
Status Code: 400
Text: Contract Failed: Invalid BTC Address.

GET /api/contract/new/1EawBV7n7f2wDbgxJfNzo1eHyQ9Gj77oJd/
RESPONSE:
Status Code: 404
Text: Contract Failed: Farmer not found.
### List Contracts
We want to know what contracts the node thinks the node the farmer should be storing.

GET /api/contract/list/<btc_address>

Success Example:

GET /api/contract/list/191GVvAaTRxLmz3rW3nU5jAV1rF186VxQc/
RESPONSE:
Status Code: 200
Text:
{
"btc_addr": "191GVvAaTRxLmz3rW3nU5jAV1rF186VxQc"
"contracts": {
{"file_hash": "c059c8035bbd74aa81f4c787c39390b57b974ec9af25a7248c46a3ebfe0f9dc8", "state": 0},
{"file_hash": "85cd8077b4c5b306d74b6a77fe839d1bc6aecb221ab4b473134430b3a124197f", "state": 0},
}
}
Fail Example:

GET /api/contract/list/191GVvAaTRxLmz3rW3nU5jAV1rF186VxQc/
RESPONSE:
Status Code: 204
Text: No contracts.

GET /api/contract/list/notvalidaddress/
RESPONSE:
Status Code: 400
Text: Invalid BTC Address.

GET /api/contract/list/1EawBV7n7f2wDbgxJfNzo1eHyQ9Gj77oJd/
RESPONSE:
Status Code: 404
Text: Farmer not found.

# Client
1. Download and install [Python 3.4](https://www.python.org/downloads/release/python-343/)
2. Download the [client](https://github.com/Storj/dataserv/blob/master/tools/client.py)
Expand Down

0 comments on commit 5485953

Please sign in to comment.