Filecoin JSON REST API (0.1.0)

Download OpenAPI specification:Download

Filecoin JSON REST API SPEC: erik.ingenito@protocol.ai

Filecoin JSON REST API Description

Authentication

BearerTokenAuth

The authentication scheme for this API is implementation dependent. Implementations should feel free to use the scheme and granularity they deem fit. This document describes the scheme used by the go-filecoin daemon.

Go-filecoin will initially (v0) support a simple all or nothing authentication and authorization suitable for use by the owner/operator of the current node, and nothing else. Consumers of this API must provide a bearer token included in the Authorization header of each request. This token is provided by the go-filecoin node for use by the caller via some out of band mechanism (like a file created on the filesystem upon initialization or upon startup). More sophisticated authentication and authorization will follow.

The nature of this style of authentication makes it suitable for use only when served over SSL/TLS.

Here is an example of using a node provided bearer token and a node provided CA cert used for self-signed TLS with curl. This example assumes the cert and token both reside in the .filecoin folder and where generated by the go-filecoin daemon:

$ AUTH="Authorization: Bearer $(xxd -ps -u -c 1000 $HOME/.filecoin/api/admin.token)"
$ curl -X GET --cacert $HOME/.filecoin/api/tls.cert --header "$AUTH" \
> https://localhost:3453/api/filecoin/v0/tipsets
Security scheme type: HTTP
HTTP Authorization Scheme Bearer Token

Tipsets

List Tipsets

List Tipsets currently known to this node in reverse height order

Authorizations:
query Parameters
nextPageToken
string

Next page token

Responses

200

Success

401

Access token is missing or invalid

get /chain/tipsets
http://127.0.0.1:3453/api/chain/v0/chain/tipsets

Response samples

Content type
application/json
Copy
Expand all Collapse all
[
  • {
    }
]

Fetch a Tipset by ID

Return information about the Tipset with the specified ID

Authorizations:
path Parameters
tipsetId
required
string

ID of the Tipset to fetch

Responses

200

Success

401

Access token is missing or invalid

get /chain/tipsets/{tipsetId}
http://127.0.0.1:3453/api/chain/v0/chain/tipsets/{tipsetId}

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "kind": "tipset",
  • "id": "zDPWYqFCyaQ9QJHr1qWZ19rFg3YRkcuXREkvpiHRJZhGN5T8SnyJ",
  • "height": 0,
  • "blocks":
    [
    ]
}

Blocks

Find block by ID

Return information about the Block with the specified ID

Authorizations:
path Parameters
blockId
required
string

ID of the Block to fetch

Responses

200

Success

401

Access token is missing or invalid

get /chain/blocks/{blockId}
http://127.0.0.1:3453/api/chain/v0/chain/blocks/{blockId}

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "kind": "block",
  • "id": "bafy2bzaceahv3kv4yllfdfrvtsr6rn5g5277dmxhx4tu4uvhvg2udpuate3te",
  • "header":
    {
    },
  • "executedMessages":
    [
    ]
}

Messages

Send a Message

This method sends a new Message to an Actor recipient.

Authorizations:
Request Body schema: application/json
to
string
value
number
gasPrice
number
gasLimit
number
method
string
parameters
object

Responses

200

Success

401

Access token is missing or invalid

post /chain/messages
http://127.0.0.1:3453/api/chain/v0/chain/messages

Request samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "to": "string",
  • "value": 0,
  • "gasPrice": 0,
  • "gasLimit": 0,
  • "method": "string",
  • "parameters": { }
}

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "kind": "message",
  • "id": "string",
  • "nonce": 0,
  • "from": "string",
  • "to": "string",
  • "value": 0,
  • "gasPrice": 0,
  • "gasLimit": 0,
  • "method": "string",
  • "parameters": { },
  • "signature": "string"
}

Find ExecutedMessage by ID

Return information about the ExecutedMessage with the specified ID. An executed Message is one that has been included in a valid block in the chain. It includes return value and status information.

Authorizations:
path Parameters
executedMessageId
required
string

ID of the executed message to fetch

Responses

200

Success

401

Access token is missing or invalid

get /chain/executed-messages/{executedMessageId}
http://127.0.0.1:3453/api/chain/v0/chain/executed-messages/{executedMessageId}

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "kind": "executedMessage",
  • "id": "bafy2bzacebc3bt6cedhoyw34drrmjvazhu4oj25er2ebk4u445pzycvq4ta4a",
  • "blockId": "bafy2bzacebakx3c5g22seerja562tqb32bhecp4w2quj4mhvmovy4oqzbr2u4",
  • "message":
    {
    },
  • "exitCode": 0,
  • "return": "3AE="
}

Actors

List Actors

List Actors currently known to this node in address order

Authorizations:
query Parameters
nextPageToken
string

Next page token

Responses

200

Success

get /actors
http://127.0.0.1:3453/api/chain/v0/actors

Response samples

Content type
application/json
Copy
Expand all Collapse all
[
  • {
    }
]

Find Actor by Address

Return information about the Actor with the specified Address

Authorizations:
path Parameters
address
required
string

The address of the Actor to fetch

Responses

200

Success

get /actors/{address}
http://127.0.0.1:3453/api/chain/v0/actors/{address}

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "kind": "actor",
  • "address": "string",
  • "role": "Init",
  • "nonce": 0,
  • "balance": 0,
  • "head": "string",
  • "codeCid": "string",
  • "info": { }
}

PaymentChannels

Redeem Voucher

This endpoint accepts a voucher from the PaymentChannel target and redeems it. Upon checking the validity and successfully checking the voucher's condition the specified funds will be transfered from the channel to the target.

Authorizations:
path Parameters
paymentChannelId
required
string

ID of the PaymentChannel to fetch

Request Body schema: applications/json
amount
number

The amount of FIL this Voucher is worth. This amount is sent to the target when this voucher is redeemed.

validAt
number

The block height on or after which this Voucher can be redeemed.

condition
object

The condition that must evaluate to true for this Voucher to be redeemed.

signature
string

The signature over all the data in this Voucher

Responses

200

Success

post /payment_channels/{paymentChannelId}/redeem
http://127.0.0.1:3453/api/chain/v0/payment_channels/{paymentChannelId}/redeem

Request samples

Content type
applications/json
Copy
Expand all Collapse all
{
  • "amount": 0.19296864,
  • "validAt": 2120399,
  • "condition": "TODO",
  • "signature": "TODO"
}

Creates Voucher

This endpoint accepts voucher details and returns a new signed voucher suitable for off chain transmission to the PaymentChannel target for later redemption. Only the PaymentChannel payer (creator) can call this endpoint successfully.

Authorizations:
path Parameters
paymentChannelId
required
string

ID of the PaymentChannel to fetch

Request Body schema: applications/json
amount
number

The amount of FIL this Voucher is worth. This amount is sent to the target when this voucher is redeemed.

validAt
number

The block height on or after which this Voucher can be redeemed.

condition
object

The condition that must evaluate to true for this Voucher to be redeemed.

signature
string

The signature over all the data in this Voucher

Responses

200

Success

post /payment_channels/{paymentChannelId}/vouchers
http://127.0.0.1:3453/api/chain/v0/payment_channels/{paymentChannelId}/vouchers

Request samples

Content type
applications/json
Copy
Expand all Collapse all
{
  • "amount": 0.19296864,
  • "validAt": 2120399,
  • "condition": "TODO",
  • "signature": "TODO"
}

List Payment Channels

List all PaymentChannels known to this node

Authorizations:
query Parameters
nextPageToken
string

Next page token

Responses

200

Success

get /payment_channels
http://127.0.0.1:3453/api/chain/v0/payment_channels

Response samples

Content type
application/json
Copy
Expand all Collapse all
[
  • {
    }
]

Create new PaymentChannel

This endpoint creates a new PaymentChannel with the specified characteristics

Authorizations:
Request Body schema: application/json
targetActorId
string

The address of the account to which funds will be transferred by this PaymentChannel upon successful redemption of vouchers

amount
number

The total amount of FIL that is in this PaymentChannel and payable to the target

agreedEol
number

The original chain height at which this PaymentChannel will expire. Specified upon creation and optionally extended by the creator of the channel.

Responses

200

Success

post /payment_channels
http://127.0.0.1:3453/api/chain/v0/payment_channels

Request samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "targetActorId": "t17vmiuyzqa3ygd4gsj5rsgglbj737wyztb4cohfy",
  • "amount": 0.19296864,
  • "agreedEol": 2120399
}

Response samples

Content type
application/json
Copy
Expand all Collapse all
[
  • {
    }
]

Find PaymentChannel by ID

Find a PaymentChannel by ID and return it

Authorizations:
path Parameters
paymentChannelId
required
string

ID of the PaymentChannel to fetch

Responses

200

Success

get /payment_channels/{paymentChannelId}
http://127.0.0.1:3453/api/chain/v0/payment_channels/{paymentChannelId}

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "id": "string",
  • "kind": "paymentChannel",
  • "targetActorId": "t17vmiuyzqa3ygd4gsj5rsgglbj737wyztb4cohfy",
  • "amount": 0.19296864,
  • "amountRedeemed": 0,
  • "agreedEol": 2120399,
  • "actualEol": 0,
  • "condition": "TODO",
  • "redeemed": true
}

Extend duration of PaymentChannel

This endpoint extends the duration of an existing PaymentChannel, increasing the block height at which the PaymentChannel will timeout. Only the payer (creator) or the PaymentChannel can successfully call this endpoint.

Authorizations:
path Parameters
paymentChannelId
required
string

ID of the PaymentChannel to fetch

Request Body schema: applications/json
agreedEol
number

The new chain (increased) height at which this PaymentChannel will expire.

Responses

200

Success

patch /payment_channels/{paymentChannelId}
http://127.0.0.1:3453/api/chain/v0/payment_channels/{paymentChannelId}

Request samples

Content type
applications/json
Copy
Expand all Collapse all
{
  • "agreedEol": 2120399
}

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "id": "string",
  • "kind": "paymentChannel",
  • "targetActorId": "t17vmiuyzqa3ygd4gsj5rsgglbj737wyztb4cohfy",
  • "amount": 0.19296864,
  • "amountRedeemed": 0,
  • "agreedEol": 2120399,
  • "actualEol": 0,
  • "condition": "TODO",
  • "redeemed": true
}

Schedule PaymentChannel for cancellation

This endpoint reduces the actual eol (effective end date) of the PaymentChannel in an attempt to free up the funds in the channel for earlier reclaming. This endpoint can only successfullly be called by the PaymentChannel's payer as the cancel message needs to originate from that account. Cancel doesn't immediately close a channel but instead reduces the lifetime of the channel leaving a grace period during which the payee can undo the cancellation by submitting a valid voucher, thereby proving that the channel is still in use.

Authorizations:
path Parameters
paymentChannelId
required
string

ID of the Channel to cancel

Responses

200

Success

post /payment_channels/{paymentChannelId}/cancel
http://127.0.0.1:3453/api/chain/v0/payment_channels/{paymentChannelId}/cancel

Reclaim unspent funds in Channel

This endpoint is used by the creator (payer) of a PaymentChannel to reclaim unspent funds when a PaymentChannel has timed out (the chain height has exceeded the eol of the PaymentChannel). It can only successfully be called by the PaymentChannel's payer on a timed out PaymentChannel.

Authorizations:
path Parameters
paymentChannelId
required
string

ID of the Channel to reclaim

Responses

200

Success

post /payment_channels/{paymentChannelId}/reclaim
http://127.0.0.1:3453/api/chain/v0/payment_channels/{paymentChannelId}/reclaim

Node

Return Node information

Get information about the current Filecoin Node.

Authorizations:

Responses

200

Success

get /control/node
http://127.0.0.1:3453/api/chain/v0/control/node

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "kind": "node",
  • "id": "QmeGwW4Nm543yYe5gchbETzzpcUJsPc7xtLkj7g5GCmMLq",
  • "addresses":
    [
    ],
  • "version": "1.0.2",
  • "commit": "93540266a2a9972e91947a538ce70dc9c4e8077e",
  • "protocol":
    {
    },
  • "bitswapStats":
    {
    },
  • "config": { }
}

Pieces

Add a Piece to local storage

This method imports data into the local node's temporary storage so that it can be transferred to a storage miner.

Authorizations:
Request Body schema: application/octet-stream
string <binary>