seesdk

package module
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 8 Imported by: 0

README

See Go SDK

Official Golang SDK for S.EE URL shortener service. Create, manage, and track short URLs with ease.

Features

  • 🔗 Create short URLs with custom slugs
  • 📝 Create text/paste with syntax highlighting
  • 📂 File upload and sharing
  • 🔒 Password-protected links
  • ⏰ Expiration time support
  • 🏷️ Tag management for organization
  • 🌐 Multiple domain support
  • 📊 Track and analyze link performance
  • 📈 View account usage statistics

Installation

go get github.com/sdotee/sdk.go

Quick Start

Initialize the client with your API credentials:

import seesdk "github.com/sdotee/sdk.go"

client := seesdk.NewClient(seesdk.Config{
    BaseURL: "https://api.s.ee",
    APIKey:  "your-api-key-here",
})

Create your first short URL:

resp, err := client.CreateShortURL(seesdk.CreateShortURLRequest{
    TargetURL: "https://www.example.com/very/long/url",
    Domain:    "s.ee",
    BaseCreateRequest: seesdk.BaseCreateRequest{
        Title: "My Link",
    },
})

fmt.Printf("Short URL: %s\n", resp.Data.ShortURL)

Usage Examples

Domain and Tag Management
// Get available domains
domains, _ := client.GetDomains()
fmt.Println(domains.Data.Domains)

// Get available tags
tags, _ := client.GetTags()
for _, tag := range tags.Data.Tags {
    fmt.Printf("%s (ID: %d)\n", tag.Name, tag.Id)
}
Advanced Short URL Creation

Create a custom branded link with expiration and password protection:

expireAt := time.Now().Add(30 * 24 * time.Hour).Unix()

resp, err := client.CreateShortURL(seesdk.CreateShortURLRequest{
    TargetURL:  "https://www.example.com/campaign",
    Domain:     "s.ee",
    BaseCreateRequest: seesdk.BaseCreateRequest{
        CustomSlug: "summer-sale",
        ExpireAt:   expireAt,
        Password:   "secret123",
        Title:      "Summer Sale Campaign",
        TagIDs:     []int64{1, 2},
    },
})
Statistics
// Get account usage statistics
usage, _ := client.GetUsage()
fmt.Printf("Links created today: %d/%d\n",
    usage.Data.LinkCountDay,
    usage.Data.LinkCountDayLimit)
Update and Delete
// Update existing short URL
client.UpdateShortURL(seesdk.UpdateShortURLRequest{
    BaseSlugRequest: seesdk.BaseSlugRequest{
        Domain: "s.ee",
        Slug:   "summer-sale",
    },
    TargetURL: "https://www.example.com/new-campaign",
    Title:     "Updated Campaign",
})

// Delete short URL
client.DeleteShortURL(seesdk.DeleteURLRequest{
    BaseSlugRequest: seesdk.BaseSlugRequest{
        Domain: "s.ee",
        Slug:   "summer-sale",
    },
})

### Text Management

```go
// Create a new text/paste
textResp, err := client.CreateText(seesdk.CreateTextRequest{
    Content:    "fmt.Println(\"Hello World\")",
    Domain:     "s.ee",
    Title:      "Go Hello World",
    TextType:   "go", // Syntax highlighting
    CustomSlug: "hello-go",
})
fmt.Printf("Text URL: %s\n", textResp.Data.ShortURL)

// Update text
client.UpdateText(seesdk.UpdateTextRequest{
    Domain:  "s.ee",
    Slug:    "hello-go",
    Content: "fmt.Println(\"Hello Updated World\")",
    Title:   "Updated Go Hello World",
})

// Delete text
client.DeleteText(seesdk.DeleteTextRequest{
    Domain: "s.ee",
    Slug:   "hello-go",
})
File Management
// Get available domains for file sharing
fileDomains, _ := client.GetFileDomains()
fmt.Println(fileDomains.Data.Domains)

// Upload a file
file, _ := os.Open("image.png")
defer file.Close()

uploadResp, err := client.UploadFile("image.png", file)
if err != nil {
    log.Fatal(err)
}
fmt.Printf("File URL: %s\n", uploadResp.Data.URL)
fmt.Printf("Delete Key: %s\n", uploadResp.Data.Delete)

// Delete file
// Use the delete key returned from upload response
deleteResp, err := client.DeleteFile(uploadResp.Data.Delete)
if err != nil {
    log.Fatal(err)
}

API Reference

Client Configuration
Field Type Required Description
BaseURL string Yes API endpoint URL
APIKey string Yes Your authentication token
Timeout time.Duration No Request timeout (default: 30s)
Methods

CreateShortURL(req CreateShortURLRequest) - Create a new short URL

UpdateShortURL(req UpdateShortURLRequest) - Modify an existing short URL

DeleteShortURL(req DeleteURLRequest) - Remove a short URL

CreateText(req CreateTextRequest) - Create a new text entry

UpdateText(req UpdateTextRequest) - Modify an existing text entry

DeleteText(req DeleteTextRequest) - Remove a text entry

UploadFile(filename string, file io.Reader) - Upload a file (max 100MB)

DeleteFile(deleteKey string) - Delete a file using the delete key

GetUsage() - Get account usage statistics

GetLinkVisitStats(domain, slug, period string) - Get access statistics for a short link

GetDomains() - List available domains

GetFileDomains() - List available domains for file sharing

GetTags() - List available tags

Request Models

CreateShortURLRequest

Field Type Required Description
TargetURL string Yes Destination URL
Domain string Yes Short domain name
CustomSlug string No Custom URL slug
ExpireAt int64 No Unix timestamp (seconds)
Password string No Access password
TagIDs []int64 No Associated tag IDs
Title string No Link description
ExpirationRedirectURL string No Redirect after expiration

UpdateShortURLRequest

Field Type Required
Domain string Yes
Slug string Yes
TargetUrl string Yes
Title string No

DeleteURLRequest

Field Type Required
Domain string Yes
Slug string Yes

CreateTextRequest

Field Type Required Description
Content string Yes Text content
Domain string No Short domain name
CustomSlug string No Custom URL slug
TextType string No Syntax highlighting type
Title string No Text title
Password string No Access password
ExpireAt int64 No Unix timestamp (seconds)
TagIDs []int64 No Associated tag IDs

UpdateTextRequest

Field Type Required
Domain string Yes
Slug string Yes
Content string Yes
Title string No

DeleteTextRequest

Field Type Required
Domain string Yes
Slug string Yes

Error Handling

All methods return standard Go errors. Always check for errors:

resp, err := client.CreateShortURL(req)
if err != nil {
    log.Printf("Failed: %v", err)
    return
}

Example

See examples/main.go for complete working examples.

cd examples && go run main.go

Contributing

Issues and Pull Requests are welcome!

License

MIT License

Documentation

Index

Constants

View Source
const DefaultBaseURL = "https://s.ee/api/v1"
View Source
const DefaultTimeout = 30 * time.Second
View Source
const UsageNoLimit = -1

UsageNoLimit represents unlimited usage.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL    string
	APIKey     string
	HTTPClient *http.Client
}

Client represents the SEE SDK client for short URL operations

func NewClient

func NewClient(config Config) *Client

NewClient creates a new SEE SDK client with the given configuration.

func (*Client) CreateShortURL

func (c *Client) CreateShortURL(req CreateShortURLRequest) (*CreateShortURLResponse, error)

CreateShortURL creates a new short URL with the given parameters.

func (*Client) CreateText

func (c *Client) CreateText(req CreateTextRequest) (*CreateTextResponse, error)

CreateText creates a new text entry with the given parameters.

func (*Client) DeleteFile

func (c *Client) DeleteFile(deleteKey string) (*DeleteFileResponse, error)

DeleteFile deletes an uploaded file using its delete key.

func (*Client) DeleteShortURL

func (c *Client) DeleteShortURL(request DeleteURLRequest) (*DeleteURLResponse, error)

DeleteShortURL deletes an existing short URL.

func (*Client) DeleteText

func (c *Client) DeleteText(req DeleteTextRequest) (*DeleteTextResponse, error)

DeleteText deletes an existing text entry.

func (*Client) GetDomains

func (c *Client) GetDomains() (*DomainsResponse, error)

GetDomains retrieves the list of available domains.

func (*Client) GetFileDomains

func (c *Client) GetFileDomains() (*DomainsResponse, error)

GetFileDomains retrieves the list of available domains for file sharing.

func (*Client) GetFileHistory added in v1.1.1

func (c *Client) GetFileHistory(page int) (*GetFileHistoryResponse, error)

GetFileHistory retrieves a paginated list of uploaded files. Returns 30 files per page, sorted by creation time descending. Page starts at 1. If page is 0 or negative, defaults to page 1.

func (*Client) GetTags

func (c *Client) GetTags() (*TagsResponse, error)

GetTags retrieves the list of available tags.

func (*Client) GetTextDomains added in v1.0.1

func (c *Client) GetTextDomains() (*DomainsResponse, error)

GetTextDomains retrieves the list of available domains for text sharing.

func (*Client) GetUsage added in v1.1.0

func (c *Client) GetUsage() (*GetUsageResponse, error)

GetUsage retrieves the usage statistics of the account.

func (*Client) UpdateShortURL

func (c *Client) UpdateShortURL(request UpdateShortURLRequest) (*UpdateShortURLResponse, error)

UpdateShortURL updates an existing short URL.

func (*Client) UpdateText

func (c *Client) UpdateText(req UpdateTextRequest) (*UpdateTextResponse, error)

UpdateText updates an existing text entry.

func (*Client) UploadFile

func (c *Client) UploadFile(req UploadFileRequest) (*UploadFileResponse, error)

UploadFile uploads a file to the server.

type Config

type Config struct {
	BaseURL string
	APIKey  string
	Timeout time.Duration
}

Config contains configuration options for the Client

type CreateShortURLRequest

type CreateShortURLRequest struct {
	CustomSlug            string  `json:"custom_slug,omitempty"`
	Domain                string  `json:"domain"`
	ExpirationRedirectURL string  `json:"expiration_redirect_url,omitempty"`
	ExpireAt              int64   `json:"expire_at,omitempty"` // Unix timestamp in seconds
	Password              string  `json:"password,omitempty"`
	TagIDs                []int64 `json:"tag_ids,omitempty"`
	TargetURL             string  `json:"target_url"`
	Title                 string  `json:"title,omitempty"`
}

CreateShortURLRequest represents a request to create a short URL.

type CreateShortURLResponse

type CreateShortURLResponse struct {
	Code int `json:"code"`
	Data struct {
		CustomSlug string `json:"custom_slug"`
		ShortURL   string `json:"short_url"`
		Slug       string `json:"slug"`
	} `json:"data"`
	Message string `json:"message"`
}

CreateShortURLResponse represents the response from creating a short URL.

type CreateTextRequest

type CreateTextRequest struct {
	Content    string  `json:"content"`
	CustomSlug string  `json:"custom_slug,omitempty"`
	Domain     string  `json:"domain,omitempty"`
	ExpireAt   int64   `json:"expire_at,omitempty"` // Unix timestamp in seconds
	Password   string  `json:"password,omitempty"`
	TagIDs     []int64 `json:"tag_ids,omitempty"`
	TextType   string  `json:"text_type,omitempty"`
	Title      string  `json:"title,omitempty"`
}

type CreateTextResponse

type CreateTextResponse struct {
	Code int `json:"code"`
	Data struct {
		CustomSlug string `json:"custom_slug"`
		ShortURL   string `json:"short_url"`
		Slug       string `json:"slug"`
	}
	Message string `json:"message"`
}

type DeleteFileResponse

type DeleteFileResponse struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Success bool   `json:"success"`
}

DeleteFileResponse represents the response from deleting a file.

type DeleteTextRequest

type DeleteTextRequest struct {
	Domain string `json:"domain"`
	Slug   string `json:"slug"`
}

DeleteTextRequest represents a request to delete a text.

type DeleteTextResponse

type DeleteTextResponse struct {
	Code    int    `json:"code"`
	Data    any    `json:"data,omitempty"`
	Message string `json:"message"`
}

DeleteTextResponse represents the response from deleting a text.

type DeleteURLRequest

type DeleteURLRequest struct {
	Domain string `json:"domain"`
	Slug   string `json:"slug"`
}

DeleteURLRequest represents a request to delete a short URL.

type DeleteURLResponse

type DeleteURLResponse struct {
	Code    int    `json:"code"`
	Data    any    `json:"data,omitempty"`
	Message string `json:"message"`
}

DeleteURLResponse represents the response from deleting a short URL.

type DomainsResponse

type DomainsResponse struct {
	Code int `json:"code"`
	Data struct {
		Domains []string `json:"domains"`
	} `json:"data"`
	Message string `json:"message"`
}

DomainsResponse represents the response containing available domains.

type GetFileHistoryResponse added in v1.1.1

type GetFileHistoryResponse struct {
	Code    int              `json:"code"`
	Data    []UploadFileData `json:"data"`
	Message string           `json:"message"`
	Success bool             `json:"success"`
}

GetFileHistoryResponse represents the response containing file upload history.

type GetUsageResponse added in v1.1.0

type GetUsageResponse struct {
	Code int `json:"code"`
	Data struct {
		APICountDay           int `json:"api_count_day"`
		APICountDayLimit      int `json:"api_count_day_limit"`
		APICountMonth         int `json:"api_count_month"`
		APICountMonthLimit    int `json:"api_count_month_limit"`
		LinkCountDay          int `json:"link_count_day"`
		LinkCountDayLimit     int `json:"link_count_day_limit"`
		LinkCountMonth        int `json:"link_count_month"`
		LinkCountMonthLimit   int `json:"link_count_month_limit"`
		QRCodeCountDay        int `json:"qrcode_count_day"`
		QRCodeCountDayLimit   int `json:"qrcode_count_day_limit"`
		QRCodeCountMonth      int `json:"qrcode_count_month"`
		QRCodeCountMonthLimit int `json:"qrcode_count_month_limit"`
	} `json:"data"`
	Message string `json:"message"`
}

GetUsageResponse represents the response containing usage statistics.

type Tag

type Tag struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

Tag represents a tag entity.

type TagsResponse

type TagsResponse struct {
	Code int `json:"code"`
	Data struct {
		Tags []Tag `json:"tags"`
	} `json:"data"`
	Message string `json:"message"`
}

TagsResponse represents the response containing available tags.

type UpdateShortURLRequest

type UpdateShortURLRequest struct {
	Domain    string `json:"domain"`
	Slug      string `json:"slug"`
	TargetURL string `json:"target_url"`
	Title     string `json:"title"`
}

UpdateShortURLRequest represents a request to update a short URL.

type UpdateShortURLResponse

type UpdateShortURLResponse struct {
	Code    int    `json:"code"`
	Data    any    `json:"data"`
	Message string `json:"message"`
}

UpdateShortURLResponse represents the response from updating a short URL.

type UpdateTextRequest

type UpdateTextRequest struct {
	Domain  string `json:"domain"`
	Slug    string `json:"slug"`
	Content string `json:"content"`
	Title   string `json:"title,omitempty"`
}

type UpdateTextResponse

type UpdateTextResponse struct {
	Code    int    `json:"code"`
	Data    any    `json:"data,omitempty"`
	Message string `json:"message"`
}

UpdateTextResponse represents the response from updating a text.

type UploadFileData added in v1.1.1

type UploadFileData struct {
	CreatedAt    int    `json:"created_at,omitempty"`
	Delete       string `json:"delete"`
	FileID       int    `json:"file_id"`
	Filename     string `json:"filename"`
	Hash         string `json:"hash"`
	Height       int    `json:"height"`
	Page         string `json:"page"`
	Path         string `json:"path"`
	Size         int    `json:"size"`
	Storename    string `json:"storename"`
	UploadStatus int    `json:"upload_status"`
	URL          string `json:"url"`
	Width        int    `json:"width"`
}

UploadFileData represents the metadata of an uploaded file.

type UploadFileRequest added in v1.1.1

type UploadFileRequest struct {
	Filename   string
	File       io.Reader
	Domain     string
	CustomSlug string
	IsPrivate  bool
}

UploadFileRequest represents a request to upload a file.

type UploadFileResponse

type UploadFileResponse struct {
	Code    int            `json:"code"`
	Data    UploadFileData `json:"data"`
	Message string         `json:"message"`
}

UploadFileResponse represents the response from uploading a file.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL