Skip to content

Latest commit

 

History

History
66 lines (48 loc) · 2.86 KB

File metadata and controls

66 lines (48 loc) · 2.86 KB

ShortURLs

(ShortURLs)

Overview

REST APIs for managing short URLs

Available Operations

Create

Shorten a URL.

Example Usage

package main

import(
	"context"
	speakeasyclientsdkgo "github.com/speakeasy-api/speakeasy-client-sdk-go/v3"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := speakeasyclientsdkgo.New(
        speakeasyclientsdkgo.WithSecurity(shared.Security{
            APIKey: speakeasyclientsdkgo.String("<YOUR_API_KEY_HERE>"),
        }),
    )

    res, err := s.ShortURLs.Create(ctx, operations.CreateRequestBody{
        URL: "https://probable-heating.com/",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.ShortURL != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.CreateRequestBody ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.CreateResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.SDKError 4XX, 5XX */*