Documentation
¶
Overview ¶
Package kaggle is a minimal, unofficial Go port of the official Python kagglesdk Connect client. It speaks the same JSON-RPC protocol (POST {endpoint}/v1/{service}/{method}) against api.kaggle.com using a KGAT bearer token, and exposes the kernels and datasets subsets needed to upload data, push GPU kernels, poll status, and download outputs.
Not affiliated with or endorsed by Kaggle.
Index ¶
- Constants
- type APIError
- type Client
- func (c *Client) Call(ctx context.Context, service, method string, req, out any) error
- func (c *Client) CallRaw(ctx context.Context, service, method string, req any) (*http.Response, error)
- func (c *Client) HTTPClient() *http.Client
- func (c *Client) Token() string
- func (c *Client) WhoAmI(ctx context.Context) (string, error)
- type IntrospectResult
- type Option
Constants ¶
const (
// EndpointProd is the production Kaggle API endpoint (kagglesdk PROD).
EndpointProd = "https://api.kaggle.com"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
APIError is a Kaggle API error. Code is the application-level error code from the JSON body (0 if absent); Status is the HTTP status code.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a minimal port of the Python kagglesdk Connect client. It POSTs JSON RPCs to {endpoint}/v1/{service}/{method} with Bearer (KGAT) auth.
The service subpackages (kernels, datasets) call through Call/CallRaw, so a single *Client is shared across them.
func New ¶
New builds a Client. The token resolves from WithToken or, if empty, the KAGGLE_API_TOKEN environment variable (mirroring kagglesdk).
func (*Client) Call ¶
Call POSTs req as JSON to service/method and decodes the JSON response into out. out may be nil for RPCs with no return body; req may be nil (sends {}). It mirrors kagglesdk error handling: a JSON body with code>=400 is an error.
func (*Client) CallRaw ¶
func (c *Client) CallRaw(ctx context.Context, service, method string, req any) (*http.Response, error)
CallRaw POSTs req as JSON and returns the raw HTTP response. The caller owns resp.Body. Use this for streaming/download RPCs; prefer Call for JSON RPCs.
func (*Client) HTTPClient ¶
HTTPClient returns the underlying HTTP client (for upload/download helpers).
type IntrospectResult ¶
type IntrospectResult struct {
Active bool `json:"active,omitempty"`
Username string `json:"username,omitempty"`
UserID int64 `json:"userId,omitempty"`
}
IntrospectResult is the subset of IntrospectToken we use: whether the token is active and the username that authorized it.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithEndpoint ¶
WithEndpoint overrides the API endpoint (default EndpointProd).
func WithHTTPClient ¶
WithHTTPClient sets the underlying HTTP client (e.g. to set a timeout).
func WithUserAgent ¶
WithUserAgent overrides the User-Agent header.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
livecheck
command
Command livecheck exercises the kaggle-go client against the real Kaggle API.
|
Command livecheck exercises the kaggle-go client against the real Kaggle API. |
|
pushcheck
command
Command pushcheck validates kernels.Push (SaveKernel) end-to-end against the real Kaggle API: push a small kernel, poll to completion, download output.
|
Command pushcheck validates kernels.Push (SaveKernel) end-to-end against the real Kaggle API: push a small kernel, poll to completion, download output. |
|
uploadcheck
command
Command uploadcheck validates the datasets upload flow against the real Kaggle API by creating a throwaway dataset from a tiny file.
|
Command uploadcheck validates the datasets upload flow against the real Kaggle API by creating a throwaway dataset from a tiny file. |
|
Package datasets ports the subset of kagglesdk's datasets.DatasetApiService needed to create datasets and dataset versions (including the signed-URL file upload flow) and to poll dataset processing status.
|
Package datasets ports the subset of kagglesdk's datasets.DatasetApiService needed to create datasets and dataset versions (including the signed-URL file upload flow) and to poll dataset processing status. |
|
Package kernels ports the kagglesdk "kernels.KernelsApiService" subset: pushing (saving) kernels, polling session status, and listing/downloading kernel session output.
|
Package kernels ports the kagglesdk "kernels.KernelsApiService" subset: pushing (saving) kernels, polling session status, and listing/downloading kernel session output. |