Getting Started
Users can connect to the API at beta.fiberapi.io:8080
, providing their API key in the process.
The domain will resolve to the closest node to the client, based on latency
(check out the regions for where this will be).
To check your latency run the following command from the same machine as your client:
ping beta.fiberapi.io
Fiber's API uses gRPC, to make the connection process as easy as possible, utilize following packages:
Programming Language | Package |
---|---|
JavaScript / TypeScript | fiber-ts |
Golang | fiber-go |
Python | fiber-py |
Rust | fiber-rs |
We highly recommend using either the Go or Rust packages if you're looking for the best performance.
If you want to build your own client (or help with the existing implementations), all you need are the protobuf / gRPC files and a compiler for your language.
Documentation for different gRPC language implementations can be found at https://grpc.io/docs/languages. The Fiber protobuf definitions are at https://github.com/chainbound/fiber-proto.
For examples of how to actually use it (API authentication), refer to the already implemented packages.
Installing
Fiber is available as a package on the following package managers:
- Golang
- Rust
- JavaScript
- Python
go get github.com/chainbound/fiber-go
cargo add --git https://github.com/chainbound/fiber-rs
npm i fiber-ts
# or
yarn add fiber-ts
pip install git+https://github.com/chainbound/fiber-py
# or
poetry add git+https://github.com/chainbound/fiber-py
Connecting
The first step is connecting to a Fiber Node API. As we've seen above, there's one URL configured with latency-based routing to always resolve to the closest instance to your client.
Here's how to use the different packages to connect to Fiber:
- Golang
- Rust
- JavaScript
- Python
import (
"context"
"log"
"time"
fiber "github.com/chainbound/fiber-go"
)
func main() {
client := fiber.NewClient("beta.fiberapi.io:8080", "YOUR_API_KEY")
// Close the client when you're done to make sure API accounting is done correctly
defer client.Close()
// Configure a timeout for establishing connection
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
if err := client.Connect(ctx); err != nil {
log.Fatal(err)
}
}
use fiber::Client;
#[tokio::main]
async fn main() {
let mut client = Client::connect(
"beta.fiberapi.io:8080".to_string(),
"YOUR_API_KEY".to_string()
).await.unwrap();
}
import { Client } from "fiber-ts";
const client = new Client("beta.fiberapi.io:8080", "YOUR_API_KEY");
// Wait 3 seconds for the client to connect
await client.waitForReady(3);
from fiber.client import Client
client = Client('beta.fiberapi.io:8080', 'YOUR_API_KEY')
try:
client.connect()
except Exception as e:
print('Error connecting', e)