Skip to content

Commit acbd005

Browse files
authored
Merge pull request #981 from hirosystems/feat/update-stacks-api-reference
update stacks api references
2 parents 7cd2c2d + aed090c commit acbd005

22 files changed

+6347
-1452
lines changed

app/global.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,9 @@ a[href="/stacks/api/blocks/block-by-burn-block-height"],
473473
a[href="/stacks/api/blocks/block-by-hash"],
474474
a[href="/stacks/api/blocks/block-by-height"],
475475
a[href="/stacks/api/blocks/recent-blocks"],
476-
a[href="/stacks/api/fees/fee-rate"] {
476+
a[href="/stacks/api/fees/fee-rate"],
477+
a[href="/stacks/api/accounts/balances"],
478+
a[href="/stacks/api/accounts/stx-balances"] {
477479
text-decoration: line-through;
478480
color: hsl(var(--muted-foreground) / var(--tw-text-opacity));
479481
}

content/docs/stacks/api/accounts/assets.mdx

Lines changed: 91 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -29,56 +29,57 @@ import {
2929
## Get account assets
3030

3131
Retrieves a list of all assets events associated with an account or a Contract Identifier. This includes Transfers, Mints.
32-
### Path Parameters
3332

34-
<Property name={"principal"} type={"string"} required={true} deprecated={false}>
33+
### Query Parameters
3534

36-
Stacks address or a Contract identifier
35+
<Property name={"limit"} type={"Limit"} required={false} deprecated={false}>
3736

38-
<span>Example: `"SP31DA6FTSJX2WGTZ69SFY11BH51NZMB0ZW97B5P0"`</span>
37+
Results per page
3938

40-
</Property>
41-
### Query Parameters
39+
<span>Default: `20`</span>
4240

43-
<Property name={"limit"} type={"integer"} required={false} deprecated={false}>
41+
<span>Minimum: `0`</span>
4442

45-
max number of account assets to fetch
46-
47-
<span>Example: `20`</span>
43+
<span>Maximum: `100`</span>
4844

4945
</Property>
5046

51-
<Property name={"offset"} type={"integer"} required={false} deprecated={false}>
47+
<Property name={"offset"} type={"Offset"} required={false} deprecated={false}>
48+
49+
Result offset
5250

53-
index of first account assets to fetch
51+
<span>Default: `0`</span>
5452

55-
<span>Example: `42000`</span>
53+
<span>Minimum: `0`</span>
5654

5755
</Property>
5856

5957
<Property name={"unanchored"} type={"boolean"} required={false} deprecated={false}>
6058

61-
Include transaction data from unanchored (i.e. unconfirmed) microblocks
62-
63-
<span>Example: `true`</span>
59+
Include data from unanchored (i.e. unconfirmed) microblocks
6460

6561
<span>Default: `false`</span>
6662

6763
</Property>
6864

6965
<Property name={"until_block"} type={"string"} required={false} deprecated={false}>
7066

71-
returned data representing the state at that point in time, rather than the current block. Note - Use either of the query parameters but not both at a time.
67+
Block hash or block height. Return data representing the state up until that point in time, rather than the current block. Note - Use either of the query parameters but not both at a time.
7268

73-
<span>Example: `60000`</span>
69+
</Property>
70+
71+
### Path Parameters
72+
73+
<Property name={"principal"} type={"Any properties in STX Address, Smart Contract ID"} required={true} deprecated={false}>
7474

7575
</Property>
7676

7777
| Status code | Description |
78-
| :------ | :------ |
79-
| `200` | Success |
78+
| ----------- | ----------- |
79+
| `200` | Default Response |
80+
| `4XX` | Default Response |
8081

81-
<APIPlayground authorization={undefined} method={"GET"} route={"/extended/v1/address/{principal}/assets"} path={[{"name":"principal","type":"string","defaultValue":"SP31DA6FTSJX2WGTZ69SFY11BH51NZMB0ZW97B5P0","isRequired":true}]} query={[{"name":"limit","type":"number","defaultValue":20,"isRequired":false},{"name":"offset","type":"number","defaultValue":42000,"isRequired":false},{"name":"unanchored","type":"boolean","defaultValue":true,"isRequired":false},{"name":"until_block","type":"string","defaultValue":60000,"isRequired":false}]} header={[]} body={undefined} schemas={{}}>
82+
<APIPlayground authorization={undefined} method={"GET"} route={"/extended/v1/address/{principal}/assets"} path={[{"name":"principal","type":"switcher","items":{"STX Address":{"type":"ref","isRequired":true,"schema":"0"},"Smart Contract ID":{"type":"ref","isRequired":true,"schema":"1"}},"isRequired":true}]} query={[{"name":"limit","type":"number","defaultValue":"","isRequired":false,"description":"Limit"},{"name":"offset","type":"number","defaultValue":"","isRequired":false,"description":"Offset"},{"name":"unanchored","type":"boolean","defaultValue":"","isRequired":false},{"name":"until_block","type":"string","defaultValue":"","isRequired":false}]} header={[]} body={undefined} schemas={{"0":{"type":"string","defaultValue":"","isRequired":false,"description":"STX Address"},"1":{"type":"string","defaultValue":"","isRequired":false,"description":"Smart Contract ID"}}}>
8283

8384
</APIPlayground>
8485

@@ -90,16 +91,16 @@ returned data representing the state at that point in time, rather than the curr
9091

9192
<Request value={"cURL"}>
9293

93-
```terminal
94-
$ curl -X GET "https://api.hiro.so/extended/v1/address/SP31DA6FTSJX2WGTZ69SFY11BH51NZMB0ZW97B5P0/assets?limit=20&offset=42000&unanchored=true&until_block=60000"
94+
```bash
95+
curl -X GET "https://api.hiro.so/extended/v1/address/SP318Q55DEKHRXJK696033DQN5C54D9K2EE6DHRWP/assets?limit=20&offset=0&unanchored=false&until_block=string"
9596
```
9697

9798
</Request>
9899

99100
<Request value={"JavaScript"}>
100101

101102
```js
102-
fetch("https://api.hiro.so/extended/v1/address/SP31DA6FTSJX2WGTZ69SFY11BH51NZMB0ZW97B5P0/assets?limit=20&offset=42000&unanchored=true&until_block=60000", {
103+
fetch("https://api.hiro.so/extended/v1/address/SP318Q55DEKHRXJK696033DQN5C54D9K2EE6DHRWP/assets?limit=20&offset=0&unanchored=false&until_block=string", {
103104
method: "GET"
104105
});
105106
```
@@ -108,21 +109,19 @@ fetch("https://api.hiro.so/extended/v1/address/SP31DA6FTSJX2WGTZ69SFY11BH51NZMB0
108109

109110
</Requests>
110111

111-
<Responses items={["200"]}>
112+
<Responses items={["200","4XX"]}>
112113

113114
<Response value={"200"}>
114115

115-
GET request that returns address assets
116-
117116
<ResponseTypes>
118117

119118
<ExampleResponse>
120119

121120
```json
122121
{
123-
"limit": 30,
122+
"limit": 20,
124123
"offset": 0,
125-
"total": 0,
124+
"total": 1,
126125
"results": [
127126
{
128127
"event_index": 0,
@@ -146,16 +145,10 @@ GET request that returns address assets
146145
<TypeScriptResponse>
147146

148147
```ts
149-
export type TransactionEvent =
150-
| TransactionEventSmartContractLog
151-
| TransactionEventStxLock
152-
| TransactionEventStxAsset
153-
| TransactionEventFungibleAsset
154-
| TransactionEventNonFungibleAsset;
155148
/**
156149
* Only present in `smart_contract` and `contract_call` tx types.
157150
*/
158-
export type TransactionEventSmartContractLog = AbstractTransactionEvent & {
151+
export type SmartContractLogTransactionEvent = AbstractTransactionEvent & {
159152
event_type: "smart_contract_log";
160153
tx_id: string;
161154
contract_log: {
@@ -170,7 +163,7 @@ export type TransactionEventSmartContractLog = AbstractTransactionEvent & {
170163
/**
171164
* Only present in `smart_contract` and `contract_call` tx types.
172165
*/
173-
export type TransactionEventStxLock = AbstractTransactionEvent & {
166+
export type StxLockTransactionEvent = AbstractTransactionEvent1 & {
174167
event_type: "stx_lock";
175168
tx_id: string;
176169
stx_lock_event: {
@@ -182,28 +175,33 @@ export type TransactionEventStxLock = AbstractTransactionEvent & {
182175
/**
183176
* Only present in `smart_contract` and `contract_call` tx types.
184177
*/
185-
export type TransactionEventStxAsset = AbstractTransactionEvent & {
178+
export type StxAssetTransactionEvent = AbstractTransactionEvent2 & {
186179
event_type: "stx_asset";
187180
tx_id: string;
188-
asset: TransactionEventAsset;
181+
asset: {
182+
asset_event_type: "transfer" | "mint" | "burn";
183+
sender: string;
184+
recipient: string;
185+
amount: string;
186+
memo?: string;
187+
};
189188
};
190-
export type TransactionEventAssetType = "transfer" | "mint" | "burn";
191-
export type TransactionEventFungibleAsset = AbstractTransactionEvent & {
189+
export type FungibleTokenAssetTransactionEvent = AbstractTransactionEvent3 & {
192190
event_type: "fungible_token_asset";
193191
tx_id: string;
194192
asset: {
195-
asset_event_type: string;
193+
asset_event_type: "transfer" | "mint" | "burn";
196194
asset_id: string;
197195
sender: string;
198196
recipient: string;
199197
amount: string;
200198
};
201199
};
202-
export type TransactionEventNonFungibleAsset = AbstractTransactionEvent & {
200+
export type NonFungibleTokenAssetTransactionEvent = AbstractTransactionEvent4 & {
203201
event_type: "non_fungible_token_asset";
204202
tx_id: string;
205203
asset: {
206-
asset_event_type: string;
204+
asset_event_type: "transfer" | "mint" | "burn";
207205
asset_id: string;
208206
sender: string;
209207
recipient: string;
@@ -214,26 +212,63 @@ export type TransactionEventNonFungibleAsset = AbstractTransactionEvent & {
214212
};
215213
};
216214

217-
/**
218-
* GET request that returns address assets
219-
*/
220215
export interface AddressAssetsListResponse {
221216
limit: number;
222217
offset: number;
223218
total: number;
224-
results: TransactionEvent[];
219+
results: (
220+
| SmartContractLogTransactionEvent
221+
| StxLockTransactionEvent
222+
| StxAssetTransactionEvent
223+
| FungibleTokenAssetTransactionEvent
224+
| NonFungibleTokenAssetTransactionEvent
225+
)[];
225226
}
226227
export interface AbstractTransactionEvent {
227228
event_index: number;
228229
}
229-
export interface TransactionEventAsset {
230-
asset_event_type?: TransactionEventAssetType;
231-
asset_id?: string;
232-
sender?: string;
233-
recipient?: string;
234-
amount?: string;
235-
value?: string;
236-
memo?: string;
230+
export interface AbstractTransactionEvent1 {
231+
event_index: number;
232+
}
233+
export interface AbstractTransactionEvent2 {
234+
event_index: number;
235+
}
236+
export interface AbstractTransactionEvent3 {
237+
event_index: number;
238+
}
239+
export interface AbstractTransactionEvent4 {
240+
event_index: number;
241+
}
242+
```
243+
244+
</TypeScriptResponse>
245+
246+
</ResponseTypes>
247+
248+
</Response>
249+
250+
<Response value={"4XX"}>
251+
252+
<ResponseTypes>
253+
254+
<ExampleResponse>
255+
256+
```json
257+
{
258+
"error": "string",
259+
"message": "string"
260+
}
261+
```
262+
263+
</ExampleResponse>
264+
265+
<TypeScriptResponse>
266+
267+
```ts
268+
export interface ErrorResponse {
269+
error: string;
270+
message?: string;
271+
[k: string]: unknown;
237272
}
238273
```
239274

0 commit comments

Comments
 (0)