{"id":31286947,"url":"https://github.com/piszmog/hnclient","last_synced_at":"2025-09-24T10:58:44.817Z","repository":{"id":315272031,"uuid":"1058831464","full_name":"Piszmog/hnclient","owner":"Piszmog","description":"Go client for Hacker News API","archived":false,"fork":false,"pushed_at":"2025-09-17T16:58:33.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-17T18:07:40.610Z","etag":null,"topics":["go","hackernews-api"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Piszmog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-17T15:55:05.000Z","updated_at":"2025-09-17T16:52:57.000Z","dependencies_parsed_at":"2025-09-17T18:07:45.007Z","dependency_job_id":"8de6d6fc-9c20-43da-8073-e9ec38fb89f8","html_url":"https://github.com/Piszmog/hnclient","commit_stats":null,"previous_names":["piszmog/hnclient"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Piszmog/hnclient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piszmog%2Fhnclient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piszmog%2Fhnclient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piszmog%2Fhnclient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piszmog%2Fhnclient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Piszmog","download_url":"https://codeload.github.com/Piszmog/hnclient/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piszmog%2Fhnclient/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276737509,"owners_count":25695700,"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-09-24T02:00:09.776Z","response_time":97,"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":["go","hackernews-api"],"created_at":"2025-09-24T10:58:42.774Z","updated_at":"2025-09-24T10:58:44.812Z","avatar_url":"https://github.com/Piszmog.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hacker News API Client for Go\n\n[![CI](https://github.com/Piszmog/hnclient/workflows/CI/badge.svg)](https://github.com/Piszmog/hnclient/actions)\n[![Go Report Card](https://goreportcard.com/badge/github.com/Piszmog/hnclient)](https://goreportcard.com/report/github.com/Piszmog/hnclient)\n[![GoDoc](https://godoc.org/github.com/Piszmog/hnclient?status.svg)](https://godoc.org/github.com/Piszmog/hnclient)\n\nA comprehensive, type-safe Go client for the [Hacker News API](https://github.com/HackerNews/API).\n\n## Installation\n\n```bash\ngo get github.com/Piszmog/hnclient\n```\n\n## Quick Start\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"net/http\"\n    \"time\"\n\n    \"github.com/Piszmog/hnclient\"\n)\n\nfunc main() {\n    // Create client with timeout\n    httpClient := \u0026http.Client{Timeout: 10 * time.Second}\n    client := hnclient.New(httpClient, hnclient.URLV0)\n\n    // Get top stories\n    ctx := context.Background()\n    stories, err := client.GetTopStories(ctx)\n    if err != nil {\n        panic(err)\n    }\n\n    // Get first story details\n    if len(stories) \u003e 0 {\n        item, err := client.GetItem(ctx, stories[0])\n        if err != nil {\n            panic(err)\n        }\n        fmt.Printf(\"Top story ID: %d\\n\", item.GetID())\n    }\n}\n```\n\n## Advanced Usage\n\n### Custom HTTP Client\n\nYou can provide your own HTTP client with custom settings:\n\n```go\nhttpClient := \u0026http.Client{\n    Timeout: 30 * time.Second,\n    Transport: \u0026http.Transport{\n        MaxIdleConns:        100,\n        MaxIdleConnsPerHost: 10,\n        IdleConnTimeout:     90 * time.Second,\n    },\n}\nclient := hnclient.New(httpClient, hnclient.URLV0)\n```\n\n## Item Types\n\nThe client supports all Hacker News item types:\n\n- **Story** - News stories and links that appear on the front page\n- **Comment** - User comments on stories or other comments  \n- **Job** - Job postings from the Jobs section\n- **Poll** - Poll questions with multiple choice options\n- **PollOption** - Individual choices within a poll\n\nAll items implement the `Item` interface and can be type-asserted to their specific types for accessing additional fields.\n\n### Type Assertions\n\n```go\nitem, err := client.GetItem(ctx, itemID)\nif err != nil {\n    return err\n}\n\nswitch v := item.(type) {\ncase hnclient.Story:\n    fmt.Printf(\"Story: %s\\n\", v.Title)\ncase hnclient.Comment:\n    fmt.Printf(\"Comment by: %s\\n\", v.By)\ncase hnclient.Job:\n    fmt.Printf(\"Job: %s\\n\", v.Title)\ncase hnclient.Poll:\n    fmt.Printf(\"Poll: %s\\n\", v.Title)\ncase hnclient.PollOption:\n    fmt.Printf(\"Poll option: %s\\n\", v.Text)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiszmog%2Fhnclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiszmog%2Fhnclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiszmog%2Fhnclient/lists"}