sf

package module
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 10 Imported by: 0

README

SF API

The SF API is a Go package that provides a client for interacting with the SFACG (SF轻小说) website's API. It allows users to retrieve book information, search for novels, and retrieve user account information. The package provides methods for making API requests and handling the responses. Customization options, such as setting a device token or API key, are also available. Contributions to the package are welcome, and it is licensed under the MIT License.

Installation

To use the SF API package in your Go project, you can use the following command to install it:

go get github.com/catnovelapi/sf

Usage

To use the SF API package, you need to import it in your Go code:

import "github.com/catnovelapi/sf"
Creating a Client

To start using the SF API, you need to create a client instance. You can customize the client by providing options such as the device token, API key, and API base URL. Here's an example of creating a client with the default options:

client := sf.NewSfClient()
Making API Requests

Once you have a client instance, you can use it to make API requests. The SF API package provides methods for various API endpoints, such as getting book information, searching for novels, and retrieving user information. Here are some examples:

// Get book information
bookInfo := client.GetBookInfoApi(bookId)

// Search for novels
searchResults := client.SearchNovelsResultApi(keyword, page)

// Get user account information
accountInfo := client.GetAccountInApi()
Handling API Responses

The API methods return the response data in the form of gjson.Result, which is a type provided by the github.com/tidwall/gjson package. You can use the methods provided by gjson.Result to extract the desired data from the response. Here's an example:

// Get the book title from the book information response
title := bookInfo.Get("data.title").String()
Customizing Client Options

If you want to customize the client options, such as setting a device token or API key, you can use the provided options when creating the client. Here's an example:

client := sf.NewSfClient(
	sf.DeviceToken("your-device-token"),
	sf.ApiKey("your-api-key"),
)

Contributing

Contributions to the SF API package are welcome. If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sfacg

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

func NewSfClient

func NewSfClient(options ...SfacgOptions) *Sfacg

func (*Sfacg) AccountInMoneyApi added in v1.1.2

func (s *Sfacg) AccountInMoneyApi() gjson.Result

func (*Sfacg) AdpworksApi

func (s *Sfacg) AdpworksApi(bookId any) gjson.Result

func (*Sfacg) BookListApi

func (s *Sfacg) BookListApi(bookId any) gjson.Result

func (*Sfacg) ChapterListByBookIDApi

func (s *Sfacg) ChapterListByBookIDApi(bookId any) gjson.Result

func (*Sfacg) EssayLongNovelApi

func (s *Sfacg) EssayLongNovelApi(page int) gjson.Result

func (*Sfacg) EssayNovellaApi

func (s *Sfacg) EssayNovellaApi(page int) gjson.Result

func (*Sfacg) EssayShortNovelApi

func (s *Sfacg) EssayShortNovelApi(page int) gjson.Result

func (*Sfacg) GetAccountInApi

func (s *Sfacg) GetAccountInApi() gjson.Result

func (*Sfacg) GetActConfigApi added in v1.1.2

func (s *Sfacg) GetActConfigApi() gjson.Result

func (*Sfacg) GetBookInfoApi

func (s *Sfacg) GetBookInfoApi(bookId any) gjson.Result

func (*Sfacg) GetBookShelfApi

func (s *Sfacg) GetBookShelfApi() gjson.Result

func (*Sfacg) GetChapterInfoApi

func (s *Sfacg) GetChapterInfoApi(chapterId any) string

func (*Sfacg) GetPositionApi

func (s *Sfacg) GetPositionApi() gjson.Result

func (*Sfacg) GetSpecialPushApi

func (s *Sfacg) GetSpecialPushApi() gjson.Result

func (*Sfacg) GetStaticsResourceApi

func (s *Sfacg) GetStaticsResourceApi() gjson.Result

func (*Sfacg) GetUserWelfareStoreitemsLatestApi

func (s *Sfacg) GetUserWelfareStoreitemsLatestApi() gjson.Result

func (*Sfacg) GetWelfareCfgApi

func (s *Sfacg) GetWelfareCfgApi() gjson.Result

func (*Sfacg) LoginApi

func (s *Sfacg) LoginApi(username, password string) BuilderHttpClient.ResponseInterfaceBuilder

func (*Sfacg) NewChapterListByBookIDApi

func (s *Sfacg) NewChapterListByBookIDApi(bookId any) []gjson.Result

func (*Sfacg) NewCookie

func (s *Sfacg) NewCookie(cookie string)

func (*Sfacg) PostConversionsApi

func (s *Sfacg) PostConversionsApi() BuilderHttpClient.ResponseInterfaceBuilder

func (*Sfacg) PostSpecialPushApi

func (s *Sfacg) PostSpecialPushApi() BuilderHttpClient.ResponseInterfaceBuilder

func (*Sfacg) PreOrderApi added in v1.1.2

func (*Sfacg) SearchNovelsResultApi

func (s *Sfacg) SearchNovelsResultApi(keyword string, page int) gjson.Result

func (*Sfacg) SystemRecommendApi added in v1.1.2

func (s *Sfacg) SystemRecommendApi() gjson.Result

func (*Sfacg) UpdateBooksList

func (s *Sfacg) UpdateBooksList(page int) gjson.Result

func (*Sfacg) VersionInformation added in v1.1.2

func (s *Sfacg) VersionInformation() BuilderHttpClient.ResponseInterfaceBuilder

type SfacgOptions

type SfacgOptions interface {
	// contains filtered or unexported methods
}

func ApiBaseUrl

func ApiBaseUrl(apiBaseUrl string) SfacgOptions

func ApiKey

func ApiKey(apiKey string) SfacgOptions
func Cookie(cookie string) SfacgOptions

func DeviceToken

func DeviceToken(deviceToken string) SfacgOptions

Jump to

Keyboard shortcuts

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