{"id":15756997,"url":"https://github.com/treethought/one-api-sdk","last_synced_at":"2025-12-15T03:29:30.483Z","repository":{"id":59044678,"uuid":"528954917","full_name":"treethought/one-api-sdk","owner":"treethought","description":"Golang SDK for The One API","archived":false,"fork":false,"pushed_at":"2022-08-25T19:51:31.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T08:30:36.434Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/treethought.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-25T17:36:08.000Z","updated_at":"2022-09-21T22:08:37.000Z","dependencies_parsed_at":"2022-09-11T04:42:00.198Z","dependency_job_id":null,"html_url":"https://github.com/treethought/one-api-sdk","commit_stats":null,"previous_names":["treethought/cam-sweeney-sdk"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/treethought/one-api-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treethought%2Fone-api-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treethought%2Fone-api-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treethought%2Fone-api-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treethought%2Fone-api-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/treethought","download_url":"https://codeload.github.com/treethought/one-api-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treethought%2Fone-api-sdk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269948859,"owners_count":24501821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T09:03:39.974Z","updated_at":"2025-12-15T03:29:25.446Z","avatar_url":"https://github.com/treethought.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The One API SDK\n\nGolang SDK for [The One API](https://the-one-api.dev/documentation#3). GoDoc can be found [here](https://pkg.go.dev/github.com/treethought/cam-sweeney-sdk)\n\n## Getting started\n\nAdd the SDK as dependency\n\n```\ngo install github.com/treethought/cam-sweeney-sdk@latest\n```\n\nObtain an APIKey from https://the-one-api.dev/sign-up and set the ONE_API_KEY environment variable\n\n```\nexport ONE_API_KEY=\u003cMY_API_KEY\u003e\n```\n\n### Examples\n\nIf you'd like to quickly try some exmaples, take a look at the [examples](./examples) directory.\n\n```\n# basic, does not require API key\ngo run examples/basic/main.go\n\n# exmaple of filtering resources, requires API key\ngo run examples/filtering/main.go\n\n```\n\n## Usage\n\nCreate a client\n\n```go\nimport (\n    \"fmt\"\n    \"os\"\n    \"github.com/treethought/cam-sweeney-sdk/sdk\"\n    )\n\nfunc main() {\n    apiKey := os.GetEnv(\"ONE_API_KEY\")\n    client := NewOneAPIClient(apiKey)\n}\n\n```\n\nThe client struct provides methods to interface with the Books, Movies, Characters, Quotes, and Chapters resources.\n\n### Books\n\nThe `Books()` method provides an interface to list and get books.\n\n```go\nimport (\n    \"fmt\"\n    \"os\"\n    \"github.com/treethought/cam-sweeney-sdk/sdk\"\n    )\n\nfunc main() {\n    apiKey := os.GetEnv(\"ONE_API_KEY\")\n    client := NewOneAPIClient(apiKey)\n\n    // List all available books\n    books, err := client.Books().List()\n    if err != nil {\n        log.Fatal(err)\n    }\n    fmt.Println(books)\n\n    // get a specific book\n    book, err := client.Books().Get(\"5cf5805fb53e011a64671582\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    // get all chapters of a book\n    book, err := client.Books().GetChapters(\"5cf5805fb53e011a64671582\")\n    if err != nil {\n        log.Fatal(err)\n    }\n\n}\n\n```\n\n### Movies\n\nThe `Movies()` method provides an interface to list and get movies.\n\n```go\n// List all available movies\nmovies, err := client.Movies().List()\nif err != nil {\n    log.Fatal(err)\n}\nfmt.Println(movies)\n\n// get a specific movie\nbook, err := client.Movies().Get(\"5cd95395de30eff6ebccde5c\")\nif err != nil {\n    log.Fatal(err)\n}\n// get all quotes of a movie\nbook, err := client.Movies().GetQuotes(\"5cd95395de30eff6ebccde5c\")\nif err != nil {\n    log.Fatal(err)\n}\n\n```\n\n### Characters\n\nThe `Characters()` method provides an interface to list and get characters.\n\n```go\n// List all available characters\nchapters, err := client.Characters().List()\nif err != nil {\n    log.Fatal(err)\n}\nfmt.Println(chapters)\n\n// get a specific chapter\nchapter, err := client.Characters().Get(\"5cd99d4bde30eff6ebccfd0d\")\nif err != nil {\n    log.Fatal(err)\n}\n\n// get all quotes of a given character\nchapter, err := client.Characters().Get(\"5cd99d4bde30eff6ebccfd0d\")\nif err != nil {\n    log.Fatal(err)\n}\n\n// get all quotes spoken by a character\nchapter, err := client.Characters().GetQuotes(\"5cd99d4bde30eff6ebccfd0d\")\nif err != nil {\n    log.Fatal(err)\n}\n```\n\n### Chapters\n\nThe `Chapters()` method provides an interface to list and get chapters.\n\n```go\n// List all available chapters\nchapters, err := client.Chapters().List()\nif err != nil {\n    log.Fatal(err)\n}\nfmt.Println(chapters)\n\n// get a specific chapter\nchapter, err := client.Chapters().Get(\"6091b6d6d58360f988133b8b\")\nif err != nil {\n    log.Fatal(err)\n}\n\n```\n\n### Quotes\n\nThe `Quotes()` method provides an interface to list and get quotes.\n\n```go\n// List all available quotes\nquotes, err := client.Quotes().List()\nif err != nil {\n    log.Fatal(err)\n}\nfmt.Println(quotes)\n\n// get a specific quote\nquote, err := client.Quotes().Get(\"5cd96e05de30eff6ebcce7e9\")\nif err != nil {\n    log.Fatal(err)\n}\n\n```\n\n### Applying Request Options\n\nThe client, as well as any API methods, may be configured with RequestOptions.\nThese options are used to apply query params for sorting, pagination, and\nfiltering. They also support setting the baseURL and authroization header.\n\nThese options may be applied to the client via `sdk.NewWithConfig`, or simply\npassed to each method as needed.\n\nFor example, to set a pagination limit of 3 across all API calls:\n\n```go\n\nopts := []RequestOption{WithLimit(3)}\n\nclient := sdk.NewWithConfig(sdk.ClientConfig{PersistentOptions: opts})\n```\n\nOr to sort books by name\n\n```go\nclient := sdk.New()\n\nclient.Books().List(WithSort(\"name\", \"asc\"))\n\n```\n\n## Testing\n\nTo test the SDK:\n\nFirst clone the repo\n\n```\n\ngit clone https://github.com/treethought/cam-sweeney-sdk.git\ncd cam-sweeney-sdk\n\n```\n\nRun the tests\n\n```\n\ngo test -v ./sdk/...\n```\n\n## TODO\n\n- [] automatically handle pagination\n- [] provide configurable logging\n- [] automatically detect API key\n- [] provide methods on API schema structs for chained API calls\n- [] Unit tests for resource specific clients\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreethought%2Fone-api-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftreethought%2Fone-api-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreethought%2Fone-api-sdk/lists"}