-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathapi.http
More file actions
104 lines (89 loc) · 3.62 KB
/
Copy pathapi.http
File metadata and controls
104 lines (89 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
### ─── Variables ────────────────────────────────────────────────────────
@baseUrl = http://localhost:4000
@token = YOUR_JWT_TOKEN
### ───────────────────────────────────────────────────────────────────────
### SEP-10 Authentication
### ───────────────────────────────────────────────────────────────────────
### These two requests establish a session. You need a Stellar keypair
### (public/secret). Generate one at https://laboratory.stellar.org
### or run: node -e "console.log(require('@stellar/stellar-sdk').Keypair.random().secret())"
###
### After step 3, copy the `token` field from the response and paste it
### into the @token variable at the top of this file.
### 1. Health Check
GET {{baseUrl}}/health
### 2. SEP-10 Challenge
# @name challenge
POST {{baseUrl}}/auth/challenge
Content-Type: application/json
{
"account": "GDULW5..."
}
### 3. SEP-10 Verify
# Paste the *signed* challenge XDR below, replacing "AAAAA...".
#
# How to sign:
# Option A — Stellar Laboratory
# Open https://laboratory.stellar.org/#xdr-viewer?type=TransactionEnvelope
# Paste the challenge transaction XDR → "Sign" → paste your secret key.
#
# Option B — Node.js (run from repo root)
# node -e "
# const {Keypair,TransactionBuilder} = require('@stellar/stellar-sdk');
# const tx = TransactionBuilder.fromXDR(process.argv[1], 'Testnet SDF Network ; September 2015');
# tx.sign(Keypair.fromSecret(process.argv[2]));
# console.log(tx.toXDR());
# " '<challenge-xdr>' '<your-secret>'
#
# @name verify
POST {{baseUrl}}/auth/verify
Content-Type: application/json
{
"transaction": "AAAAA..."
}
### ───────────────────────────────────────────────────────────────────────
### Authenticated requests (set @token above first)
### ───────────────────────────────────────────────────────────────────────
### 4. Get current user
GET {{baseUrl}}/me
Authorization: Bearer {{token}}
### 5. Create a group
# @name createGroup
POST {{baseUrl}}/groups
Authorization: Bearer {{token}}
Content-Type: application/json
{
"name": "Test Group",
"description": "Created via REST Client for local API exploration"
}
### 6. Add an expense
@groupId = {{createGroup.response.body.group.id}}
# @name createExpense
POST {{baseUrl}}/groups/{{groupId}}/expenses
Authorization: Bearer {{token}}
Content-Type: application/json
{
"title": "Pizza",
"amount": "45.00",
"assetCode": "XLM",
"splitType": "equal",
"shares": [
{
"userId": "CHANGE_ME"
}
]
}
### 7. Settle an expense (your unpaid share)
# Note: you can only settle a share where you are NOT the payer.
# The payer's share is auto-settled on creation. For this to succeed you
# need at least one other group member who is the payer.
@expenseId = {{createExpense.response.body.expense.id}}
POST {{baseUrl}}/expenses/{{expenseId}}/settle
Authorization: Bearer {{token}}
Content-Type: application/json
{
"assetCode": "XLM"
}
### 8. Get personal history
GET {{baseUrl}}/history
Authorization: Bearer {{token}}