Skip to content

Commit fc6fd3b

Browse files
authored
Update public API documentation flow (#1432)
1 parent 421af80 commit fc6fd3b

File tree

5 files changed

+215
-30
lines changed

5 files changed

+215
-30
lines changed

docs/pages/coins/sdk/index.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,28 @@ bun add @zoralabs/coins-sdk
3232

3333
:::
3434

35-
3635
Additionally, the SDK requires `viem` to be installed as a peer dependency:
3736

3837
:::code-group
3938

4039
```bash [npm]
41-
npm install viem
40+
npm install viem
4241
```
4342

4443
```bash [pnpm]
45-
pnpm install viem
44+
pnpm install viem
4645
```
4746

4847
```bash [yarn]
49-
yarn add viem
48+
yarn add viem
5049
```
5150

5251
```bash [bun]
53-
bun add viem
52+
bun add viem
5453
```
5554

5655
:::
5756

58-
5957
On-chain write operations will not work without `viem` installed.
6058

6159
## Usage
@@ -68,12 +66,6 @@ It can be used on both client and server environments.
6866

6967
The Coins SDK should be used with an API key to prevent rate limiting and unlock all features.
7068

71-
To set up your API key:
72-
1. Log in or create an account on [Zora](https://zora.co)
73-
2. Navigate to [Developer Settings on Zora](https://zora.co/settings/developer)
74-
3. Create an API key
75-
4. Use the API key in the SDK
76-
7769
The API key can be set using the `setApiKey` function:
7870

7971
```ts twoslash
@@ -82,3 +74,11 @@ import { setApiKey } from "@zoralabs/coins-sdk";
8274
// Set up your API key before making any SDK requests
8375
setApiKey("your-api-key-here");
8476
```
77+
78+
To obtain an API key:
79+
80+
1. Log in or create an account on [Zora](https://zora.co)
81+
2. Navigate to [Developer Settings](https://zora.co/settings/developer)
82+
3. Create an API key
83+
84+
For REST API usage from other programming languages, see the [Public REST API documentation](/coins/sdk/public-rest-api).
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Public REST API
2+
3+
The Coins SDK provides a REST API that can be accessed from any programming language that supports HTTP requests. This allows developers to query coin data, profile information, and market metrics without needing to use JavaScript.
4+
5+
## API Documentation
6+
7+
Full interactive API documentation with a dynamic editor and OpenAPI definition file is available at:
8+
9+
**[https://api-sdk.zora.engineering/docs](https://api-sdk.zora.engineering/docs)**
10+
11+
The documentation includes:
12+
13+
- Interactive API explorer
14+
- Request/response examples
15+
- OpenAPI specification download
16+
- Real-time testing capabilities
17+
18+
## Authentication
19+
20+
### API Key Setup
21+
22+
Authentication is strongly recommended for all API requests to prevent rate limiting and ensure reliability in production environments.
23+
24+
To obtain an API key:
25+
26+
1. Log in or create an account on [Zora](https://zora.co)
27+
2. Navigate to [Developer Settings on Zora](https://zora.co/settings/developer)
28+
3. Create an API key
29+
4. Use the API key in the `api-key` header with all requests
30+
31+
### Using the API Key
32+
33+
Include the API key in the request header:
34+
35+
```bash
36+
curl -H "api-key: your-api-key-here" \
37+
https://api-sdk.zora.engineering/api/endpoint
38+
```
39+
40+
## API Endpoints
41+
42+
The REST API provides the same functionality as the SDK functions. The API paths and function names map directly to the SDK functions documented in [Coin Queries](/coins/sdk/queries).
43+
44+
### Main Endpoint Categories
45+
46+
1. **Coin Data**: Retrieve information about specific coins including metadata, market data, and comments
47+
2. **Profile Data**: Access user/wallet information including holdings and activity
48+
3. **Explore Data**: Discover coins through curated lists (new, trending, top gainers, etc.)
49+
50+
### Example Request
51+
52+
```bash
53+
# Get coin information
54+
curl -H "api-key: your-api-key-here" \
55+
"https://api-sdk.zora.engineering/coin?address=0xCoinContractAddress&chain=8453"
56+
```
57+
58+
```bash
59+
# Get profile balances
60+
curl -H "api-key: your-api-key-here" \
61+
"https://api-sdk.zora.engineering/profile?identifier=0xUserAddress"
62+
```
63+
64+
## Using with Different Languages
65+
66+
### Python Example
67+
68+
```python
69+
import requests
70+
71+
API_KEY = "your-api-key-here"
72+
BASE_URL = "https://api-sdk.zora.engineering/api"
73+
74+
headers = {
75+
"api-key": API_KEY
76+
}
77+
78+
# Get coin data
79+
response = requests.get(
80+
f"{BASE_URL}/coin",
81+
headers=headers,
82+
params={
83+
"address": "0xCoinContractAddress",
84+
"chain": 8453
85+
}
86+
)
87+
88+
coin_data = response.json()
89+
print(coin_data)
90+
```
91+
92+
### Go Example
93+
94+
```go
95+
package main
96+
97+
import (
98+
"encoding/json"
99+
"fmt"
100+
"io"
101+
"net/http"
102+
)
103+
104+
const (
105+
APIKey = "your-api-key-here"
106+
BaseURL = "https://api-sdk.zora.engineering/api"
107+
)
108+
109+
func getCoin(address string, chain int) (map[string]interface{}, error) {
110+
url := fmt.Sprintf("%s/coin?address=%s&chain=%d", BaseURL, address, chain)
111+
112+
req, err := http.NewRequest("GET", url, nil)
113+
if err != nil {
114+
return nil, err
115+
}
116+
117+
req.Header.Set("api-key", APIKey)
118+
119+
client := &http.Client{}
120+
resp, err := client.Do(req)
121+
if err != nil {
122+
return nil, err
123+
}
124+
defer resp.Body.Close()
125+
126+
body, err := io.ReadAll(resp.Body)
127+
if err != nil {
128+
return nil, err
129+
}
130+
131+
var result map[string]interface{}
132+
err = json.Unmarshal(body, &result)
133+
return result, err
134+
}
135+
```
136+
137+
### Ruby Example
138+
139+
```ruby
140+
require 'net/http'
141+
require 'json'
142+
require 'uri'
143+
144+
API_KEY = 'your-api-key-here'
145+
BASE_URL = 'https://api-sdk.zora.engineering/api'
146+
147+
def get_coin(address, chain = 8453)
148+
uri = URI("#{BASE_URL}/coin")
149+
uri.query = URI.encode_www_form(address: address, chain: chain)
150+
151+
request = Net::HTTP::Get.new(uri)
152+
request['api-key'] = API_KEY
153+
154+
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
155+
http.request(request)
156+
end
157+
158+
JSON.parse(response.body)
159+
end
160+
161+
coin_data = get_coin('0xCoinContractAddress')
162+
puts coin_data
163+
```
164+
165+
## Rate Limiting
166+
167+
Without an API key, requests are subject to high rate limiting. Using an API key significantly increases the available rate limit for users.
168+
If your use case exceeds this, please contact the team and discuss enterprise access.
169+
170+
## Related Documentation
171+
172+
- [Coin Queries](/coins/sdk/queries) - Complete reference for all available queries
173+
- [SDK Getting Started](/coins/sdk) - Using the JavaScript/TypeScript SDK
174+
- [Interactive API Docs](https://api-sdk.zora.engineering/docs) - Test and explore the API
Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Coin Queries
22

3-
The Coins SDK provides a comprehensive set of query functions to fetch information about coins, profiles, and related data. This page details the available query functions, their parameters, and usage examples.
3+
The Coins SDK provides a comprehensive set of query functions to fetch information about coins, profiles, and related data.
44

55
## Overview
66

@@ -10,9 +10,20 @@ The query functions are divided into several categories:
1010
2. **[Profile Queries](/coins/sdk/queries/profile)**: Retrieve information associated with users/wallets like holdings and activity
1111
3. **[Explore Queries](/coins/sdk/queries/explore)**: Retrieve information about all coins (new, trending, top gainers, etc.)
1212

13+
## Using the REST API
14+
15+
The Coins SDK can be used from any programming language via the **[Public REST API](/coins/sdk/public-rest-api)**. This includes:
16+
17+
- Interactive API documentation with live testing
18+
- Authentication with API keys
19+
- Code examples in multiple languages (Python, Go, Ruby, etc.)
20+
- OpenAPI specification
21+
22+
For JavaScript/TypeScript usage, continue reading below. For other languages, see the [Public REST API documentation](/coins/sdk/public-rest-api).
23+
1324
## API Key Setup
1425

15-
Before using the API queries in a high-usage production environment, you'll need to set up an API key:
26+
Before using the API queries in a high-usage production environment, set up an API key:
1627

1728
```ts twoslash
1829
import { setApiKey } from "@zoralabs/coins-sdk";
@@ -21,20 +32,11 @@ import { setApiKey } from "@zoralabs/coins-sdk";
2132
setApiKey("your-api-key-here");
2233
```
2334

24-
To set up an API key:
25-
1. Create an account on [Zora](https://zora.co)
26-
2. Navigate to [Zora Developer Settings](https://zora.co/settings/developer)
35+
To obtain an API key:
36+
37+
1. Log in or create an account on [Zora](https://zora.co)
38+
2. Navigate to [Developer Settings](https://zora.co/settings/developer)
2739
3. Create an API key
2840
4. Use the API key in the SDK
2941

30-
31-
## Non-Javascript Usage
32-
33-
The Coins SDK API can be used in any language that supports HTTP requests.
34-
35-
Full API documentation can be found [on the SDK site](https://api-sdk.zora.engineering/docs) with a dynamic editor and an openapi definition file.
36-
37-
It's strongly recommended to use the authentication header for `api-key` with all requests to this API.
38-
39-
The paths and function names map directly to the SDK functions which can be used to document the usage of these API paths.
40-
42+
For detailed authentication instructions and REST API usage, see the [Public REST API documentation](/coins/sdk/public-rest-api).

docs/vercel.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
"destination": "/coins/sdk",
3535
"permanent": true
3636
},
37+
{
38+
"source": "/coins/sdk/coins-queries",
39+
"destination": "/coins/sdk/queries",
40+
"permanent": true
41+
},
3742
{
3843
"source": "/protocol-sdk/collect/get-of-contract",
3944
"destination": "/protocol-sdk/collect/getTokensOfContract",

docs/vocs.config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ export default defineConfig({
124124
text: "Update Coin",
125125
link: "/coins/sdk/update-coin",
126126
},
127+
{
128+
text: "Public REST API",
129+
link: "/coins/sdk/public-rest-api",
130+
},
127131
{
128132
text: "Coin Queries",
129133
items: [
@@ -216,8 +220,8 @@ export default defineConfig({
216220
},
217221
resolve: {
218222
alias: {
219-
'@components': path.resolve(process.cwd(), 'components')
220-
}
223+
"@components": path.resolve(process.cwd(), "components"),
224+
},
221225
},
222226
plugins: [
223227
...(process.env.NODE_ENV === "production"

0 commit comments

Comments
 (0)