{"id":30947520,"url":"https://github.com/eshaffer321/costco-go","last_synced_at":"2025-10-15T02:03:54.369Z","repository":{"id":313845301,"uuid":"1053121077","full_name":"eshaffer321/costco-go","owner":"eshaffer321","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-09T03:06:28.000Z","size":32,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"feature/initial-implementation","last_synced_at":"2025-09-09T05:57:02.227Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eshaffer321.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-09T02:49:52.000Z","updated_at":"2025-09-09T03:00:04.000Z","dependencies_parsed_at":"2025-09-09T05:57:04.552Z","dependency_job_id":"064d955a-ef34-4f33-9e15-17a500bdb90e","html_url":"https://github.com/eshaffer321/costco-go","commit_stats":null,"previous_names":["eshaffer321/costco-go"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/eshaffer321/costco-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eshaffer321%2Fcostco-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eshaffer321%2Fcostco-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eshaffer321%2Fcostco-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eshaffer321%2Fcostco-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eshaffer321","download_url":"https://codeload.github.com/eshaffer321/costco-go/tar.gz/refs/heads/feature/initial-implementation","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eshaffer321%2Fcostco-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275739404,"owners_count":25519601,"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-18T02:00:09.552Z","response_time":77,"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":"2025-09-11T01:46:51.356Z","updated_at":"2025-09-18T08:56:05.990Z","avatar_url":"https://github.com/eshaffer321.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Costco Go Client\n\nA Go client library and CLI for accessing Costco order history and receipt data via their GraphQL API.\n\n## Features\n\n- OAuth2 authentication with automatic token refresh\n- Get online order history\n- Get warehouse receipts\n- Get detailed receipt information with line items\n- Command-line interface\n- JSON output support\n- Test-driven development with comprehensive test coverage\n\n## Installation\n\n```bash\ngo get github.com/costco-go/pkg/costco\n```\n\n## Library Usage\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n    \"time\"\n    \n    \"github.com/costco-go/pkg/costco\"\n)\n\nfunc main() {\n    config := costco.Config{\n        Email:              \"your-email@example.com\",\n        Password:           \"your-password\",\n        WarehouseNumber:    \"847\", // Your local warehouse number\n        TokenRefreshBuffer: 5 * time.Minute,\n    }\n    \n    client := costco.NewClient(config)\n    ctx := context.Background()\n    \n    // Get online orders\n    orders, err := client.GetOnlineOrders(ctx, \"2025-01-01\", \"2025-01-31\", 1, 10)\n    if err != nil {\n        log.Fatal(err)\n    }\n    \n    for _, order := range orders.BCOrders {\n        fmt.Printf(\"Order %s: $%.2f\\n\", order.OrderNumber, order.OrderTotal)\n    }\n    \n    // Get receipts\n    receipts, err := client.GetReceipts(ctx, \"1/01/2025\", \"1/31/2025\", \"all\", \"all\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    \n    for _, receipt := range receipts.Receipts {\n        fmt.Printf(\"Receipt from %s: $%.2f\\n\", receipt.TransactionDateTime, receipt.Total)\n    }\n    \n    // Get detailed receipt\n    receipt, err := client.GetReceiptDetail(ctx, \"21134300501862509051323\", \"warehouse\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    \n    fmt.Printf(\"Receipt total: $%.2f with %d items\\n\", receipt.Total, receipt.TotalItemCount)\n}\n```\n\n## CLI Usage\n\n### Build the CLI\n\n```bash\ngo build -o costco-cli cmd/costco-cli/main.go\n```\n\n### Set credentials via environment variables\n\n```bash\nexport COSTCO_EMAIL=\"your-email@example.com\"\nexport COSTCO_PASSWORD=\"your-password\"\nexport COSTCO_WAREHOUSE=\"847\"  # Optional, defaults to 847\n```\n\n### Get online orders\n\n```bash\n# Get orders from last 3 months (default)\n./costco-cli -cmd orders\n\n# Get orders for specific date range\n./costco-cli -cmd orders -start 2025-01-01 -end 2025-01-31\n\n# Get orders with pagination\n./costco-cli -cmd orders -page 2 -size 20\n\n# Output as JSON\n./costco-cli -cmd orders -json\n```\n\n### Get receipts\n\n```bash\n# Get all receipts from last 3 months\n./costco-cli -cmd receipts\n\n# Get receipts for specific date range\n./costco-cli -cmd receipts -start 2025-01-01 -end 2025-01-31\n\n# Output as JSON\n./costco-cli -cmd receipts -json\n```\n\n### Get receipt details\n\n```bash\n# Get detailed receipt with all line items\n./costco-cli -cmd receipt-detail -barcode 21134300501862509051323\n\n# Output as JSON\n./costco-cli -cmd receipt-detail -barcode 21134300501862509051323 -json\n```\n\n### CLI Flags\n\n- `-email`: Costco account email (overrides COSTCO_EMAIL env var)\n- `-password`: Costco account password (overrides COSTCO_PASSWORD env var)\n- `-warehouse`: Warehouse number (overrides COSTCO_WAREHOUSE env var, default: 847)\n- `-cmd`: Command to run: `orders`, `receipts`, or `receipt-detail`\n- `-start`: Start date in YYYY-MM-DD format\n- `-end`: End date in YYYY-MM-DD format\n- `-barcode`: Receipt barcode (required for receipt-detail command)\n- `-page`: Page number for orders (default: 1)\n- `-size`: Page size for orders (default: 10)\n- `-json`: Output results as JSON\n\n## Running Tests\n\n```bash\ngo test ./pkg/costco -v\n```\n\n## API Details\n\nThe client uses Costco's OAuth2 authentication flow and GraphQL API:\n\n- **Auth endpoint**: `https://signin.costco.com/.../oauth2/v2.0/token`\n- **GraphQL endpoint**: `https://ecom-api.costco.com/ebusiness/order/v1/orders/graphql`\n- **Auth header**: `costco-x-authorization: Bearer {id_token}`\n\nThe client handles:\n- Initial authentication with email/password\n- Automatic token refresh before expiry\n- Thread-safe token management\n- GraphQL query construction and response parsing\n\n## Data Structures\n\n### Online Orders\n- Order header information (date, total, status)\n- Line items with shipping details\n- Shipment tracking information\n\n### Receipts\n- Transaction details (date, warehouse, total)\n- Complete line item details with prices\n- Tax breakdown\n- Payment information\n- Membership number\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feshaffer321%2Fcostco-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feshaffer321%2Fcostco-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feshaffer321%2Fcostco-go/lists"}