{"id":20936217,"url":"https://github.com/adzerk/adzerk-decision-sdk-java","last_synced_at":"2025-04-11T14:22:25.984Z","repository":{"id":39936553,"uuid":"225666693","full_name":"adzerk/adzerk-decision-sdk-java","owner":"adzerk","description":"Java SDK for Adzerk's Decision API","archived":false,"fork":false,"pushed_at":"2025-04-07T03:06:29.000Z","size":437,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-04-07T04:22:50.342Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adzerk.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}},"created_at":"2019-12-03T16:30:53.000Z","updated_at":"2025-04-07T03:06:33.000Z","dependencies_parsed_at":"2025-01-10T15:42:12.337Z","dependency_job_id":"2bf10a23-dd96-44a2-a42b-520020dfdca6","html_url":"https://github.com/adzerk/adzerk-decision-sdk-java","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adzerk%2Fadzerk-decision-sdk-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adzerk%2Fadzerk-decision-sdk-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adzerk%2Fadzerk-decision-sdk-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adzerk%2Fadzerk-decision-sdk-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adzerk","download_url":"https://codeload.github.com/adzerk/adzerk-decision-sdk-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248418218,"owners_count":21100191,"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","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-11-18T22:18:24.798Z","updated_at":"2025-04-11T14:22:25.963Z","avatar_url":"https://github.com/adzerk.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Adzerk Java Decision SDK\n\nJava Software Development Kit for Adzerk Decision \u0026 UserDB APIs\n\n## Installation\n\nRequires [Java SE 8](https://en.wikipedia.org/wiki/Java_version_history) or higher.\n\n[Maven Package](https://search.maven.org/artifact/com.adzerk/adzerk-decision-sdk)\n\nAdd to your `pom.xml` file:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.adzerk\u003c/groupId\u003e\n    \u003cartifactId\u003eadzerk-decision-sdk\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0-beta.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nOr `build.gradle` file:\n\n```gradle\nimplementation 'com.adzerk:adzerk-decision-sdk:1.0.0-beta.1'\n```\n\nOr, if using Clojure, add to your `deps.edn` file:\n\n```clojure\n{:deps\n  {com.adzerk/adzerk-decision-sdk {:mvn/version \"1.0.0-beta.1\"}}}\n```\n\n## Examples\n\n### API Credentials \u0026 Required IDs\n\n- Network ID: Log into [Adzerk UI](https://app.adzerk.com/) \u0026 use the \"circle-i\" help menu in upper right corner to find Network ID. Required for all SDK operations.\n- Site ID: Go to [Manage Sites page](https://app.adzerk.com/#!/sites/) to find site IDs. Required when fetching an ad decision.\n- Ad Type ID: Go to [Ad Sizes page](https://app.adzerk.com/#!/ad-sizes/) to find Ad Type IDs. Required when fetching an ad decision.\n- API Key: Go to [API Keys page](https://app.adzerk.com/#!/api-keys/) find active API keys. Required when writing to UserDB.\n- User Key: UserDB IDs are [specified or generated for each user](https://dev.adzerk.com/reference/userdb#passing-the-userkey).\n\n### Fetching an Ad Decision\n\n```java\nimport java.util.*;\nimport com.adzerk.sdk.*;\nimport com.adzerk.sdk.generated.ApiException;\nimport com.adzerk.sdk.generated.model.*;\nimport com.adzerk.sdk.model.DecisionResponse;\n\npublic class FetchAds {\n  public static void main(String[] args) throws ApiException {\n    // Demo network, site, and ad type IDs; find your own via the Adzerk UI!\n    Client client = new Client(new ClientOptions(23).siteId(667480));\n    Placement placement = new Placement().adTypes(Arrays.asList(5));\n    User user = new User().key(\"abc\");\n\n    DecisionRequest request = new DecisionRequest()\n      .placements(Arrays.asList(placement))\n      .keywords(Arrays.asList(\"keyword1\", \"keyword2\"))\n      .user(user);\n\n    DecisionResponse response = client.decisions().get(request);\n    System.out.println(response.toString());\n  }  \n}\n```\n\n### Recording Impression \u0026 Clicks\n\nUse with the fetch ad example above.\n\n```java\n// Impression pixel; fire when user sees the ad\nString impUrl = decision.getImpressionUrl().toString();\nclient.pixels().fire(new PixelFireOptions().url(impUrl));\n\n// Click pixel; fire when user clicks on the ad\n// status: HTTP status code\n// location: click target URL\nString clickUrl = decision.getClickUrl().toString();\nPixelFireResponse clickResponse = client.pixels().fire(new PixelFireOptions() .url(clickUrl));\nSystem.out.println(\"Fired! \" +\n    \"status: \" + clickResponse.getStatusCode() + \" \" +\n    \"location: \" + clickResponse.getLocation());\n```\n\n### UserDB: Reading User Record\n\n```java\nimport com.adzerk.sdk.*;\nimport com.adzerk.sdk.generated.ApiException;\nimport com.adzerk.sdk.model.UserRecord;\nimport org.apache.commons.lang3.builder.ToStringBuilder;\n\npublic class FetchUserDb {\n  public static void main(String[] argv) throws ApiException {\n    // Demo network ID; find your own via the Adzerk UI!    \n    Client client = new Client(new ClientOptions(23));\n    UserRecord record = client.userDb().read(\"abc\");\n    System.out.println(ToStringBuilder.reflectionToString(record));\n  }  \n}\n```\n\n### UserDB: Setting Custom Properties\n\n```java\nimport java.util.*;\nimport com.adzerk.sdk.*;\nimport com.adzerk.sdk.generated.ApiException;\n\npublic class SetUserDb {\n  public static void main(String[] argv) throws ApiException {\n    // Demo network ID; find your own via the Adzerk UI!\n    Client client = new Client(new ClientOptions(23));\n\n    Map props = Map.of(\n      \"favoriteColor\", \"blue\",\n      \"favoriteNumber\", 42,\n      \"favoriteFoods\", new String[] {\"strawberries\", \"chocolate\"});\n\n    client.userDb().setCustomProperties(\"abc\", props);\n  }\n}\n```\n\n### UserDB: Forgetting User Record\n\n```java\nimport com.adzerk.sdk.*;\nimport com.adzerk.sdk.generated.ApiException;\n\npublic class ForgetUserDb {\n  public static void main(String[] argv) throws ApiException {\n    // Demo network ID and API key; find your own via the Adzerk UI!\n    Client client = new Client(new ClientOptions(23).apiKey(\"YOUR-API-KEY\"));\n    client.userDb().forget(\"abc\");\n  }\n}\n```\n\n### Decision Explainer\n\nThe Decision Explainer is a feature that returns information on a Decision API request explaining why each candidate ad was or was not chosen. \n\n\n```java\nimport java.util.*;\nimport com.adzerk.sdk.*;\nimport com.adzerk.sdk.generated.ApiException;\nimport com.adzerk.sdk.generated.model.*;\nimport com.adzerk.sdk.model.DecisionResponse;\n\npublic class FetchAds {\n  public static void main(String[] args) throws ApiException {\n    // Demo network, site, and ad type IDs; find your own via the Adzerk UI!\n    Client client = new Client(new ClientOptions(23).siteId(667480));\n    Placement placement = new Placement().adTypes(Arrays.asList(5));\n    User user = new User().key(\"abc\");\n\n    DecisionRequest request = new DecisionRequest()\n      .placements(Arrays.asList(placement))\n      .keywords(Arrays.asList(\"keyword1\", \"keyword2\"))\n      .user(user);\n\n    AdditionalOptions options = new AdditionalOptions()\n      .includeExplanation(true)\n      .apiKey(\"API_KEY\");\n\n    DecisionResponse response = client.decisions().get(request, options);\n    System.out.println(response.toString());\n  }  \n}\n```\n\nThe response returns a decision object with placement, buckets, rtb logs, and result information.\n``` json\n{\n  \"div0\": {\n    \"placement\": {},\n    \"buckets\": [],\n    \"rtb_log\": [],\n    \"results\": []\n  }\n}\n```\n\nThe \"placement\" object represents a decision in which an ad may be served. A Explainer Request can have multiple placements in the request.\nThe \"buckets\" array contains channel and priority information.\nThe \"rtb_logs\" array contains information about Real Time Bidding.\nThe \"results\" array contains the list of candidate ads that did and did not serve, along with a brief explanation.\n\n\u003c!-- ### Logging Example\n\nTBD: ....... --\u003e\n\n## Clojure Examples\n\n### Fetching an Ad Decision\n\n```clojure\n(ns readme-ad-request\n  (:import (com.adzerk.sdk Client ClientOptions)\n           (com.adzerk.sdk.generated.model DecisionRequest Placement User)))\n\n(defn -main []\n  ; Demo network, site, and ad type IDs; find your own via the Adzerk UI!\n  (let [client (Client. (doto (ClientOptions. (int 23)) (.siteId (int 667480))))\n        request (doto (DecisionRequest.)\n                      (.placements [(doto (Placement.) (.adTypes [5]))])\n                      (.keywords [\"keyword1\" \"keyword2\"])\n                      (.user (doto (User.) (.key \"abc\"))))]\n    (print (-\u003e client (.decisions) (.get request)))))\n```\n\n### Recording Impression \u0026 Clicks\n\nUse with the fetch ad example above.\n\n```clojure\n; Impression pixel; fire when user sees the ad\n(-\u003e client (.pixels) (.fire (doto (PixelFireOptions.) (.url (.toString (.getImpressionUrl decision))))))\n\n; Click pixel; fire when user clicks on the ad\n; status: HTTP status code\n; location: click target URL\n(let [decision-url (.toString (.getClickUrl decision))\n      pixel-results (-\u003e client (.pixels) (.fire (doto (PixelFireOptions.) (.url decision-url))))]\n  (println (str \"Fired! status: \" (.getStatusCode pixel-results)\n                \"; location: \" (.getLocation pixel-results))))))\n```\n\n### UserDB: Reading User Record\n\n```clojure\n(ns readme-read-userdb\n  (:use clojure.pprint)\n  (:import (com.adzerk.sdk Client ClientOptions)))\n\n(defn -main []\n  ; Demo network ID; find your own via the Adzerk UI!\n  (let [client (Client. (doto (ClientOptions. (int 23))))]\n    (pprint (bean (-\u003e client (.userDb) (.read \"abc\"))))))\n```\n\n### UserDB: Setting Custom Properties\n\n```clojure\n(ns readme-set-userdb\n  (:import (com.adzerk.sdk Client ClientOptions)))\n\n(defn -main []\n  ; Demo network ID; find your own via the Adzerk UI!\n  (let [client (Client. (doto (ClientOptions. (int 23))))\n        props {\"favoriteColor\" \"blue\"\n               \"favoriteNumber\" 42\n               \"favoriteFoods\" [\"strawberries\", \"chocolate\"]}]\n    (-\u003e client (.userDb) (.setCustomProperties \"abc\" props))))\n```\n\n### UserDB: Forgetting User Record\n\n```clojure\n(ns readme-forget-userdb\n  (:import (com.adzerk.sdk Client ClientOptions)))\n\n(defn -main []\n  ; Demo network ID and API key; find your own via the Adzerk UI!\n  (let [client (Client. (doto (ClientOptions. (int 23)) (.apiKey \"YOUR-API-KEY\")))]\n    (-\u003e client (.userDb) (.forget \"abc\"))))\n```\n\n## Documentation\n\n- [Adzerk API Documentation](https://dev.adzerk.com/reference)\n- [Adzerk User \u0026 Developer Documentation](https://dev.adzerk.com/docs)\n\n## Contributing\n\n### Reporting Issues\n\n- For bug fixes and improvements to this SDK please use Github to [open an issue](https://github.com/adzerk/adzerk-decision-sdk-java/issues) or send us a [pull request](https://github.com/adzerk/adzerk-decision-sdk-java/pulls).\n- For questions or issues regarding Adzerk functionality, please [contact Adzerk support](https://adzerk.com/help/).\n\n### Building\n\n```\n./gradlew build\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadzerk%2Fadzerk-decision-sdk-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadzerk%2Fadzerk-decision-sdk-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadzerk%2Fadzerk-decision-sdk-java/lists"}