{"id":31914132,"url":"https://github.com/ambiretech/adex-adview-manager","last_synced_at":"2025-10-13T18:59:56.113Z","repository":{"id":38401354,"uuid":"181838059","full_name":"AmbireTech/adex-adview-manager","owner":"AmbireTech","description":"manager class for AdEx adviews","archived":false,"fork":false,"pushed_at":"2023-12-21T08:13:13.000Z","size":2299,"stargazers_count":1,"open_issues_count":22,"forks_count":4,"subscribers_count":4,"default_branch":"v5-development","last_synced_at":"2025-08-03T14:52:08.689Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/AmbireTech.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}},"created_at":"2019-04-17T07:19:05.000Z","updated_at":"2022-01-22T10:23:37.000Z","dependencies_parsed_at":"2023-12-21T10:29:52.626Z","dependency_job_id":"65eba685-32f0-4afa-8106-971844e5d7ec","html_url":"https://github.com/AmbireTech/adex-adview-manager","commit_stats":null,"previous_names":["adexnetwork/adex-adview-manager"],"tags_count":43,"template":false,"template_full_name":null,"purl":"pkg:github/AmbireTech/adex-adview-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmbireTech%2Fadex-adview-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmbireTech%2Fadex-adview-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmbireTech%2Fadex-adview-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmbireTech%2Fadex-adview-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AmbireTech","download_url":"https://codeload.github.com/AmbireTech/adex-adview-manager/tar.gz/refs/heads/v5-development","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmbireTech%2Fadex-adview-manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016629,"owners_count":26085855,"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-10-13T02:00:06.723Z","response_time":61,"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-10-13T18:59:53.027Z","updated_at":"2025-10-13T18:59:56.103Z","avatar_url":"https://github.com/AmbireTech.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# adex-adview-manager\n\nManager class for AdEx AdViews.\n\nThis library is meant to be integrated by publishers on their websites, runs on the client side (user's browser) and facilitates the following functionalities:\n\n1. Pulling ad demand (campaigns) and applying targeting, header bidding and filtering according to the criteria set by the advertisers and the involved publisher\n2. Showing the ad creative to the user\n3. Counting events and sending them to the validators; for example, impressions (as defined by [IAB guidelines](https://www.iab.com/wp-content/uploads/2015/06/Ad-Impression-Measurment-Guideline-US.pdf)) and clicks\n\nFor more information, check the [adex-protocol repo](https://github.com/adexnetwork/adex-protocol).\n\n**NOTE:** If you're a publisher, you do not need to integrate this library directly. All you need to do is copy/paste the HTML snippet from the Platform once you create an ad slot.\n\nUsage:\n\n```javascript\nconst { AdViewManager } = require('adex-adview-manager')\nconst mgr = new AdViewManager(require('node-fetch'), {\n\tpublisherAddr: '0xd6e371526cdaeE04cd8AF225D42e37Bc14688D9E',\n\twhitelistedToken: '0x7af963cF6D228E564e2A0aA0DdBF06210B38615D',\n\ttargeting: [{ tag: 'location_BG', score: 1.5 }],\n})\nasync function run() {\n\tconsole.log((await mgr.getNextAdUnit()).html)\n}\nrun()\n```\n\n### Constructor:\n\n`const mgr = new AdViewManager(fetch, opts)`\n\n#### Options\n\nFor the available options, see https://github.com/AdExNetwork/adex-adview-manager/blob/master/src/main.ts#L18\n\nBrief description of each one:\nbackendURL\n* `backendURL`: URL to the AdEx market; defaults to `\"https://backend.moonicorn.network\"`\n* `acceptedStates`: array of accepted campaign states; defaults to `['Active', 'Ready']`\n* `minPerImpression`: minimum payment amount per impression; defaults to `'0'`\n* `minTargetingScore`: minimum targeting score to show an ad unit; defaults to `0`\n* `publisherAddr`: the address of the publisher that will receive the earnings\n* `whitelistedToken`: the address of the whitelisted payment token\n* `whitelistedType`: the allowed type of the ad unit; don't pass that in (or set to `null`) if you want to allow all types\n* `topByPrice`: how many ad units to consider after sorting by price\n* `topByScore`: how many ad units to consider after sorting by targeting\n* `randomize`: apply random sort on the final selection (after applying `topByPrice` and `topByScore`)\n* `targeting`: what targeting tags to apply\n\nFor detailed information on how the bidding process works, see: https://github.com/AdExNetwork/adex-protocol/blob/master/components/validator-stack.md#bidding-process\n\n### Methods:\n\n* `mgr.getAdUnits()`: returns a promise that resolves with all ad units from currently active campaigns; applies targeting and filtering\n* `mgr.getNextAdUnit()`: returns a promise that returns the least seen unit from `getAdUnits()`; use this in your app to get the next ad unit to show\n\nThe object format that those functions return is `{ unit, channelId, html }`\n\n\n\n## Build a browser version\n\n```\nwebpack --mode production\n```\n\n### Test it\n\n```\nhttp-server --cors dist.browser/\n```\n### test js-example\n[http://127.0.0.1:8080/js-example.html](http://127.0.0.1:8080/js-example.html)\n\n### iframe parameters\n\n```javascript\nconst options = {\n\tpublisherAddr: '0xd6e371526cdaeE04cd8AF225D42e37Bc14688D9E',\n\twhitelistedToken: '0x7af963cF6D228E564e2A0aA0DdBF06210B38615D',\n\twhitelistedType: 'legacy_300x250'\n}\nconst url = `index.html#${encodeURIComponent(JSON.stringify({ options }))}`\n```\n\n\n\n### iframes\n\n#### Standard:\n\n```\n\u003ciframe width={width} height={height} src=\"{origin}{parameters}\"\u003e\n```\n\n#### Auto-collapsing, collapsed by default:\n\nAuto-collapsing is achieved by adding an `onload` handler:\n\n```javascript\nwindow.addEventListener('message', function(ev) { if (ev.data.hasOwnProperty('adexHeight') \u0026\u0026 ev.origin === '{origin}') for (f of document.getElementsByTagName('iframe')) if (f.contentWindow === ev.source) f.height = ev.data.adexHeight }, false)\n```\n\n```\n`\u003ciframe width={width} src=\"{origin}{parameters}\" onload=\"window.addEventListener('message', function(ev) { if (ev.data.hasOwnProperty('adexHeight') \u0026\u0026 ev.origin === '{origin}') for (f of document.getElementsByTagName('iframe')) if (f.contentWindow === ev.source) f.height = ev.data.adexHeight }, false)\"\u003e\n```\n\n\n#### Auto-collapsing, not collapsed by default:\n\n\nEssentially the only difference to the previous one is that the `height` is set\n\n```\n\u003ciframe width={width} height={height} src=\"{origin}{parameters}\" onload=\"window.addEventListener('message', function(ev) { if (ev.data.hasOwnProperty('adexHeight') \u0026\u0026 ev.origin === '{origin}') for (f of document.getElementsByTagName('iframe')) if (f.contentWindow === ev.source) f.height = ev.data.adexHeight }, false)\"\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fambiretech%2Fadex-adview-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fambiretech%2Fadex-adview-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fambiretech%2Fadex-adview-manager/lists"}