Documentation
¶
Index ¶
- func Bool(b bool) param.Opt[bool]
- func BoolPtr(v bool) *bool
- func DefaultClientOptions() []option.RequestOption
- func File(rdr io.Reader, filename string, contentType string) file
- func Float(f float64) param.Opt[float64]
- func FloatPtr(v float64) *float64
- func Int(i int64) param.Opt[int64]
- func IntPtr(v int64) *int64
- func Opt[T comparable](v T) param.Opt[T]
- func Ptr[T any](v T) *T
- func String(s string) param.Opt[string]
- func StringPtr(v string) *string
- func Time(t time.Time) param.Opt[time.Time]
- func TimePtr(v time.Time) *time.Time
- type CliAuthCompleteParams
- type CliAuthCompleteResponse
- type CliAuthPollParams
- type CliAuthPollResponse
- type CliAuthPollResponseUser
- type CliAuthService
- func (r *CliAuthService) Complete(ctx context.Context, body CliAuthCompleteParams, opts ...option.RequestOption) (res *CliAuthCompleteResponse, err error)
- func (r *CliAuthService) Poll(ctx context.Context, body CliAuthPollParams, opts ...option.RequestOption) (res *CliAuthPollResponse, err error)
- func (r *CliAuthService) Start(ctx context.Context, body CliAuthStartParams, opts ...option.RequestOption) (res *CliAuthStartResponse, err error)
- type CliAuthStartParams
- type CliAuthStartResponse
- type CliService
- type Client
- func (r *Client) Delete(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, ...) error
- func (r *Client) Get(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Patch(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Post(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Put(ctx context.Context, path string, params any, res any, ...) error
- type DictionaryDefinition
- type DictionaryEntry
- type DictionaryLanguagesResponse
- type DictionaryLookupParams
- type DictionaryLookupParamsExact
- type DictionaryLookupParamsExamples
- type DictionaryLookupResponse
- type DictionaryService
- type Error
- type LanguageInfo
- type PuzzleGenerateParams
- type PuzzleGenerateParamsDifficulty
- type PuzzleGenerateParamsHardMode
- type PuzzleHint
- type PuzzleMetadata
- type PuzzleResponse
- type PuzzleResponseDifficulty
- type PuzzleService
- type WordDailyParams
- type WordDailyResponse
- type WordGetDailyParams
- type WordGetDailyResponse
- type WordGetRandomParams
- type WordGetRandomResponse
- type WordRandomParams
- type WordRandomResponse
- type WordService
- func (r *WordService) Daily(ctx context.Context, query WordDailyParams, opts ...option.RequestOption) (res *WordDailyResponse, err error)
- func (r *WordService) GetDaily(ctx context.Context, query WordGetDailyParams, opts ...option.RequestOption) (res *WordGetDailyResponse, err error)
- func (r *WordService) GetRandom(ctx context.Context, query WordGetRandomParams, opts ...option.RequestOption) (res *WordGetRandomResponse, err error)
- func (r *WordService) Random(ctx context.Context, query WordRandomParams, opts ...option.RequestOption) (res *WordRandomResponse, err error)
- func (r *WordService) Validate(ctx context.Context, query WordValidateParams, opts ...option.RequestOption) (res *WordValidateResponse, err error)
- type WordValidateParams
- type WordValidateResponse
- type WordsetGetParams
- type WordsetGetParamsRandom
- type WordsetGetParamsScramble
- type WordsetResponse
- type WordsetService
- type WordsetWord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultClientOptions ¶
func DefaultClientOptions() []option.RequestOption
DefaultClientOptions read from the environment (ANAGRAMA_API_KEY, ANAGRAMA_BASE_URL). This should be used to initialize new clients.
func Opt ¶
func Opt[T comparable](v T) param.Opt[T]
Types ¶
type CliAuthCompleteParams ¶
type CliAuthCompleteParams struct {
// The device code from the authentication session.
DeviceCode param.Opt[string] `json:"device_code,omitzero"`
// The user code from the authentication session.
UserCode param.Opt[string] `json:"user_code,omitzero"`
// contains filtered or unexported fields
}
func (CliAuthCompleteParams) MarshalJSON ¶
func (r CliAuthCompleteParams) MarshalJSON() (data []byte, err error)
func (*CliAuthCompleteParams) UnmarshalJSON ¶
func (r *CliAuthCompleteParams) UnmarshalJSON(data []byte) error
type CliAuthCompleteResponse ¶
type CliAuthCompleteResponse struct {
// Always `true` on success.
Ok bool `json:"ok,required"`
// The resulting session status.
Status constant.Approved `json:"status,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Ok respjson.Field
Status respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (CliAuthCompleteResponse) RawJSON ¶
func (r CliAuthCompleteResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*CliAuthCompleteResponse) UnmarshalJSON ¶
func (r *CliAuthCompleteResponse) UnmarshalJSON(data []byte) error
type CliAuthPollParams ¶
type CliAuthPollParams struct {
// The device code returned from `/cli/auth/start`.
DeviceCode param.Opt[string] `json:"device_code,omitzero"`
// The user code returned from `/cli/auth/start`.
UserCode param.Opt[string] `json:"user_code,omitzero"`
// contains filtered or unexported fields
}
func (CliAuthPollParams) MarshalJSON ¶
func (r CliAuthPollParams) MarshalJSON() (data []byte, err error)
func (*CliAuthPollParams) UnmarshalJSON ¶
func (r *CliAuthPollParams) UnmarshalJSON(data []byte) error
type CliAuthPollResponse ¶
type CliAuthPollResponse struct {
// The API token (prefixed with `cli_`). Store this securely and use it as a Bearer
// token for authenticated API calls.
Token string `json:"token,required"`
// The session status. Always `"approved"` for a 200 response.
Status constant.Approved `json:"status,required"`
// Basic profile information for the authenticated user.
User CliAuthPollResponseUser `json:"user,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Token respjson.Field
Status respjson.Field
User respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (CliAuthPollResponse) RawJSON ¶
func (r CliAuthPollResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*CliAuthPollResponse) UnmarshalJSON ¶
func (r *CliAuthPollResponse) UnmarshalJSON(data []byte) error
type CliAuthPollResponseUser ¶
type CliAuthPollResponseUser struct {
// The user's display name. Falls back to username, first name, last name, or
// "Player".
DisplayName string `json:"displayName,required"`
// The user's unique identifier.
UserID string `json:"userId,required"`
// The user's username, or null if not set.
Username string `json:"username,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
DisplayName respjson.Field
UserID respjson.Field
Username respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Basic profile information for the authenticated user.
func (CliAuthPollResponseUser) RawJSON ¶
func (r CliAuthPollResponseUser) RawJSON() string
Returns the unmodified JSON received from the API
func (*CliAuthPollResponseUser) UnmarshalJSON ¶
func (r *CliAuthPollResponseUser) UnmarshalJSON(data []byte) error
type CliAuthService ¶
type CliAuthService struct {
Options []option.RequestOption
}
CliAuthService contains methods and other services that help with interacting with the anagrama API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewCliAuthService method instead.
func NewCliAuthService ¶
func NewCliAuthService(opts ...option.RequestOption) (r CliAuthService)
NewCliAuthService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*CliAuthService) Complete ¶
func (r *CliAuthService) Complete(ctx context.Context, body CliAuthCompleteParams, opts ...option.RequestOption) (res *CliAuthCompleteResponse, err error)
Called by the web application after the user approves the CLI authentication request. This endpoint requires a valid Anagrama web session (browser cookie-based auth) and is not intended for direct SDK use.
Approves the pending session identified by `deviceCode` or `userCode`, generates an API token, and stores it. The CLI can then retrieve the token by polling `/cli/auth/poll`.
func (*CliAuthService) Poll ¶
func (r *CliAuthService) Poll(ctx context.Context, body CliAuthPollParams, opts ...option.RequestOption) (res *CliAuthPollResponse, err error)
Polls the status of a device-flow authentication session. The CLI should call this endpoint at the interval specified in the `/cli/auth/start` response until it receives a status of `"approved"` with a token.
The token is returned exactly once -- if the session has already been consumed by a previous successful poll, a `409` status is returned.
Rate limited to 30 requests per minute per IP address.
func (*CliAuthService) Start ¶
func (r *CliAuthService) Start(ctx context.Context, body CliAuthStartParams, opts ...option.RequestOption) (res *CliAuthStartResponse, err error)
Initiates a device-flow authentication session. Returns a device code, a human-readable user code, and a verification URL. The CLI should display the verification URL and user code to the user, then poll `/cli/auth/poll` until the session is approved.
Rate limited to 10 requests per minute per IP address.
type CliAuthStartParams ¶
type CliAuthStartParams struct {
// The name of the CLI client application (e.g., "anagrama-cli").
ClientName param.Opt[string] `json:"clientName,omitzero"`
// A human-readable label for this token (e.g., "My Laptop"). HTML special
// characters are stripped. Truncated to 100 characters.
Label param.Opt[string] `json:"label,omitzero"`
// contains filtered or unexported fields
}
func (CliAuthStartParams) MarshalJSON ¶
func (r CliAuthStartParams) MarshalJSON() (data []byte, err error)
func (*CliAuthStartParams) UnmarshalJSON ¶
func (r *CliAuthStartParams) UnmarshalJSON(data []byte) error
type CliAuthStartResponse ¶
type CliAuthStartResponse struct {
// Unique device code for this authentication session. Used when polling for
// approval.
DeviceCode string `json:"device_code,required"`
// Number of seconds until this authentication session expires. Default is 900 (15
// minutes).
ExpiresIn int64 `json:"expires_in,required"`
// Minimum number of seconds the CLI should wait between poll requests. Default
// is 3.
Interval int64 `json:"interval,required"`
// A short, human-readable code displayed to the user for verification.
UserCode string `json:"user_code,required"`
// The full URL the user should visit to authorize the CLI. Includes the
// device_code and user_code as query parameters.
VerificationURL string `json:"verification_url,required" format:"uri"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
DeviceCode respjson.Field
ExpiresIn respjson.Field
Interval respjson.Field
UserCode respjson.Field
VerificationURL respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (CliAuthStartResponse) RawJSON ¶
func (r CliAuthStartResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*CliAuthStartResponse) UnmarshalJSON ¶
func (r *CliAuthStartResponse) UnmarshalJSON(data []byte) error
type CliService ¶
type CliService struct {
Options []option.RequestOption
Auth CliAuthService
}
CliService contains methods and other services that help with interacting with the anagrama API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewCliService method instead.
func NewCliService ¶
func NewCliService(opts ...option.RequestOption) (r CliService)
NewCliService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
type Client ¶
type Client struct {
Options []option.RequestOption
Words WordService
Puzzles PuzzleService
Dictionary DictionaryService
Wordsets WordsetService
Cli CliService
}
Client creates a struct with services and top level methods that help with interacting with the anagrama API. You should not instantiate this client directly, and instead use the NewClient method instead.
func NewClient ¶
func NewClient(opts ...option.RequestOption) (r Client)
NewClient generates a new client with the default option read from the environment (ANAGRAMA_API_KEY, ANAGRAMA_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.
func (*Client) Delete ¶
func (r *Client) Delete(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Execute ¶
func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error
Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.
If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.
The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned url.Values will be used as query strings to the url.
If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.
Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.
The response body will be deserialized into the res variable, depending on its type:
- A pointer to a *http.Response is populated by the raw response.
- A pointer to a byte array will be populated with the contents of the request body.
- A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
- A nil value will not read the response body.
For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.
func (*Client) Get ¶
func (r *Client) Get(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Patch ¶
func (r *Client) Patch(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
type DictionaryDefinition ¶ added in v0.5.0
type DictionaryDefinition struct {
// The definition text.
Gloss string `json:"gloss,required"`
// An example sentence demonstrating usage.
Example string `json:"example"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Gloss respjson.Field
Example respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
A single definition of a word with an optional usage example.
func (DictionaryDefinition) RawJSON ¶ added in v0.5.0
func (r DictionaryDefinition) RawJSON() string
Returns the unmodified JSON received from the API
func (*DictionaryDefinition) UnmarshalJSON ¶ added in v0.5.0
func (r *DictionaryDefinition) UnmarshalJSON(data []byte) error
type DictionaryEntry ¶ added in v0.5.0
type DictionaryEntry struct {
// Part of speech (e.g., "noun", "verb", "adjective").
Pos string `json:"pos,required"`
// Words with opposite meaning.
Antonyms []string `json:"antonyms"`
// Definitions for this part of speech.
Definitions []DictionaryDefinition `json:"definitions"`
// Words derived from this word.
Derived []string `json:"derived"`
// The etymology (origin) of the word.
Etymology string `json:"etymology"`
// Inflected forms of the word (e.g., plural, past tense).
Forms []string `json:"forms"`
// More general terms (e.g., "animal" is a hypernym of "dog").
Hypernyms []string `json:"hypernyms"`
// More specific terms (e.g., "poodle" is a hyponym of "dog").
Hyponyms []string `json:"hyponyms"`
// Semantically related words.
Related []string `json:"related"`
// Words with similar meaning.
Synonyms []string `json:"synonyms"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Pos respjson.Field
Antonyms respjson.Field
Definitions respjson.Field
Derived respjson.Field
Etymology respjson.Field
Forms respjson.Field
Hypernyms respjson.Field
Hyponyms respjson.Field
Related respjson.Field
Synonyms respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
A dictionary entry for a specific part of speech, including definitions, etymology, and related words.
func (DictionaryEntry) RawJSON ¶ added in v0.5.0
func (r DictionaryEntry) RawJSON() string
Returns the unmodified JSON received from the API
func (*DictionaryEntry) UnmarshalJSON ¶ added in v0.5.0
func (r *DictionaryEntry) UnmarshalJSON(data []byte) error
type DictionaryLanguagesResponse ¶ added in v0.5.0
type DictionaryLanguagesResponse struct {
// Total number of available languages.
Count int64 `json:"count,required"`
// Array of available languages with entry counts.
Languages []LanguageInfo `json:"languages,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Count respjson.Field
Languages respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (DictionaryLanguagesResponse) RawJSON ¶ added in v0.5.0
func (r DictionaryLanguagesResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*DictionaryLanguagesResponse) UnmarshalJSON ¶ added in v0.5.0
func (r *DictionaryLanguagesResponse) UnmarshalJSON(data []byte) error
type DictionaryLookupParams ¶ added in v0.5.0
type DictionaryLookupParams struct {
// Maximum number of definitions to return per entry. Clamped to [0, 50].
Definitions param.Opt[int64] `query:"definitions,omitzero" json:"-"`
// Comma-separated list of fields to include in the response (e.g.,
// "definitions,etymology,synonyms"). When omitted, all fields are returned.
Fields param.Opt[string] `query:"fields,omitzero" json:"-"`
// ISO 639-1 language code. Defaults to "en" (English).
Lang param.Opt[string] `query:"lang,omitzero" json:"-"`
// Maximum number of results to return for fuzzy searches. Clamped to [1, 20].
// Ignored for exact lookups.
Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
// Filter results by part of speech (e.g., "noun", "verb", "adjective").
Pos param.Opt[string] `query:"pos,omitzero" json:"-"`
// When `"true"`, performs an exact lookup. When `"false"`, performs a fuzzy search
// returning similar words.
//
// Any of "true", "false".
Exact DictionaryLookupParamsExact `query:"exact,omitzero" json:"-"`
// When `"true"`, includes usage examples in definitions.
//
// Any of "true", "false".
Examples DictionaryLookupParamsExamples `query:"examples,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (DictionaryLookupParams) URLQuery ¶ added in v0.5.0
func (r DictionaryLookupParams) URLQuery() (v url.Values, err error)
URLQuery serializes DictionaryLookupParams's query parameters as `url.Values`.
type DictionaryLookupParamsExact ¶ added in v0.5.0
type DictionaryLookupParamsExact string
When `"true"`, performs an exact lookup. When `"false"`, performs a fuzzy search returning similar words.
const ( DictionaryLookupParamsExactTrue DictionaryLookupParamsExact = "true" DictionaryLookupParamsExactFalse DictionaryLookupParamsExact = "false" )
type DictionaryLookupParamsExamples ¶ added in v0.5.0
type DictionaryLookupParamsExamples string
When `"true"`, includes usage examples in definitions.
const ( DictionaryLookupParamsExamplesTrue DictionaryLookupParamsExamples = "true" DictionaryLookupParamsExamplesFalse DictionaryLookupParamsExamples = "false" )
type DictionaryLookupResponse ¶ added in v0.5.0
type DictionaryLookupResponse struct {
// The language code used for the lookup.
Lang string `json:"lang,required"`
// Dictionary entries for the word, one per part of speech.
Results []DictionaryEntry `json:"results,required"`
// The word that was looked up.
Word string `json:"word,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Lang respjson.Field
Results respjson.Field
Word respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Response for an exact dictionary word lookup.
func (DictionaryLookupResponse) RawJSON ¶ added in v0.5.0
func (r DictionaryLookupResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*DictionaryLookupResponse) UnmarshalJSON ¶ added in v0.5.0
func (r *DictionaryLookupResponse) UnmarshalJSON(data []byte) error
type DictionaryService ¶ added in v0.5.0
type DictionaryService struct {
Options []option.RequestOption
}
DictionaryService contains methods and other services that help with interacting with the anagrama API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewDictionaryService method instead.
func NewDictionaryService ¶ added in v0.5.0
func NewDictionaryService(opts ...option.RequestOption) (r DictionaryService)
NewDictionaryService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*DictionaryService) Languages ¶ added in v0.5.0
func (r *DictionaryService) Languages(ctx context.Context, opts ...option.RequestOption) (res *DictionaryLanguagesResponse, err error)
Returns a list of all languages available in the Anagrama dictionary, along with the number of entries for each language. Requires a valid API key as a Bearer token.
func (*DictionaryService) Lookup ¶ added in v0.5.0
func (r *DictionaryService) Lookup(ctx context.Context, word string, query DictionaryLookupParams, opts ...option.RequestOption) (res *DictionaryLookupResponse, err error)
Retrieves detailed dictionary entries for a word, including definitions, etymology, part of speech, synonyms, antonyms, and related words. When `exact` is set to `false`, performs a fuzzy search and returns matching candidates. Requires a valid API key as a Bearer token.
type LanguageInfo ¶ added in v0.5.0
type LanguageInfo struct {
// ISO 639-1 language code (e.g., "en", "es", "fr").
Code string `json:"code,required"`
// Number of dictionary entries available for this language.
Entries int64 `json:"entries,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Code respjson.Field
Entries respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Information about a supported dictionary language.
func (LanguageInfo) RawJSON ¶ added in v0.5.0
func (r LanguageInfo) RawJSON() string
Returns the unmodified JSON received from the API
func (*LanguageInfo) UnmarshalJSON ¶ added in v0.5.0
func (r *LanguageInfo) UnmarshalJSON(data []byte) error
type PuzzleGenerateParams ¶ added in v0.5.0
type PuzzleGenerateParams struct {
// Optional seed string for deterministic puzzle generation. The same seed and
// difficulty always produce the same puzzle.
Seed param.Opt[string] `query:"seed,omitzero" json:"-"`
// Puzzle difficulty level. Controls word length, number of hints, and attempts
// allowed.
//
// Any of "easy", "medium", "hard".
Difficulty PuzzleGenerateParamsDifficulty `query:"difficulty,omitzero" json:"-"`
// When `"true"`, reduces hints and attempts for an extra challenge.
//
// Any of "true", "false".
HardMode PuzzleGenerateParamsHardMode `query:"hardMode,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (PuzzleGenerateParams) URLQuery ¶ added in v0.5.0
func (r PuzzleGenerateParams) URLQuery() (v url.Values, err error)
URLQuery serializes PuzzleGenerateParams's query parameters as `url.Values`.
type PuzzleGenerateParamsDifficulty ¶ added in v0.5.0
type PuzzleGenerateParamsDifficulty string
Puzzle difficulty level. Controls word length, number of hints, and attempts allowed.
const ( PuzzleGenerateParamsDifficultyEasy PuzzleGenerateParamsDifficulty = "easy" PuzzleGenerateParamsDifficultyMedium PuzzleGenerateParamsDifficulty = "medium" PuzzleGenerateParamsDifficultyHard PuzzleGenerateParamsDifficulty = "hard" )
type PuzzleGenerateParamsHardMode ¶ added in v0.5.0
type PuzzleGenerateParamsHardMode string
When `"true"`, reduces hints and attempts for an extra challenge.
const ( PuzzleGenerateParamsHardModeTrue PuzzleGenerateParamsHardMode = "true" PuzzleGenerateParamsHardModeFalse PuzzleGenerateParamsHardMode = "false" )
type PuzzleHint ¶ added in v0.5.0
type PuzzleHint struct {
// The letter revealed by this hint.
Letter string `json:"letter,required"`
// The order in which this hint should be revealed (0-based).
Order int64 `json:"order,required"`
// The zero-based index of the letter in the target word.
Position int64 `json:"position,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Letter respjson.Field
Order respjson.Field
Position respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
A positional hint revealing one letter of the target word.
func (PuzzleHint) RawJSON ¶ added in v0.5.0
func (r PuzzleHint) RawJSON() string
Returns the unmodified JSON received from the API
func (*PuzzleHint) UnmarshalJSON ¶ added in v0.5.0
func (r *PuzzleHint) UnmarshalJSON(data []byte) error
type PuzzleMetadata ¶ added in v0.5.0
type PuzzleMetadata struct {
// Number of alternative valid solutions.
AltCount int64 `json:"altCount,required"`
// Whether the target word contains repeated letters.
HasRepeats bool `json:"hasRepeats,required"`
// Number of unique letters in the letter pool.
PoolSize int64 `json:"poolSize,required"`
// Number of vowels in the target word.
VowelCount int64 `json:"vowelCount,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
AltCount respjson.Field
HasRepeats respjson.Field
PoolSize respjson.Field
VowelCount respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Metadata about the generated puzzle for analytics and difficulty calibration.
func (PuzzleMetadata) RawJSON ¶ added in v0.5.0
func (r PuzzleMetadata) RawJSON() string
Returns the unmodified JSON received from the API
func (*PuzzleMetadata) UnmarshalJSON ¶ added in v0.5.0
func (r *PuzzleMetadata) UnmarshalJSON(data []byte) error
type PuzzleResponse ¶ added in v0.5.0
type PuzzleResponse struct {
// Alternative valid anagram solutions.
Alts []string `json:"alts,required"`
// Definitions for the target word and alternatives. Keys are words, values are
// definition strings or null if no definition is available.
Definitions map[string]string `json:"definitions,required"`
// The difficulty level of the puzzle.
//
// Any of "easy", "medium", "hard".
Difficulty PuzzleResponseDifficulty `json:"difficulty,required"`
// The feedback mode for guesses (e.g., "exact", "positional").
FeedbackMode string `json:"feedbackMode,required"`
// Pre-generated hints revealing individual letters.
Hints []PuzzleHint `json:"hints,required"`
// Maximum number of attempts allowed.
MaxAttempts int64 `json:"maxAttempts,required"`
// Maximum number of hints available.
MaxHints int64 `json:"maxHints,required"`
// Metadata about the generated puzzle for analytics and difficulty calibration.
Metadata PuzzleMetadata `json:"metadata,required"`
// The sorted pool of available letters.
Pool string `json:"pool,required"`
// The scrambled version of the target word.
Scramble string `json:"scramble,required"`
// The seed used for puzzle generation. Can be passed back to reproduce this exact
// puzzle.
Seed string `json:"seed,required"`
// The target word the player must unscramble.
Target string `json:"target,required"`
// The length of the target word.
WordLength int64 `json:"wordLength,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Alts respjson.Field
Definitions respjson.Field
Difficulty respjson.Field
FeedbackMode respjson.Field
Hints respjson.Field
MaxAttempts respjson.Field
MaxHints respjson.Field
Metadata respjson.Field
Pool respjson.Field
Scramble respjson.Field
Seed respjson.Field
Target respjson.Field
WordLength respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
A generated anagram puzzle with target word, scrambled letters, hints, and metadata.
func (PuzzleResponse) RawJSON ¶ added in v0.5.0
func (r PuzzleResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*PuzzleResponse) UnmarshalJSON ¶ added in v0.5.0
func (r *PuzzleResponse) UnmarshalJSON(data []byte) error
type PuzzleResponseDifficulty ¶ added in v0.5.0
type PuzzleResponseDifficulty string
The difficulty level of the puzzle.
const ( PuzzleResponseDifficultyEasy PuzzleResponseDifficulty = "easy" PuzzleResponseDifficultyMedium PuzzleResponseDifficulty = "medium" PuzzleResponseDifficultyHard PuzzleResponseDifficulty = "hard" )
type PuzzleService ¶ added in v0.5.0
type PuzzleService struct {
Options []option.RequestOption
}
PuzzleService contains methods and other services that help with interacting with the anagrama API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewPuzzleService method instead.
func NewPuzzleService ¶ added in v0.5.0
func NewPuzzleService(opts ...option.RequestOption) (r PuzzleService)
NewPuzzleService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*PuzzleService) Generate ¶ added in v0.5.0
func (r *PuzzleService) Generate(ctx context.Context, query PuzzleGenerateParams, opts ...option.RequestOption) (res *PuzzleResponse, err error)
Generates a new anagram puzzle with a target word, scrambled letters, hints, alternative solutions, and metadata. Difficulty controls word length and hint availability. An optional seed allows reproducible puzzle generation. Requires a valid API key as a Bearer token.
type WordDailyParams ¶ added in v0.5.0
type WordDailyParams struct {
// IANA timezone identifier used to resolve the current calendar date (e.g.,
// "America/New_York", "Europe/London"). Defaults to "UTC".
Tz param.Opt[string] `query:"tz,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (WordDailyParams) URLQuery ¶ added in v0.5.0
func (r WordDailyParams) URLQuery() (v url.Values, err error)
URLQuery serializes WordDailyParams's query parameters as `url.Values`.
type WordDailyResponse ¶ added in v0.6.0
type WordDailyResponse struct {
// The date (YYYY-MM-DD) for which this word was selected, resolved in the
// requested timezone.
Date time.Time `json:"date,required" format:"date"`
// The IANA timezone used to resolve the date.
Timezone string `json:"timezone,required"`
// The daily word. Always 5-6 characters long.
Word string `json:"word,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Date respjson.Field
Timezone respjson.Field
Word respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (WordDailyResponse) RawJSON ¶ added in v0.6.0
func (r WordDailyResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*WordDailyResponse) UnmarshalJSON ¶ added in v0.6.0
func (r *WordDailyResponse) UnmarshalJSON(data []byte) error
type WordGetDailyParams ¶ added in v0.5.0
type WordGetDailyParams struct {
// IANA timezone identifier used to resolve the current calendar date (e.g.,
// "America/New_York", "Europe/London"). Defaults to "UTC".
Tz param.Opt[string] `query:"tz,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (WordGetDailyParams) URLQuery ¶ added in v0.5.0
func (r WordGetDailyParams) URLQuery() (v url.Values, err error)
URLQuery serializes WordGetDailyParams's query parameters as `url.Values`.
type WordGetDailyResponse ¶
type WordGetDailyResponse struct {
// The date (YYYY-MM-DD) for which this word was selected, resolved in the
// requested timezone.
Date time.Time `json:"date,required" format:"date"`
// The IANA timezone used to resolve the date.
Timezone string `json:"timezone,required"`
// The daily word. Always 5-6 characters long.
Word string `json:"word,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Date respjson.Field
Timezone respjson.Field
Word respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (WordGetDailyResponse) RawJSON ¶
func (r WordGetDailyResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*WordGetDailyResponse) UnmarshalJSON ¶
func (r *WordGetDailyResponse) UnmarshalJSON(data []byte) error
type WordGetRandomParams ¶
type WordGetRandomParams struct {
// Number of random words to return. Clamped to the range [1, 10]. Defaults to 1.
Count param.Opt[int64] `query:"count,omitzero" json:"-"`
// Maximum word length (inclusive). Clamped to the range [3, 15]. Defaults to 15.
// If minLength > maxLength, they are swapped automatically.
MaxLength param.Opt[int64] `query:"maxLength,omitzero" json:"-"`
// Minimum word length (inclusive). Clamped to the range [3, 15]. Defaults to 3.
MinLength param.Opt[int64] `query:"minLength,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (WordGetRandomParams) URLQuery ¶
func (r WordGetRandomParams) URLQuery() (v url.Values, err error)
URLQuery serializes WordGetRandomParams's query parameters as `url.Values`.
type WordGetRandomResponse ¶
type WordGetRandomResponse struct {
// The number of words returned. May be 0 if no words match the length criteria.
Count int64 `json:"count,required"`
// Array of random words matching the length criteria.
Words []string `json:"words,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Count respjson.Field
Words respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (WordGetRandomResponse) RawJSON ¶
func (r WordGetRandomResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*WordGetRandomResponse) UnmarshalJSON ¶
func (r *WordGetRandomResponse) UnmarshalJSON(data []byte) error
type WordRandomParams ¶ added in v0.5.0
type WordRandomParams struct {
// Number of random words to return. Clamped to the range [1, 10]. Defaults to 1.
Count param.Opt[int64] `query:"count,omitzero" json:"-"`
// Maximum word length (inclusive). Clamped to the range [3, 15]. Defaults to 15.
// If minLength > maxLength, they are swapped automatically.
MaxLength param.Opt[int64] `query:"maxLength,omitzero" json:"-"`
// Minimum word length (inclusive). Clamped to the range [3, 15]. Defaults to 3.
MinLength param.Opt[int64] `query:"minLength,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (WordRandomParams) URLQuery ¶ added in v0.5.0
func (r WordRandomParams) URLQuery() (v url.Values, err error)
URLQuery serializes WordRandomParams's query parameters as `url.Values`.
type WordRandomResponse ¶ added in v0.6.0
type WordRandomResponse struct {
// The number of words returned. May be 0 if no words match the length criteria.
Count int64 `json:"count,required"`
// Array of random words matching the length criteria.
Words []string `json:"words,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Count respjson.Field
Words respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (WordRandomResponse) RawJSON ¶ added in v0.6.0
func (r WordRandomResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*WordRandomResponse) UnmarshalJSON ¶ added in v0.6.0
func (r *WordRandomResponse) UnmarshalJSON(data []byte) error
type WordService ¶
type WordService struct {
Options []option.RequestOption
}
WordService contains methods and other services that help with interacting with the anagrama API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewWordService method instead.
func NewWordService ¶
func NewWordService(opts ...option.RequestOption) (r WordService)
NewWordService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*WordService) Daily ¶ added in v0.5.0
func (r *WordService) Daily(ctx context.Context, query WordDailyParams, opts ...option.RequestOption) (res *WordDailyResponse, err error)
Returns a deterministic daily word that is the same for all users on a given calendar date. The word is selected from puzzle-quality words of 5-6 characters in length using a seeded random algorithm. An optional timezone parameter allows the date to be resolved in the caller's local timezone instead of UTC. Requires a valid API key as a Bearer token. Subject to daily rate limiting (1,000 requests/day).
func (*WordService) GetDaily ¶
func (r *WordService) GetDaily(ctx context.Context, query WordGetDailyParams, opts ...option.RequestOption) (res *WordGetDailyResponse, err error)
Returns a deterministic daily word that is the same for all users on a given calendar date. The word is selected from puzzle-quality words of 5-6 characters in length using a seeded random algorithm. An optional timezone parameter allows the date to be resolved in the caller's local timezone instead of UTC. Requires a valid API key as a Bearer token. Subject to daily rate limiting (1,000 requests/day).
func (*WordService) GetRandom ¶
func (r *WordService) GetRandom(ctx context.Context, query WordGetRandomParams, opts ...option.RequestOption) (res *WordGetRandomResponse, err error)
Returns one or more random words from the Anagrama word pool. Words can be filtered by length. Requires a valid API key as a Bearer token. Subject to daily rate limiting (1,000 requests/day).
func (*WordService) Random ¶ added in v0.5.0
func (r *WordService) Random(ctx context.Context, query WordRandomParams, opts ...option.RequestOption) (res *WordRandomResponse, err error)
Returns one or more random words from the Anagrama word pool. Words can be filtered by length. Requires a valid API key as a Bearer token. Subject to daily rate limiting (1,000 requests/day).
func (*WordService) Validate ¶ added in v0.5.0
func (r *WordService) Validate(ctx context.Context, query WordValidateParams, opts ...option.RequestOption) (res *WordValidateResponse, err error)
Checks whether a given word exists in the Anagrama dictionary for the specified language. Returns validation status and optional part-of-speech information. Requires a valid API key as a Bearer token.
type WordValidateParams ¶ added in v0.5.0
type WordValidateParams struct {
// The word to validate. Case-insensitive. Must be 1-100 characters.
Word string `query:"word,required" json:"-"`
// ISO 639-1 language code to validate against. Defaults to "en" (English).
Lang param.Opt[string] `query:"lang,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (WordValidateParams) URLQuery ¶ added in v0.5.0
func (r WordValidateParams) URLQuery() (v url.Values, err error)
URLQuery serializes WordValidateParams's query parameters as `url.Values`.
type WordValidateResponse ¶ added in v0.5.0
type WordValidateResponse struct {
// The language code used for validation.
Lang string `json:"lang,required"`
// Whether the word exists in the dictionary for the specified language.
Valid bool `json:"valid,required"`
// The word that was validated (lowercased).
Word string `json:"word,required"`
// The primary part of speech for the word, if found (e.g., "noun", "verb",
// "adjective").
Pos string `json:"pos"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Lang respjson.Field
Valid respjson.Field
Word respjson.Field
Pos respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (WordValidateResponse) RawJSON ¶ added in v0.5.0
func (r WordValidateResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*WordValidateResponse) UnmarshalJSON ¶ added in v0.5.0
func (r *WordValidateResponse) UnmarshalJSON(data []byte) error
type WordsetGetParams ¶
type WordsetGetParams struct {
// Filter words by category (case-insensitive match). Only words with a matching
// `category` field are returned.
Category param.Opt[string] `query:"category,omitzero" json:"-"`
// Maximum number of words to return. Applied after filtering and optional
// shuffling.
Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
// Filter words to only include those with at most this many characters.
MaxLength param.Opt[int64] `query:"maxLength,omitzero" json:"-"`
// Filter words to only include those with at least this many characters.
MinLength param.Opt[int64] `query:"minLength,omitzero" json:"-"`
// When set to `"true"`, shuffles the word list into a random order before applying
// the limit.
//
// Any of "true", "false".
Random WordsetGetParamsRandom `query:"random,omitzero" json:"-"`
// When set to `"true"`, scrambles the letters of each word in the response
// (Fisher-Yates shuffle on characters). Useful for building anagram puzzles.
//
// Any of "true", "false".
Scramble WordsetGetParamsScramble `query:"scramble,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (WordsetGetParams) URLQuery ¶
func (r WordsetGetParams) URLQuery() (v url.Values, err error)
URLQuery serializes WordsetGetParams's query parameters as `url.Values`.
type WordsetGetParamsRandom ¶
type WordsetGetParamsRandom string
When set to `"true"`, shuffles the word list into a random order before applying the limit.
const ( WordsetGetParamsRandomTrue WordsetGetParamsRandom = "true" WordsetGetParamsRandomFalse WordsetGetParamsRandom = "false" )
type WordsetGetParamsScramble ¶
type WordsetGetParamsScramble string
When set to `"true"`, scrambles the letters of each word in the response (Fisher-Yates shuffle on characters). Useful for building anagram puzzles.
const ( WordsetGetParamsScrambleTrue WordsetGetParamsScramble = "true" WordsetGetParamsScrambleFalse WordsetGetParamsScramble = "false" )
type WordsetResponse ¶
type WordsetResponse struct {
// ISO 8601 timestamp of when the wordset was created.
CreatedAt time.Time `json:"createdAt,required" format:"date-time"`
// A description of the wordset.
Description string `json:"description,required"`
// Whether the wordset is publicly accessible.
IsPublic bool `json:"isPublic,required"`
// The name of the wordset.
Name string `json:"name,required"`
// The total number of words in the wordset (before filtering).
TotalWordCount int64 `json:"totalWordCount,required"`
// The number of words in the `words` array (after filtering).
WordCount int64 `json:"wordCount,required"`
// The list of words in the wordset, after applying any query filters (minLength,
// maxLength, category, random, limit, scramble).
Words []WordsetWord `json:"words,required"`
// The unique wordset identifier.
WordsetID string `json:"wordsetId,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
CreatedAt respjson.Field
Description respjson.Field
IsPublic respjson.Field
Name respjson.Field
TotalWordCount respjson.Field
WordCount respjson.Field
Words respjson.Field
WordsetID respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
A wordset with its words, optionally filtered and/or scrambled.
func (WordsetResponse) RawJSON ¶
func (r WordsetResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*WordsetResponse) UnmarshalJSON ¶
func (r *WordsetResponse) UnmarshalJSON(data []byte) error
type WordsetService ¶
type WordsetService struct {
Options []option.RequestOption
}
WordsetService contains methods and other services that help with interacting with the anagrama API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewWordsetService method instead.
func NewWordsetService ¶
func NewWordsetService(opts ...option.RequestOption) (r WordsetService)
NewWordsetService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*WordsetService) Get ¶
func (r *WordsetService) Get(ctx context.Context, wordsetID string, query WordsetGetParams, opts ...option.RequestOption) (res *WordsetResponse, err error)
Retrieves a user-created wordset by its ID. Public wordsets (`isPublic: true`) can be accessed without authentication. Private wordsets require the creator's API key passed as a Bearer token.
Words in the response can be filtered, shuffled, limited, and optionally scrambled using query parameters. Each request increments the wordset's hit counter for analytics.
type WordsetWord ¶
type WordsetWord struct {
// The word string. If `scramble=true` was requested, the letters are shuffled.
Word string `json:"word,required"`
// An optional category label for the word (e.g., "animals", "food").
Category string `json:"category"`
// An optional hint or clue for the word.
Hint string `json:"hint"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Word respjson.Field
Category respjson.Field
Hint respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
A word entry in a wordset.
func (WordsetWord) RawJSON ¶
func (r WordsetWord) RawJSON() string
Returns the unmodified JSON received from the API
func (*WordsetWord) UnmarshalJSON ¶
func (r *WordsetWord) UnmarshalJSON(data []byte) error
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
|
Package json implements encoding and decoding of JSON as defined in RFC 7159. |
|
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
|
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package. |
|
packages
|
|
|
shared
|
|