Skip to content

Commit

Permalink
Merge pull request #167 from spacescan-io/sabari
Browse files Browse the repository at this point in the history
Added more info for token integration
  • Loading branch information
natsabari authored Dec 31, 2024
2 parents 5e7943d + cfa75cb commit 053e984
Show file tree
Hide file tree
Showing 4 changed files with 242 additions and 0 deletions.
167 changes: 167 additions & 0 deletions api/nft/stats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
---
sidebar_position: 2
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import CodeBlock from '@theme/CodeBlock';
import ApiCallExample from '@site/src/components/ApiCallExample';

# Get NFT Statistics

This endpoint provides global statistics about NFTs on the Chia blockchain, including collection counts, total NFTs, trade volumes, and royalty information.

### Endpoint

<Tabs>
<TabItem value="mainnet" label="Mainnet">

```
GET https://api.spacescan.io/nft/stats
```

</TabItem>
<TabItem value="testnet" label="Testnet">

```
GET https://api-testnet11.spacescan.io/nft/stats
```

</TabItem>
</Tabs>

:::info Free API
Use `api.spacescan.io` for free tier access. See our [API Plans](https://spacescan.io/apis#plans) for rate limits and features.
:::

:::tip Pro API
Use `pro-api.spacescan.io` with your API key in the `x-api-key` header. See our [API Plans](https://spacescan.io/apis#plans) for details.

```bash
curl -X GET "https://pro-api.spacescan.io/nft/stats" \
-H "x-api-key: YOUR_API_KEY"
```
:::

### Live API Test

<Tabs>
<TabItem value="mainnet" label="Mainnet">
<a href="https://api.spacescan.io/nft/stats" target="_blank" rel="noopener noreferrer" className="api-test-button">
🚀 Test API in Browser
</a>
</TabItem>
<TabItem value="testnet" label="Testnet">
<a href="https://api-testnet11.spacescan.io/nft/stats" target="_blank" rel="noopener noreferrer" className="api-test-button">
🚀 Test API in Browser
</a>
</TabItem>
</Tabs>

### Request Example

<Tabs>
<TabItem value="curl" label="cURL">
<Tabs>
<TabItem value="mainnet" label="Mainnet">
<CodeBlock language="bash">
curl -X GET "https://api.spacescan.io/nft/stats"
</CodeBlock>
</TabItem>
<TabItem value="testnet" label="Testnet">
<CodeBlock language="bash">
curl -X GET "https://api-testnet11.spacescan.io/nft/stats"
</CodeBlock>
</TabItem>
</Tabs>
</TabItem>
<TabItem value="python" label="Python">
<Tabs>
<TabItem value="mainnet" label="Mainnet">
<CodeBlock language="python">
import requests

url = "https://api.spacescan.io/nft/stats"

response = requests.get(url)
data = response.json()
print(data)
</CodeBlock>
</TabItem>
<TabItem value="testnet" label="Testnet">
<CodeBlock language="python">
import requests

url = "https://api-testnet11.spacescan.io/nft/stats"

response = requests.get(url)
data = response.json()
print(data)
</CodeBlock>
</TabItem>
</Tabs>
</TabItem>
<TabItem value="javascript" label="JavaScript">
<Tabs>
<TabItem value="mainnet" label="Mainnet">
<CodeBlock language="javascript">
const url = "https://api.spacescan.io/nft/stats";

fetch(url)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
</CodeBlock>
</TabItem>
<TabItem value="testnet" label="Testnet">
<CodeBlock language="javascript">
const url = "https://api-testnet11.spacescan.io/nft/stats";

fetch(url)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
</CodeBlock>
</TabItem>
</Tabs>
</TabItem>
</Tabs>

### Response Example

```json
{
"status": "success",
"data": {
"collections_count": 4547,
"nft_count": 1637021,
"trades_count": 104329,
"traded_amount_xch": 4.680786556872335e-8,
"royalty_amount_xch": 2.202437563733082e-9,
"traded_amount_fiat": 9.77022e-7,
"royalty_amount_fiat": 4.5972e-8
}
}
```

### Response Schema

| Field | Type | Description |
|---------------------|---------|-------------------------------------------------------|
| status | string | The status of the API request |
| data | object | Object containing NFT statistics |
| collections_count | number | Total number of NFT collections |
| nft_count | number | Total number of NFTs |
| trades_count | number | Total number of NFT trades |
| traded_amount_xch | number | Total amount of XCH traded for NFTs |
| royalty_amount_xch | number | Total amount of XCH collected as royalties |
| traded_amount_fiat | number | Total amount traded in fiat currency |
| royalty_amount_fiat| number | Total amount of royalties in fiat currency |

### Error Responses

| HTTP Status Code | Meaning |
|------------------|-------------------------------------------------------------------------------------------|
| 400 | Bad Request -- Your request is invalid. |
| 429 | Too Many Requests -- You're requesting too many times! Slow down! |
| 500 | Internal Server Error -- We had a problem with our server. Try again later. |
| 503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later. |
1 change: 1 addition & 0 deletions apisidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const sidebars = {
label: 'NFT',
items: [
'nft/info',
'nft/stats',
],
},
{
Expand Down
74 changes: 74 additions & 0 deletions docs/guide/exchange_integration/exchange_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,80 @@ The block explorer shows:
- Transactions in the block
- Block weight and other metadata

## Token Explorer Integration

To link to token details, you can use either the token symbol or token ID:

```
https://www.spacescan.io/token/{token_symbol_or_id}
```

### Examples
```
// Using token symbol
https://www.spacescan.io/token/SBX
// Using token ID
https://www.spacescan.io/token/a628c1c2c6fcb74d53746157e438e108eab5c0bb3e5c80ff9b1910b3e4832913
```

![Token Explorer](token-explorer.png)

The token explorer shows:
- Token name and symbol
- Market cap and volume
- Total and circulating supply
- Number of holders
- Recent trades and transfers
- Price charts and market data

### Token API Integration

For exchanges requiring programmatic access to token data, Spacescan.io provides comprehensive APIs:

#### 1. Get Token Information
```javascript
// Fetch basic token information, price, and supply
GET https://api.spacescan.io/token/info/{token_id}

// Example Response
{
"status": "success",
"info": {
"asset_id": "token_id",
"name": "Token Name",
"symbol": "SYMBOL",
"description": "Token description...",
"type": "CAT2"
}
}
```

#### 2. Get Total Supply
```javascript
GET https://api.spacescan.io/token/total-supply/{token_id}

// Example Response
{
"total_supply": 1000000000
}
```

#### 3. Get Circulating Supply
```javascript
GET https://api.spacescan.io/token/circulating-supply/{token_id}

// Example Response
{
"circulating_supply": 999999999
}
```

For detailed API documentation, implementation examples, and advanced usage, please refer to:
- [Token Info API Documentation](https://docs.spacescan.io/api/cat/info)
- [Total Supply API Documentation](https://docs.spacescan.io/api/cat/total-supply)
- [Circulating Supply API Documentation](https://docs.spacescan.io/api/cat/circulating-supply)

## Implementation Examples

### HTML Link
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 053e984

Please sign in to comment.