Skip to content

Commit 3e0ca28

Browse files
authored
Merge pull request #42 from jcrowthe/patch-1
Add python example to JSON-RPC documentation
2 parents ac6d79e + e1c057c commit 3e0ca28

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

json-rpc-api.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,35 @@ func main() {
5555
1. Run `go mod init` to set up your `go.mod` file
5656
2. You should now be able to interact with the Boost API.
5757

58+
### JSON-RPC in Other Languages
59+
60+
The JSON-RPC API can also be communicated with programmatically from other languages. Here is an example written in Python.
61+
Note that the `method` must be prefixed with `Filecoin.`
62+
63+
```
64+
import requests
65+
import json
66+
67+
def main():
68+
url = "http://localhost:3051/rpc/v0"
69+
headers = {'content-type': 'application/json', "Authorization": "Bearer <token>"}
70+
payload = {
71+
"method": "Filecoin.BoostOfflineDealWithData",
72+
"params": [
73+
"<deal-uuid>",
74+
"<file-path>",
75+
True
76+
],
77+
"jsonrpc": "2.0",
78+
"id": 1,
79+
}
80+
response = requests.post(url, data=json.dumps(payload), headers=headers)
81+
print(response.text)
82+
83+
if __name__ == "__main__":
84+
main()
85+
```
86+
5887
## Groups
5988

6089
* [Actor](#actor)

0 commit comments

Comments
 (0)