Version 1.0.0
GitHubUsing the API Guide
Learn how to interact with the Neo Service Layer API to programmatically manage resources and services.
Information
This is a basic version of the API guide. It will be expanded with more detailed content in future updates.
API Overview
The Neo Service Layer API follows RESTful principles, using standard HTTP methods and JSON payloads. All endpoints require authentication using API keys.
Base URL
1https://api.neoservicelayer.com/v1
Authentication
All API requests require an API key, which should be included in the HTTP headers:
1Authorization: Bearer YOUR_API_KEY
Example Requests
Here are examples of common API operations using different languages:
Listing Functions
1curl -X GET "https://api.neoservicelayer.com/v1/functions" \
2 -H "Authorization: Bearer YOUR_API_KEY"
1// Using the JavaScript SDK
2import { NeoServiceLayer } from 'neo-service-layer-sdk';
3
4const serviceLayer = new NeoServiceLayer({
5 apiKey: 'YOUR_API_KEY',
6 network: 'mainnet', // or 'testnet'
7});
8
9async function listFunctions() {
10 const functions = await serviceLayer.functions.list();
11 console.log('Functions:', functions);
12}
13
14listFunctions();
1package main
2
3import (
4 "fmt"
5
6 nsl "github.com/neo-service-layer/sdk"
7)
8
9func main() {
10 client := nsl.NewClient(nsl.Config{
11 APIKey: "YOUR_API_KEY",
12 Network: "mainnet", // or "testnet"
13 })
14
15 // List functions
16 functions, err := client.Functions.List(nil)
17 if err != nil {
18 fmt.Printf("Error: %v\n", err)
19 return
20 }
21
22 fmt.Printf("Functions: %+v\n", functions)
23}
Examples of listing functions using different languages
Response Handling
API responses follow a consistent format with HTTP status codes indicating success or failure:
- 2xx: Success
- 4xx: Client error (invalid parameters, unauthorized, etc.)
- 5xx: Server error
Error responses include a message explaining what went wrong:
1{
2 "error": {
3 "code": "INVALID_REQUEST",
4 "message": "The provided parameters are invalid",
5 "details": {
6 "field": "functionName",
7 "issue": "must be between 3 and 64 characters"
8 }
9 }
10}
Rate Limiting
API requests are subject to rate limiting to ensure fair usage. Rate limits vary by endpoint and account tier. When you exceed the rate limit, you'll receive a 429 response.
Tip
The
X-RateLimit-Remaining
and X-RateLimit-Reset
headers in API responses tell you how many requests you have left and when your limit will reset.