Back to godoc.org
miniflux.app / client

Package client

v0.0.0 (fc75b0c)
Latest Go to latest
Published: today | License: Apache-2.0 | Module: miniflux.app

Overview

Package client implements a client library for the Miniflux REST API.

Examples

This code snippet fetch the list of users:

import (
	miniflux "miniflux.app/client"
)

client := miniflux.New("https://api.example.org", "admin", "secret")
users, err := client.Users()
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(users, err)

This one discover subscriptions on a website:

subscriptions, err := client.Discover("https://example.org/")
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(subscriptions)

Index

Package Files

Constants

const (
	EntryStatusUnread  = "unread"
	EntryStatusRead    = "read"
	EntryStatusRemoved = "removed"
)

Entry statuses.

Variables

var (
	ErrNotAuthorized = errors.New("miniflux: unauthorized (bad credentials)")
	ErrForbidden     = errors.New("miniflux: access forbidden")
	ErrServerError   = errors.New("miniflux: internal server error")
	ErrNotFound      = errors.New("miniflux: resource not found")
)

List of exposed errors.

type Categories

type Categories []*Category

Categories represents a list of categories.

type Category

type Category struct {
	ID     int64  `json:"id,omitempty"`
	Title  string `json:"title,omitempty"`
	UserID int64  `json:"user_id,omitempty"`
}

Category represents a feed category.

func (Category) String

func (c Category) String() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client holds API procedure calls.

func New

func New(endpoint string, credentials ...string) *Client

New returns a new Miniflux client.

func (*Client) Categories

func (c *Client) Categories() (Categories, error)

Categories gets the list of categories.

func (*Client) CreateCategory

func (c *Client) CreateCategory(title string) (*Category, error)

CreateCategory creates a new category.

func (*Client) CreateFeed

func (c *Client) CreateFeed(url string, categoryID int64) (int64, error)

CreateFeed creates a new feed.

func (*Client) CreateUser

func (c *Client) CreateUser(username, password string, isAdmin bool) (*User, error)

CreateUser creates a new user in the system.

func (*Client) DeleteCategory

func (c *Client) DeleteCategory(categoryID int64) error

DeleteCategory removes a category.

func (*Client) DeleteFeed

func (c *Client) DeleteFeed(feedID int64) error

DeleteFeed removes a feed.

func (*Client) DeleteUser

func (c *Client) DeleteUser(userID int64) error

DeleteUser removes a user from the system.

func (*Client) Discover

func (c *Client) Discover(url string) (Subscriptions, error)

Discover try to find subscriptions from a website.

func (*Client) Entries

func (c *Client) Entries(filter *Filter) (*EntryResultSet, error)

Entries fetch entries.

func (*Client) Entry

func (c *Client) Entry(entryID int64) (*Entry, error)

Entry gets a single entry.

func (*Client) Export

func (c *Client) Export() ([]byte, error)

Export creates OPML file.

func (*Client) Feed

func (c *Client) Feed(feedID int64) (*Feed, error)

Feed gets a feed.

func (*Client) FeedEntries

func (c *Client) FeedEntries(feedID int64, filter *Filter) (*EntryResultSet, error)

FeedEntries fetch feed entries.

func (*Client) FeedEntry

func (c *Client) FeedEntry(feedID, entryID int64) (*Entry, error)

FeedEntry gets a single feed entry.

func (*Client) FeedIcon

func (c *Client) FeedIcon(feedID int64) (*FeedIcon, error)

FeedIcon gets a feed icon.

func (*Client) Feeds

func (c *Client) Feeds() (Feeds, error)

Feeds gets all feeds.

func (*Client) Import

func (c *Client) Import(f io.ReadCloser) error

Import imports an OPML file.

func (*Client) Me

func (c *Client) Me() (*User, error)

Me returns the logged user information.

func (*Client) RefreshAllFeeds

func (c *Client) RefreshAllFeeds() error

RefreshAllFeeds refreshes all feeds.

func (*Client) RefreshFeed

func (c *Client) RefreshFeed(feedID int64) error

RefreshFeed refreshes a feed.

func (*Client) ToggleBookmark

func (c *Client) ToggleBookmark(entryID int64) error

ToggleBookmark toggles entry bookmark value.

func (*Client) UpdateCategory

func (c *Client) UpdateCategory(categoryID int64, title string) (*Category, error)

UpdateCategory updates a category.

func (*Client) UpdateEntries

func (c *Client) UpdateEntries(entryIDs []int64, status string) error

UpdateEntries updates the status of a list of entries.

func (*Client) UpdateFeed

func (c *Client) UpdateFeed(feedID int64, feedChanges *FeedModification) (*Feed, error)

UpdateFeed updates a feed.

func (*Client) UpdateUser

func (c *Client) UpdateUser(userID int64, userChanges *UserModification) (*User, error)

UpdateUser updates a user in the system.

func (*Client) UserByID

func (c *Client) UserByID(userID int64) (*User, error)

UserByID returns a single user.

func (*Client) UserByUsername

func (c *Client) UserByUsername(username string) (*User, error)

UserByUsername returns a single user.

func (*Client) Users

func (c *Client) Users() (Users, error)

Users returns all users.

type Enclosure

type Enclosure struct {
	ID       int64  `json:"id"`
	UserID   int64  `json:"user_id"`
	EntryID  int64  `json:"entry_id"`
	URL      string `json:"url"`
	MimeType string `json:"mime_type"`
	Size     int    `json:"size"`
}

Enclosure represents an attachment.

type Enclosures

type Enclosures []*Enclosure

Enclosures represents a list of attachments.

type Entries

type Entries []*Entry

Entries represents a list of entries.

type Entry

type Entry struct {
	ID         int64      `json:"id"`
	UserID     int64      `json:"user_id"`
	FeedID     int64      `json:"feed_id"`
	Status     string     `json:"status"`
	Hash       string     `json:"hash"`
	Title      string     `json:"title"`
	URL        string     `json:"url"`
	Date       time.Time  `json:"published_at"`
	Content    string     `json:"content"`
	Author     string     `json:"author"`
	ShareCode  string     `json:"share_code"`
	Starred    bool       `json:"starred"`
	Enclosures Enclosures `json:"enclosures,omitempty"`
	Feed       *Feed      `json:"feed,omitempty"`
}

Entry represents a subscription item in the system.

type EntryResultSet

type EntryResultSet struct {
	Total   int     `json:"total"`
	Entries Entries `json:"entries"`
}

EntryResultSet represents the response when fetching entries.

type Feed

type Feed struct {
	ID                 int64     `json:"id"`
	UserID             int64     `json:"user_id"`
	FeedURL            string    `json:"feed_url"`
	SiteURL            string    `json:"site_url"`
	Title              string    `json:"title"`
	CheckedAt          time.Time `json:"checked_at,omitempty"`
	EtagHeader         string    `json:"etag_header,omitempty"`
	LastModifiedHeader string    `json:"last_modified_header,omitempty"`
	ParsingErrorMsg    string    `json:"parsing_error_message,omitempty"`
	ParsingErrorCount  int       `json:"parsing_error_count,omitempty"`
	ScraperRules       string    `json:"scraper_rules"`
	RewriteRules       string    `json:"rewrite_rules"`
	Crawler            bool      `json:"crawler"`
	UserAgent          string    `json:"user_agent"`
	Username           string    `json:"username"`
	Password           string    `json:"password"`
	Category           *Category `json:"category,omitempty"`
}

Feed represents a Miniflux feed.

type FeedIcon

type FeedIcon struct {
	ID       int64  `json:"id"`
	MimeType string `json:"mime_type"`
	Data     string `json:"data"`
}

FeedIcon represents the feed icon.

type FeedModification

type FeedModification struct {
	FeedURL      *string `json:"feed_url"`
	SiteURL      *string `json:"site_url"`
	Title        *string `json:"title"`
	ScraperRules *string `json:"scraper_rules"`
	RewriteRules *string `json:"rewrite_rules"`
	Crawler      *bool   `json:"crawler"`
	UserAgent    *string `json:"user_agent"`
	Username     *string `json:"username"`
	Password     *string `json:"password"`
	CategoryID   *int64  `json:"category_id"`
}

FeedModification represents changes for a feed.

type Feeds

type Feeds []*Feed

Feeds represents a list of feeds.

type Filter

type Filter struct {
	Status        string
	Offset        int
	Limit         int
	Order         string
	Direction     string
	Starred       bool
	Before        int64
	After         int64
	BeforeEntryID int64
	AfterEntryID  int64
	Search        string
	CategoryID    int64
}

Filter is used to filter entries.

type Subscription

type Subscription struct {
	Title string `json:"title"`
	URL   string `json:"url"`
	Type  string `json:"type"`
}

Subscription represents a feed subscription.

func (Subscription) String

func (s Subscription) String() string

type Subscriptions

type Subscriptions []*Subscription

Subscriptions represents a list of subscriptions.

type User

type User struct {
	ID             int64             `json:"id"`
	Username       string            `json:"username"`
	Password       string            `json:"password,omitempty"`
	IsAdmin        bool              `json:"is_admin"`
	Theme          string            `json:"theme"`
	Language       string            `json:"language"`
	Timezone       string            `json:"timezone"`
	EntryDirection string            `json:"entry_sorting_direction"`
	EntriesPerPage int               `json:"entries_per_page"`
	LastLoginAt    *time.Time        `json:"last_login_at"`
	Extra          map[string]string `json:"extra"`
}

User represents a user in the system.

func (User) String

func (u User) String() string

type UserModification

type UserModification struct {
	Username       *string `json:"username"`
	Password       *string `json:"password"`
	IsAdmin        *bool   `json:"is_admin"`
	Theme          *string `json:"theme"`
	Language       *string `json:"language"`
	Timezone       *string `json:"timezone"`
	EntryDirection *string `json:"entry_sorting_direction"`
	EntriesPerPage *int    `json:"entries_per_page"`
}

UserModification is used to update a user.

type Users

type Users []User

Users represents a list of users.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier