|
| 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 |
0 commit comments