{"id":36693992,"url":"https://github.com/recombee/go-api-client","last_synced_at":"2026-01-12T11:25:59.441Z","repository":{"id":229589308,"uuid":"777118030","full_name":"recombee/go-api-client","owner":"recombee","description":"Go client for easy use of the Recombee recommendation API","archived":false,"fork":false,"pushed_at":"2025-10-23T13:12:38.000Z","size":266,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-23T15:14:48.888Z","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/recombee.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":"2024-03-25T08:33:02.000Z","updated_at":"2025-10-23T13:12:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"1a84aa8a-9aea-41d9-ba03-061809c96287","html_url":"https://github.com/recombee/go-api-client","commit_stats":null,"previous_names":["recombee/go-api-client"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/recombee/go-api-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recombee%2Fgo-api-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recombee%2Fgo-api-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recombee%2Fgo-api-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recombee%2Fgo-api-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/recombee","download_url":"https://codeload.github.com/recombee/go-api-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recombee%2Fgo-api-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28338971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T10:58:46.209Z","status":"ssl_error","status_checked_at":"2026-01-12T10:58:42.742Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2026-01-12T11:25:58.538Z","updated_at":"2026-01-12T11:25:59.428Z","avatar_url":"https://github.com/recombee.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Recombee API Client\n\nA Go client (SDK) for easy use of the [Recombee](https://www.recombee.com/) recommendation API.\n\nIf you don't have an account at Recombee yet, you can create a free account [here](https://www.recombee.com/).\n\nDocumentation of the API can be found at [docs.recombee.com](https://docs.recombee.com/).\n\n## Installation\n\nRun the following command in your Go project:\n```\ngo get github.com/recombee/go-api-client/v6@v6.1.0\n```\n\n## Examples\n\n### Basic example\n\nThe following example shows how to:\n- Send many interactions within a single `Batch` request\n- Request recommendations for a user using `RecommendItemsToUser` and `RecommendNextItems` endpoints\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"math/rand\"\n    \"os\"\n\n    \"github.com/recombee/go-api-client/v6/recombee\"\n    \"github.com/recombee/go-api-client/v6/recombee/requests\"\n)\n\nfunc main() {\n    client, err := recombee.NewRecombeeClient(\"your-database-id\", \"db-private-token\", \"us-west\")\n    if err != nil {\n        fmt.Println(err)\n        panic(err)\n    }\n\n    const numItemsAndUsers = 100\n    const probabilityInteracted = 0.1\n\n    var addDetailViewInteractions []requests.Request\n    for i := 0; i \u003c numItemsAndUsers; i++ {\n        for j := 0; j \u003c numItemsAndUsers; j++ {\n            if rand.Float64() \u003c probabilityInteracted {\n                userId := fmt.Sprintf(\"user-%d\", i)\n                itemId := fmt.Sprintf(\"item-%d\", j)\n\n                request := client.NewAddDetailView(userId, itemId).SetCascadeCreate(true)\n                addDetailViewInteractions = append(addDetailViewInteractions, request)\n            }\n        }\n    }\n\n    fmt.Println(\"Send all interactions in Batch\")\n    batchRes, err := client.NewBatch(addDetailViewInteractions).Send()\n    if err != nil {\n        fmt.Println(err)\n        panic(err)\n    }\n\n    fmt.Println(batchRes) // Contains responses for all requests\n\n    // Get 5 recommendations for user 'user-25'\n    recommendReq := client.NewRecommendItemsToUser(\"user-25\", 5).SetCascadeCreate(true)\n    recommendRes, err := recommendReq.Send()\n    if err != nil {\n        fmt.Println(err)\n        panic(err)\n    }\n\n    fmt.Println(\"Recommended items:\")\n    for _, rec := range recommendRes.Recomms {\n        fmt.Println(rec.Id)\n    }\n\n    // User scrolled down - get next 3 recommended items\n    fmt.Println(\"Next recommended items:\")\n    recommendNextRes, err := client.NewRecommendNextItems(recommendRes.RecommId, 3).Send()\n    if err != nil {\n        fmt.Println(err)\n        panic(err)\n    }\n\n    for _, rec := range recommendNextRes.Recomms {\n        fmt.Println(rec.Id)\n    }\n}\n\n```\n\n\nSee `examples/batch` for an extended example of using the `Batch` requests.\n\n### Using property values\n\nThe second example shows how to:\n- Specify the properties (columns) of the items catalog using `AddItemProperty` requests\n- Upload their values for all the items using `SetItemValues` requests in a `Batch`\n- Get recommendations based on an item using `RecommendItemsToItem`\n- Search items using `SearchItems`\n\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"github.com/recombee/go-api-client/v6/recombee\"\n    \"github.com/recombee/go-api-client/v6/recombee/requests\"\n    \"math/rand\"\n    \"os\"\n    \"time\"\n)\n\nfunc main() {\n    client, err := recombee.NewRecombeeClient(\"your-database-id\", \"db-private-token\", \"us-west\")\n    if err != nil {\n        fmt.Println(err)\n        panic(err)\n    }\n\n    // Add item properties\n    // Properties are the columns of the items catalogs\n    properties := []struct {\n        propertyName string\n        propertyType string\n    }{\n        {\"price\", \"double\"},\n        {\"num-cores\", \"int\"},\n        {\"description\", \"string\"},\n        {\"image\", \"image\"},\n    }\n\n    for _, p := range properties {\n        if _, err := client.NewAddItemProperty(p.propertyName, p.propertyType).Send(); err != nil {\n            fmt.Println(err)\n            panic(err)\n        }\n    }\n\n    // Prepare and send a catalog of computers\n    const numItems = 100\n    requestsBatch := make([]requests.Request, numItems)\n\n    for i := 0; i \u003c numItems; i++ {\n        itemId := fmt.Sprintf(\"computer-%d\", i)\n        requestsBatch[i] = client.NewSetItemValues(itemId, map[string]interface{}{\n            \"price\":       600.0 + 400*rand.Float64(),\n            \"num-cores\":   1 + rand.Intn(7),\n            \"description\": \"Great computer\",\n            \"image\":       fmt.Sprintf(\"http://examplesite.com/products/%s.jpg\", itemId),\n        }).SetCascadeCreate(true)\n    }\n\n    if _, err := client.NewBatch(requestsBatch).Send(); err != nil {\n        fmt.Println(err)\n        panic(err)\n    }\n\n    // Simulate random purchases\n    const probabilityPurchased = 0.02\n    var addPurchaseRequests []requests.Request\n\n    for i := 0; i \u003c numItems; i++ {\n        for j := 0; j \u003c numItems; j++ {\n            if rand.Float64() \u003c probabilityPurchased {\n                userId := fmt.Sprintf(\"user-%d\", i)\n                itemId := fmt.Sprintf(\"computer-%d\", j)\n                addPurchaseRequests = append(addPurchaseRequests, client.NewAddPurchase(userId, itemId).SetCascadeCreate(true))\n            }\n        }\n    }\n\n    // Send the Batch request with custom timeout\n    ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n    defer cancel()\n\n    if _, err := client.NewBatch(addPurchaseRequests).SendWithContext(ctx); err != nil {\n        fmt.Println(err)\n        panic(err)\n    }\n\n    // Request recommendations with a set scenario\n    // Behavior of the recommendations is configured per scenario in the Recombee Admin UI\n    req := client.NewRecommendItemsToItem(\"computer-6\", \"user-42\", 5).SetScenario(\"product_detail\")\n\n    recommRes, err := req.Send()\n    if err != nil {\n        panic(err)\n    }\n    fmt.Println(\"Recommended items:\")\n    for _, rec := range recommRes.Recomms {\n        fmt.Println(rec.Id)\n    }\n\n    // Recommend items with at least 3 processor cores (dynamic filter), return property values of the items\n    req = client.NewRecommendItemsToItem(\"computer-6\", \"user-42\", 5)\n    req = req.SetFilter(\"'num-cores'\u003e=3\").SetReturnProperties(true)\n    recommRes, err = req.Send()\n    fmt.Println(\"\\nRecommended items with at least 3 cores:\")\n    for _, rec := range recommRes.Recomms {\n        fmt.Println(rec.Id)\n        fmt.Println(rec.Values)\n    }\n\n    // Perform a search using \"computers\" query\n    searchResponse, err := client.NewSearchItems(\"user-42\", \"computers\", 5).Send()\n\n    if err != nil {\n        panic(err)\n    }\n    fmt.Println(\"\\nSearch matches: %s\", searchResponse.Recomms)\n}\n\n```\n\n## Sending Requests\n\nA request can be sent to the Recombee API using the `Send()` method.\n\nIf you want to provide your own `context.Context` (e.g. to set your custom timeout for the request) call the `SendWithContext(ctx context.Context)` method.\n\n## RecombeeClient Initialization\n\nThe RecombeeClient can be created using the `NewRecombeeClient(...)` function, as per previous examples.\n\nIf you want to provide your own `http.Client` use `NewRecombeeClientWithOptions`:\n\n```go\n    region := \"ap-se\"\n    options := recombee.ClientOptions{Region: \u0026region, HttpClient: \u0026myHttpClient}\n    client, err := recombee.NewRecombeeClientWithOptions(\"your-database-id\", \"db-private-token\", options)\n```\n\n## Custom Errors\n\nVarious errors can occur while processing the request, for example, because of adding an already existing item or submitting interaction of a nonexistent user without *cascadeCreate* set to true. These errors lead to returning the `errors.ResponseError` by the `Send` method.\n\nAnother reason for producing an error is a timeout, yielding `errors.TimeoutError`.\n\nWe are doing our best to provide the fastest and most reliable service, but production-level applications shall implement a fallback solution since errors can always happen. The fallback might be, for example, showing the most popular items from the current category, or not displaying recommendations at all.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecombee%2Fgo-api-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frecombee%2Fgo-api-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecombee%2Fgo-api-client/lists"}