(ShortURLs)
REST APIs for managing short URLs
- Create - Shorten a URL.
Shorten a URL.
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
}
}
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. |
*operations.CreateResponse, error
Error Type | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4XX, 5XX | */* |