Merge pull request #12 from PRavaga/main

add zano trade API
This commit is contained in:
Ravaga 2025-05-02 20:24:38 +04:00 committed by GitHub
commit 98b7a03cd0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 363 additions and 0 deletions

View file

@ -0,0 +1,3 @@
{
"label": "Zano trade API"
}

View file

@ -0,0 +1,4 @@
{
"label": "Apply for matched order",
"position": 6
}

View file

@ -0,0 +1,30 @@
# Apply for matched order
> Use this method to apply if another side hasn't done it yet.
> You can check if they applied by the **transaction** field in applyTips. If it's `false`, you can apply for it; otherwise, you are the finalizer and should use the **Confirm transaction** method.
- **METHOD**: <kbd>POST</kbd>
- **PATH**: `/api/orders/apply-order`
#### Request:
```typescript
{
token: string;
orderData: {
id: string;
connected_order_id: string;
hex_raw_proposal: string;
};
}
```
>Explanation of Fields:
>- to get `hex_raw_proposal` create [ionic swap proposal](https://docs.zano.org/docs/build/rpc-api/wallet-rpc-api/ionic_swap_generate_proposal/) via Zano wallet API;
>- hex_raw_proposal - Hex-encoded proposal raw data(encrypted with common shared key). Includes half-created transaction template and some extra information that would be needed counterparty to finialize and sign transaction
#### Response:
```typescript
{
success: boolean;
data?: string // error message
}
```

View file

@ -0,0 +1,4 @@
{
"label": "Сonfirm transaction",
"position": 7
}

View file

@ -0,0 +1,21 @@
# Confirm transaction
> Use this method to confirm that you have finalized the transaction (order or part). You can get its id from the **get-active-tx-by-orders-ids** method.
- **METHOD**: <kbd>POST</kbd>
- **PATH**: `/api/transactions/confirm`
#### Request:
```typescript
{
token: string;
transactionId: number;
}
```
#### Response:
```typescript
{
success: boolean;
data?: string // error message
}
```

View file

@ -0,0 +1,4 @@
{
"label": "Create new order",
"position": 4
}

View file

@ -0,0 +1,42 @@
# Create new order
- **METHOD**: <kbd>POST</kbd>
- **PATH**: `/api/orders/create`
#### Request:
```typescript
{
token: string;
orderData: {
type: 'buy' | 'sell';
side: 'limit'; // field naming will be fixed soon. It won't affect bots, both field names will work
price: string;
amount: string;
pairId: number;
};
}
```
#### Response:
```typescript
{
success: boolean;
data?: string |
{
hasNotification: boolean;
id: number;
type: string;
timestamp: string;
side: string;
price: string;
amount: string;
total: string;
pair_id: number;
user_id: number;
status: string;
left: string;
updatedAt: string;
createdAt: string;
}
}
```

View file

@ -0,0 +1,4 @@
{
"label": "Delete your order",
"position": 5
}

View file

@ -0,0 +1,19 @@
# Delete your order
- **METHOD**: <kbd>POST</kbd>
- **PATH**: `/api/orders/cancel`
#### Request:
```typescript
{
token: string;
orderId: number;
}
```
#### Response:
```typescript
{
success: boolean;
data?: string // error message
}
```

View file

@ -0,0 +1,4 @@
{
"label": "Get your active orders",
"position": 3
}

View file

@ -0,0 +1,52 @@
# Get your active orders
- **METHOD**: <kbd>POST</kbd>
- **PATH**: `/api/orders/get-user-page`
#### Request:
```typescript
{
token: string;
pairId: number;
}
```
#### Response:
```typescript
success: boolean;
data: {
orders: {
id: number;
type: string;
timestamp: string;
side: string;
price: string;
amount: string;
total: string;
pair_id: number;
user_id: number;
status: string;
left: string;
hasNotification: boolean;
createdAt: string;
updatedAt: string;
isInstant: boolean;
}[];
applyTips: {
id: number;
left: string;
price: string;
user: {
alias: string;
address: string;
createdAt: string;
updatedAt: string;
};
type: string;
total: string;
connected_order_id: number;
transaction: boolean;
hex_raw_proposal: string;
isInstant: boolean;
}[];
}
```

View file

@ -0,0 +1,4 @@
{
"label": "Get active Tx by orders' Ids",
"position": 10
}

View file

@ -0,0 +1,29 @@
# Get active Tx by orders' Ids
> Get active transaction data by matching 2 orders.
> So you can check if the transaction is already confirmed by another user and/or get proposal hex.
- **METHOD**: <kbd>POST</kbd>
- **PATH**: `/api/transactions/get-active-tx-by-orders-ids`
#### Request:
```typescript
{
token: string;
firstOrderId: number;
secondOrderId: number;
}
```
#### Response:
```typescript
success: boolean;
data?: {
buy_order_id: number;
sell_order_id: number;
amount: string;
timestamp: number;
status: string;
creator: string;
hex_raw_proposal: string;
} | string // error message
```

View file

@ -0,0 +1,4 @@
{
"label": "Get info about a DEX trading pair",
"position": 8
}

View file

@ -0,0 +1,69 @@
# Get info about a DEX trading pair
- **METHOD**: <kbd>POST</kbd>
- **PATH**: `/api/dex/get-pair`
#### Request:
```typescript
{
id: number;
}
```
#### Response:
```typescript
{
success: boolean;
data: {
id: number;
first_currency_id: number;
second_currency_id: number;
rate: number;
coefficient: number;
high: number;
low: number;
volume: number;
featured: boolean;
createdAt: string;
updatedAt: string;
first_currency: {
id: number;
name: string;
code: string;
type: string;
asset_id: string;
auto_parsed: boolean;
asset_info: {
id: string;
logo: string;
price: number | null;
ticker: string;
asset_id: string;
full_name: string;
meta_info: string;
price_url: string;
decimal_point: number;
current_supply: string;
total_max_supply: string;
};
whitelisted: boolean;
createdAt: string;
updatedAt: string;
};
second_currency: {
id: number;
name: string;
code: string;
type: string;
asset_id: string;
auto_parsed: boolean;
asset_info: {
decimal_point: number;
};
whitelisted: boolean;
createdAt: string;
updatedAt: string;
};
};
}
```

View file

@ -0,0 +1,4 @@
{
"label": "Overview",
"position": 1
}

View file

@ -0,0 +1,9 @@
# Trade API for custom bots
## Resources
- [Zano Trade Dex](https://trade.zano.org)
- [Zano Documentation](https://docs.zano.org)
- [Ionic Swaps Overview](https://docs.zano.org/docs/build/confidential-assets/ionic-swaps)
## Rest API ENDPOINTS
**Base URL** - https://trade.zano.org

View file

@ -0,0 +1,4 @@
{
"label": "Ping activity checker",
"position": 9
}

View file

@ -0,0 +1,22 @@
# Ping activity checker
> *You should call this method every 10 seconds to keep the `instant` icon active, so users know that your bot will accept the order immediately.*
> ![instant icon](../../../../static/img/build/zano-trade-api/ping-activity-checker/instant.jpg)
- **METHOD**: <kbd>POST</kbd>
- **PATH**: `/api/dex/renew-bot`
#### Request:
```typescript
{
token: string;
orderId: number;
}
```
#### Response:
```typescript
sucess: boolean;
data?: string // error message
```

View file

@ -0,0 +1,4 @@
{
"label": "Authenticate in System",
"position": 2
}

View file

@ -0,0 +1,27 @@
# Authenticate in System
- **METHOD**: <kbd>POST</kbd>
- **PATH**: `/api/auth`
#### Request:
```typescript
{
data: {
address: string;
alias: string;
message: string;
signature: string;
};
neverExpires: boolean;
}
```
>Explanation of Fields:
>- To get ```data``` you should [sign some message using Zano wallet](https://docs.zano.org/docs/build/rpc-api/wallet-rpc-api/sign_message/) (random string)
#### Response:
```typescript
{
success: boolean;
data?: string // error message
}
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB