Skip to Content
Core FeaturesTest Mode
Concepts

Test Mode

Preview real ads with your publisher ID

Use test mode in your development or staging environment to check your integration with the NotPixel API. If your publisher is on the waitlist, you can copy its ID from the waitlist page when test mode is available.

import Ads from 'notpixel'; const ads = new Ads({ publisherId: 'YOUR_PUBLISHER_ID', testMode: true }); const ad = await ads.getAd({ input: 'How can I optimize PostgreSQL?' }); if (ad?.testMode) console.log(ad.headline);
from notpixel import Ads, AsyncAds ads = Ads(publisher_id="YOUR_PUBLISHER_ID", test_mode=True) ad = ads.get_ad(input="How can I optimize PostgreSQL?")

React Native uses the same testMode option, and Python’s AsyncAds takes the same test_mode option. Your local or remote processing choice still applies.

Test mode selects from approved campaigns based on the input and publisher. An ad is labeled Anúncio de teste, has a disabled CTA, and generates no impressions, clicks, conversions, spend, or earnings. If no campaign matches, the SDK returns undefined in JavaScript or None in Python. Daily usage limits apply to the publisher ID across environments and IPs on the same API deployment.

Localhost and preview hosts

In the publisher dashboard, open Settings → Domains & apps and enable Allow localhost & preview hosts. The same control is available on the waitlist page. Requests recognized as coming from localhost (including loopback IPs), ngrok-managed domains, vercel.app, or workers.dev always use test mode, even if the request omits testMode or sets it to false. With the setting off, those requests receive a 403 development_origin_disabled and never serve a live ad.

When the chat backend calls NotPixel, pass the chat’s public origin as context.origin. Use the incoming request or the app’s configured public URL. For browser requests, NotPixel can also recognize development hosts from the HTTP Origin or Referer header.

const origin = request.headers.get('origin') ?? new URL(request.url).origin; const ad = await ads.getAd({ input, context: { origin } });

For other environments, use the SDK’s explicit test option or send testMode: true to POST /api/v1/pick. Test responses include testMode: true even on no-fill and omit impressionId.

In Domains & apps, register your own web hostname and verify it with the TXT record shown in the panel. You can also register your iOS Bundle ID or Android Application ID. Verify iOS and Android apps from a signed build when native delivery is enabled. For production web delivery, create a placement under the verified domain and render the opportunity with the React SDK or a custom browser renderer.

Last updated on
Was this helpful?