Skip to content

Latest commit

 

History

History
309 lines (203 loc) · 7.4 KB

ApiKey.md

File metadata and controls

309 lines (203 loc) · 7.4 KB

\ApiKey

All URIs are relative to https://api.w3stream.xyz/api

Method HTTP request Description
Create Post /api_keys Create API key
Update Patch /api_keys/{id} Rename api key
Delete Delete /api_keys/{id} Delete API key
List Get /api_keys Get list API keys

Create

Create(request CreateApiKeyRequest) (*CreateApiKeyResponse, error)

CreateWithContext(ctx context.Context, request CreateApiKeyRequest) (*CreateApiKeyResponse, error)

Create API key

Example

package main

import (
    "context"
    "fmt"
    "encoding/json"
    "os"
    w3streamsdk "github.com/AIOZNetwork/w3stream-go-client"
)

func main() {
    // create a new client
    apiCreds := w3streamsdk.AuthCredentials{
		SecretKey: "YOUR_SECRET_KEY",
		PublicKey: "YOUR_PUBLIC_KEY",
    }
    client := w3streamsdk.ClientBuilder(apiCreds).Build()
        
    request := *w3streamsdk.NewCreateApiKeyRequest() // CreateApiKeyRequest | api key's data

    
    res, err := client.ApiKey.Create(request)

    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ApiKey.Create``: %v\n", err)
    }
    // response from `Create`: CreateApiKeyResponse
    newJsonString, err := json.MarshalIndent(res, "", "  ")
    if err != nil {
    fmt.Println(err)
    }
    fmt.Println("Response from `ApiKey.Create`")
    fmt.Println(string(newJsonString))
}

Path Parameters

Other Parameters

Name Type Description Notes
request CreateApiKeyRequest api key's data

Return type

CreateApiKeyResponse

[Back to top] [Back to API list] [Back to Model list] [Back to README]

Update

Update(id string, request RenameAPIKeyRequest) (*ResponseSuccess, error)

UpdateWithContext(ctx context.Context, id string, request RenameAPIKeyRequest) (*ResponseSuccess, error)

Rename api key

Example

package main

import (
    "context"
    "fmt"
    "encoding/json"
    "os"
    w3streamsdk "github.com/AIOZNetwork/w3stream-go-client"
)

func main() {
    // create a new client
    apiCreds := w3streamsdk.AuthCredentials{
		SecretKey: "YOUR_SECRET_KEY",
		PublicKey: "YOUR_PUBLIC_KEY",
    }
    client := w3streamsdk.ClientBuilder(apiCreds).Build()
        
    id := "id_example" // string | api key id
    request := *w3streamsdk.NewRenameAPIKeyRequest() // RenameAPIKeyRequest | new api key name

    
    res, err := client.ApiKey.Update(id, request)

    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ApiKey.Update``: %v\n", err)
    }
    // response from `Update`: ResponseSuccess
    newJsonString, err := json.MarshalIndent(res, "", "  ")
    if err != nil {
    fmt.Println(err)
    }
    fmt.Println("Response from `ApiKey.Update`")
    fmt.Println(string(newJsonString))
}

Path Parameters

Name Type Description Notes
id string api key id

Other Parameters

Name Type Description Notes
request RenameAPIKeyRequest new api key name

Return type

ResponseSuccess

[Back to top] [Back to API list] [Back to Model list] [Back to README]

Delete

Delete(id string) (*ResponseSuccess, error)

DeleteWithContext(ctx context.Context, id string) (*ResponseSuccess, error)

Delete API key

Example

package main

import (
    "context"
    "fmt"
    "encoding/json"
    "os"
    w3streamsdk "github.com/AIOZNetwork/w3stream-go-client"
)

func main() {
    // create a new client
    apiCreds := w3streamsdk.AuthCredentials{
		SecretKey: "YOUR_SECRET_KEY",
		PublicKey: "YOUR_PUBLIC_KEY",
    }
    client := w3streamsdk.ClientBuilder(apiCreds).Build()
        
    id := "id_example" // string | API key's ID

    
    res, err := client.ApiKey.Delete(id)

    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ApiKey.Delete``: %v\n", err)
    }
    // response from `Delete`: ResponseSuccess
    newJsonString, err := json.MarshalIndent(res, "", "  ")
    if err != nil {
    fmt.Println(err)
    }
    fmt.Println("Response from `ApiKey.Delete`")
    fmt.Println(string(newJsonString))
}

Path Parameters

Name Type Description Notes
id string API key's ID

Other Parameters

Name Type Description Notes

Return type

ResponseSuccess

[Back to top] [Back to API list] [Back to Model list] [Back to README]

List

List(r ApiKeyApiListRequest) (*GetApiKeysResponse, error)

ListWithContext(ctx context.Context, r ApiKeyApiListRequest) (*GetApiKeysResponse, error)

Get list API keys

Example

package main

import (
    "context"
    "fmt"
    "encoding/json"
    "os"
    w3streamsdk "github.com/AIOZNetwork/w3stream-go-client"
)

func main() {
    // create a new client
    apiCreds := w3streamsdk.AuthCredentials{
		SecretKey: "YOUR_SECRET_KEY",
		PublicKey: "YOUR_PUBLIC_KEY",
    }
    client := w3streamsdk.ClientBuilder(apiCreds).Build()
    req := w3streamsdk.ApiKeyApiListRequest{}
    
    req.Search("search_example") // string | only support search by name
    req.SortBy("sortBy_example") // string | sort by (default to "created_at")
    req.OrderBy("orderBy_example") // string | allowed: asc, desc. Default: asc (default to "asc")
    req.Offset(int32(56)) // int32 | offset, allowed values greater than or equal to 0. Default(0) (default to 0)
    req.Limit(int32(56)) // int32 | results per page. Allowed values 1-100, default is 25 (default to 25)

    res, err := client.ApiKey.List(req)
    

    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ApiKey.List``: %v\n", err)
    }
    // response from `List`: GetApiKeysResponse
    newJsonString, err := json.MarshalIndent(res, "", "  ")
    if err != nil {
    fmt.Println(err)
    }
    fmt.Println("Response from `ApiKey.List`")
    fmt.Println(string(newJsonString))
}

Path Parameters

Other Parameters

Name Type Description Notes
search string only support search by name
sortBy string sort by [default to "created_at"]
orderBy string allowed: asc, desc. Default: asc [default to "asc"]
offset int32 offset, allowed values greater than or equal to 0. Default(0) [default to 0]
limit int32 results per page. Allowed values 1-100, default is 25 [default to 25]

Return type

GetApiKeysResponse

[Back to top] [Back to API list] [Back to Model list] [Back to README]