> For the complete documentation index, see [llms.txt](https://docs.blueseasx.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.blueseasx.com/server-bidding/sdk-integration/ad-format.md).

# Ad Format

For server bidding integration, the orchestration is similar to waterfall but with a few minor alterations. If you’re integrating BlueSea’s waterfall, just follow [Android](/android/integrate-sdk.md) and [iOS](/ios/integrate-sdk.md) If you’re using server bidding, please see the samples below.

First, create server bidding placement ids on the BlueSea console

### **Interstitial**

**Android**

To request interstitial ads, declare a `MediationInfo` object. This object should include the ad mediation platform, the mediation version, and the BlueSea Adapter version used when requesting the ads.&#x20;

```
MediationInfo mediationInfo = new MediationInfo("<in house or mediation name>","<mediation-version-name>", "<adapter-version-code>");
```

* **\<in house or mediation name>**: Pass the value as "in-house" or the specific mediation platform name.
* **\<mediation-version-name>**: Pass the version number of the mediation SDK.
* **\<adapter-version-code>**: Pass the version number of the adapter.

Call the `loadInterstitialAd(String, String, MediationInfo, AdLoadCallback<InterstitialAd>)`  method, pass the ad's Placement ID and server bidding’s encrypted adm obtained from the server

```
BlueseasxSDK.loadInterstitialAd("<BlueSea-pid>", "<ServerBidding-encrypted-adm>", mediationInfo, new AdLoadCallback<InterstitialAd>() {
  @Override
  public void onAdLoadError(@NonNull AdError error) {
      Log.d(TAG, "loadInterstitialAd error, code=" + error.getCode() + ", message=" + error.getMessage());
  }

  @Override
  public void onAdLoaded(@NonNull InterstitialAd ad) {
      Log.d(TAG, "loadInterstitialAd success");
      mInterstitialAd = ad;
  }
});
```

`AdLoadCallback<InterstitialAd>` callback:

* `onAdLoadError(AdError error)`: Indicates that no ads were filled. This may be due to the advertiser not bidding or other issues. You can check the error code and message by using `AdError.getCode() and AdError.getMessage()`. For details on error codes, refer to [Error Handling](/server-bidding/sdk-integration/error-handling.md)
* `onAdLoaded(InterstitialAd ad)`: Indicates that the ad was successfully filled, and returns an instance of the `InterstitialAd` object.

**iOS**

To request interstitial ads, declare a `BSXMediationInfo` object. This object should include the ad mediation platform, the mediation version, and the BlueSea Adapter version used when requesting the ads

```
BSXMediationInfo *mediationInfo = [[BSXMediationInfo alloc] initWithMediationName:@"<in-house or mediation>" mediationVersion:@"<mediation version-name>" adapterVersion:@"<adapter-version-name>"];
```

* `<in house or mediation name>`: Pass the value as "in-house" or the specific mediation platform name.
* `<mediation-version-name>`: Pass the version number of the mediation SDK.
* `<adapter-version-code>`: Pass the version number of the adapter.

Call the `[loadInterstitialAdWithPlacementId:mediationInfo:delegate:]` method, pass the ad's Placement ID and server bidding’s encrypted adm obtained from the server

```
[BlueSeaSDK loadInterstitialAdWithPlacementId:@"<BlueSea-pid>" payload:@"<ServerBidding-encrypted-adm>" mediationInfo:mediationInfo delegate:self];

@interface ViewController () <BSXInterstitialAdDelegate, BSXInterstitialAdLoadDelegate>

@end

@implementation ViewController ()
#pragma mark - BSXInterstitialAdLoadDelegate
- (void)didBSXInterstitialAdLoadError:(BSXAdError*)error {
    [self hideProgress];
    if (self.interstitialAd) {
        [self.interstitialAd destroy];
    }
    self.interstitialAd = nil;
}
- (void)didBSXInterstitialAdLoaded:(BSXInterstitialAd *)ad {
    [self hideProgress];
    if (self.interstitialAd) {
        [self.interstitialAd destroy];
    }
    self.interstitialAd = ad;
    [self.interstitialAd setDelegate:self];
}

@end
```

`BSXInterstitialAdLoadDelegate` Callback:

* `- (void)didBSXInterstitialAdLoadError:(BSXAdError*)error`: Indicates that no ads were filled. This may be due to the advertiser not bidding or other issues. You can check the error code and message by using `BSXAdError.errorCode` and `BSXAdError.errorMsg`. For details on error codes, refer to [Error Handling](/server-bidding/sdk-integration/error-handling.md)
* `- (void)didBSXInterstitialAdLoaded:(BSXInterstitialAd *)`: Indicates that the ad was successfully filled, and returns an instance of the `BSXInterstitialAd` object.

### **Rewarded**

**Android**

To request rewarded ads, declare a `MediationInfo` object. This object should include the ad mediation platform, the mediation version, and the BlueSea Adapter version used when requesting the ads.

```
MediationInfo mediationInfo = new MediationInfo("<in house or mediation name>","<mediation-version-name>", "<adapter-version-code>");
```

* **\<in house or mediation name>**: Pass the value as "in-house" or the specific mediation platform name.
* **\<mediation-version-name>**: Pass the version number of the mediation SDK.
* **\<adapter-version-code>**: Pass the version number of the adapter.

Call the `loadRewordVideoAd(String, String, MediationInfo, AdLoadCallback<RewardVideoAd>)` method, pass the ad's Placement ID and server bidding’s encrypted adm obtained from the server

```
BlueseasxSDK.loadRewordVideoAd("<BlueSea-pid>", "<ServerBidding-encrypted-adm>", mediationInfo, new AdLoadCallback<RewardVideoAd>() {
  @Override
  public void onAdLoadError(@NonNull AdError error) {
      Log.d(TAG, "loadRewordVideoAd error, code=" + error.getCode() + ", message=" + error.getMessage());
  }

  @Override
  public void onAdLoaded(@NonNull RewardVideoAd ad) {
      Log.d(TAG, "loadRewordVideoAd success");
      mRewardVideoAd = ad;
  }
});
```

`AdLoadCallback<RewardVideoAd>` callback：

* `onAdLoadError(AdError error)`: Indicates that no ads were filled. This may be due to the advertiser not bidding or other issues. You can check the error code and message by using `AdError.getCode()` and `AdError.getMessage()`. For details on error codes, refer to [Error Handling](/server-bidding/sdk-integration/error-handling.md)
* `onAdLoaded(RewardVideoAd ad)`: Indicates that the ad was successfully filled, and returns an instance of the `RewardVideoAd` object.

**iOS**

To request rewarded ads, declare a `BSXMediationInfo` object. This object should include the ad mediation platform, the mediation version, and the BlueSea Adapter version used when requesting the ads

```
BSXMediationInfo *mediationInfo = [[BSXMediationInfo alloc] initWithMediationName:@"<in-house or mediation>" mediationVersion:@"<mediation version-name>" adapterVersion:@"<adapter-version-name>"];
```

* `<in house or mediation name>`: Pass the value as "in-house" or the specific mediation platform name.
* `<mediation-version-name>`: Pass the version number of the mediation SDK.
* `<adapter-version-code>`: Pass the version number of the adapter.

Call `[BlueSeaSDK loadRewardVideoAdWithPlacementId:payload:mediationInfo:delegate:]` method，pass the ad's Placement ID and server bidding’s encrypted adm obtained from the server

```
[BlueSeaSDK loadRewardVideoAdWithPlacementId:@"<BlueSea-pid>" payload:@"<ServerBidding-encrypted-adm>" mediationInfo:mediationInfo delegate:self];

@interface ViewController () <BSXRewardVideoAdDelegate, BSXRewardVideoAdLoadDelegate>
@end

@implementation ViewController ()
#pragma mark - BSXRewardVideoAdLoadDelegate
- (void)didBSXRewardVideoAdLoadError:(BSXAdError*)error {
    if (self.rewardVideoAd) {
        [self.rewardVideoAd destroy];
    }
    self.rewardVideoAd = nil;
}
- (void)didBSXRewardVideoAdLoaded:(BSXRewardVideoAd *)ad {
    if (self.rewardVideoAd) {
        [self.rewardVideoAd destroy];
    }
    self.rewardVideoAd = ad;
    [self.rewardVideoAd setDelegate:self];
}

@end
```

`BSXRewardVideoAdLoadDelegate` callback：

* `- (void)didBSXRewardVideoAdLoadError:(BSXAdError *)error`: Indicates that no ads were filled. This may be due to the advertiser not bidding or other issues. You can check the error code and message using `AdError.errorCode` and `AdError.errorMsg`. For details on error codes, refer to [Error Handling](/server-bidding/sdk-integration/error-handling.md)
* `- (void)didBSXRewardVideoAdLoaded:(BSXRewardVideoAd *)ad`: Indicates that the ad was successfully filled and returns an instance of the `BSXRewardVideoAd` object.

### **Banner**

**Android**

To request banner ads, declare a `MediationInfo` object. This object should include the ad mediation platform, the mediation version, and the BlueSea Adapter version used when requesting the ads.&#x20;

```
MediationInfo mediationInfo = new MediationInfo("<in house or mediation name>","<mediation-version-name>", "<adapter-version-code>");
```

* **\<in house or mediation name>**: Pass the value as "in-house" or the specific mediation platform name.
* **\<mediation-version-name>**: Pass the version number of the mediation SDK.
* **\<adapter-version-code>**: Pass the version number of the adapter.

To request an ad, create a `BSXAdView` with the specified Placement and server bidding’s encrypted adm obtained from the server and call the `loadAd()` method. Add the `BSXAdView` as a child of your parent layout when you’re going to display the ad. You should also set a `BSXAdViewListener` to track ad load status and other related events. The following example shows how to request an ad:

```
public class ExampleActivity extends Activity
        implements BSXAdViewAdListener
{
  private BSXAdView adView;

  void createBannerAd()
  {
    adView = new BSXAdView(this, "«BlueSea-pid»" );
    adView.setAdViewListener( this );
    adView.setMediationInfo( mediationInfo );

    // Load the ad
    adView.loadAd("«ServerBidding-encrypted-adm»" );
  }

  // Ad Listener
  @Override
  public void onAdLoaded() {}
        // the ad is loaded successfully

  @Override
  public void onAdLoadError(AdError error) {}
        // the ad fails to load

  @Override
  public void onAdDisplayFailed(AdError error) {}
        // an error occurs when displaying the ad

  @Override
  public void onAdClicked() {}
        // the ad is clicked by user

  @Override
  public void onAdDisplayed() {}
        // an ad impression occurs
}
```

`BSXAdViewListener` callback：

* `onAdLoadError(AdError error)`: Indicates that no ads were filled. This may be due to the advertiser not bidding or other issues. You can check the error code and message using `AdError.getCode()` and `AdError.getMessage()`. For details on error codes, refer to [Error Handling](/server-bidding/sdk-integration/error-handling.md)
* `onAdLoaded():` Indicates that the ad was successfully filled

**iOS**

To request banner ads, declare a `BSXMediationInfo` object. This object should include the ad mediation platform, the mediation version, and the BlueSea Adapter version used when requesting the ads

```
BSXMediationInfo *mediationInfo = [[BSXMediationInfo alloc] initWithMediationName:@"<in-house or mediation>" mediationVersion:@"<mediation version-name>" adapterVersion:@"<adapter-version-name>"];
```

* `<in house or mediation name>`: Pass the value as "in-house" or the specific mediation platform name.
* `<mediation-version-name>`: Pass the version number of the mediation SDK.
* `<adapter-version-code>`: Pass the version number of the adapter.

To request an ad, create a `BSXAdView` with the specified Placement and  and server bidding’s encrypted adm obtained from the server then call the `loadAd` method. Add the `BSXAdView` as a child of your parent layout when you’re going to display the ad. You should also set a `BSXAdViewDelegate` to track ad load status and other related events. The following example shows how to request an ad:

```
@interface BannerViewController () <BSXAdViewDelegate>
@property(nonatomic, strong) BSXAdView *adView;
@property(nonatomic, strong) UIView *adContainer;
@end

@implementation BannerViewController
- (BSXAdView *)createAdView {
    BSXAdView *adView = [[BSXAdView alloc] initWithFrame:self.adContainer.bounds];
    [adView setPlacementId:BSXBannerAdPlacementId];
    [adView setMediationInfo:self.mediationInfo];
    return adView;
}

- (void)loadBannerAd {
    self.adView = [self createAdView];
    self.adView.delegate = self;
    [self.adView loadAdWithPayload:@"<ServerBidding-encrypted-adm>"];
}

#pragma mark - BSXAdViewDelegate
- (void)didBSXBannerAd:(BSXAdView *)adView loadError:(BSXAdError*)error {
    NSLog(@"BannerAd load fail.");
}
- (void)didBSXBannerAdLoaded:(BSXAdView *)adView {
    NSLog(@"BannerAd loaded.");
}
- (void)didBSXBannerAd:(BSXAdView *)adView displayFailed:(BSXAdError*)error {
    NSLog(@"BannerAd display fail.");
}
- (void)didBSXBannerAdDisplayed:(BSXAdView *)adView {
    NSLog(@"BannerAd displayed.");
}
- (void)didBSXBannerAdClicked:(BSXAdView *)adView {
    NSLog(@"BannerAd clicked.");
}

@end
```

`BSXAdViewDelegate` callback：

* `- (void)didBSXBannerAd:(BSXAdView *)adView loadError:(BSXAdError*)error`: Indicates that no ads were filled. This may be due to the advertiser not bidding or other issues. You can check the error code and message using `BSXAdError.errorCode` and `BSXAdError.errorMsg`.  For details on error codes, refer to [Error Handling](/server-bidding/sdk-integration/error-handling.md)
* `- (void)didBSXBannerAdLoaded:(BSXAdView *)adView`: Indicates that the ad was successfully filled
