程序化广告
    • 天下联程序化广告投放接口

    天下联程序化广告投放接口

    1. 系统概述#

    1.1 接口简介#

    本文档用于协助渠道方(SSP/ADX/媒体服务端)接入我方广告竞价服务,说明广告请求、广告响应、监测上报和字段枚举等标准规范。
    通信协议采用 HTTPS,使用 POST 方法发送广告请求。接口支持 JSON 和 Protobuf 两种消息格式:
    消息格式接口路径说明
    JSON/json/bid请求体和响应体均为 JSON
    Protobuf/pb/bid请求体和响应体均为 Protobuf 二进制
    HTTP 状态码说明:
    状态码说明
    200 OK正常响应,可能有广告,也可能为无填充响应
    204 No Content无响应体
    其他状态码异常,渠道方可按无广告处理
    建议开启 HTTPS keep-alive 长连接。默认超时时间建议设置为 200ms 到 300ms,具体以双方联调确认值为准。

    1.2 环境地址#

    环境JSONProtobuf
    测试https://test.engine.showtx.cn/json/bidhttps://test.engine.showtx.cn/pb/bid
    正式https://engine.showtx.cn/json/bidhttps://engine.showtx.cn/pb/bid

    1.3 HTTP Header 规范#

    请求 Header:
    Header 字段必填建议/固定取值说明
    Content-TypeYapplication/json; charset=utf-8 或 application/x-protobuf声明请求体格式
    ConnectionYkeep-alive建议开启长连接,降低建连耗时
    Content-EncodingNgzip请求体压缩格式;未传表示未压缩
    Accept-EncodingNgzip声明可接收 gzip 响应
    响应 Header:
    Header 字段出现条件说明
    Content-Type必返JSON 响应为 application/json;Protobuf 响应为 application/protobuf
    Content-Encoding条件返回当响应体使用 gzip 压缩时返回

    2. 广告请求 BidRequest#

    2.1 BidRequest 对象#

    参数名类型必填描述
    idstringY请求唯一 ID
    impsobject arrayY广告曝光对象列表
    siteobjectN网站流量信息,App 流量可不填
    appobjectNApp 流量信息,App 流量建议填写
    contentobjectN内容上下文信息
    deviceobjectY用户设备信息
    userobjectN用户信息
    is_testboolN是否测试请求
    is_pingboolN是否 ping 请求
    is_previewboolN是否预览请求
    https_requiredboolN是否要求返回 HTTPS 链接
    max_bid_timeint32N最大竞价时间,单位毫秒
    media_exp_idsstring arrayN媒体实验 ID
    extend_infostringN扩展信息

    2.2 Imp 对象#

    参数名类型必填描述
    imp_idstringY曝光机会 ID
    pidstringY广告位 ID,请联系商务获取
    publisher_idstringY媒体 ID
    resource_typeint32Y资源类型,见附录资源类型
    creative_typesint32 arrayY可接受的创意类型,见附录创意类型
    widthint32Y广告位宽度,单位像素
    heightint32Y广告位高度,单位像素
    max_ad_numint32N期望返回广告数量
    min_cpm_priceint32NCPM 底价,单位分/千次展现
    min_cpc_priceint32NCPC 底价,单位分/点击
    open_typesint32 arrayN广告位支持的打开方式;不填时默认支持落地页,取值见附录打开方式
    pricing_typeint32 arrayN支持的计费类型,见附录计费类型
    templatesobject arrayN可用创意模板列表
    dealsobject arrayNDeal 信息
    download_typesint32 arrayN支持的下载类型:1 链接下载,2 应用商店下载,4 腾讯广点通下载
    title_lenint32N标题长度限制

    2.3 App 对象#

    参数名类型必填描述
    media_idstringY媒体 ID
    namestringY应用名称
    package_namestringYAndroid 包名或 iOS Bundle ID
    versionstringNApp 版本号
    app_idstringN应用 ID
    version_codeint32NApp 版本整数
    categoryint32 arrayNApp 类目

    2.4 Device 对象#

    参数名类型必填描述
    ipstringY用户 IP,支持 IPv4/IPv6
    user_agentstringYHTTP User-Agent
    device_typeint32N设备类型,见附录设备类型
    osint32Y操作系统,见附录操作系统
    osvstringN操作系统版本
    makestringN设备厂商
    modelstringN设备型号
    carrierint32N运营商,见附录运营商
    connection_typeint32N网络类型,见附录网络类型
    screen_widthint32N屏幕宽度,单位像素
    screen_heightint32N屏幕高度,单位像素
    geoobjectN地理位置信息
    idfastringiOS 推荐iOS IDFA
    oaidstringAndroid 推荐Android OAID
    android_idstringAndroid 推荐Android ID
    imei_md5stringAndroid 推荐IMEI MD5
    idfa_md5stringiOS 推荐IDFA MD5
    oaid_md5stringAndroid 推荐OAID MD5
    caidsobject arrayiOS 推荐CAID 列表,包含 ver、caid
    boot_markstringiOS 推荐iOS boot mark
    update_markstringiOS 推荐iOS update mark
    device_birth_timestringiOS 推荐设备初始化时间
    installed_pkgsstring arrayN用户已安装 App 包名列表

    2.5 User 对象#

    参数名类型必填描述
    ageint32N年龄
    genderint32N性别,见附录性别
    marriageint32N婚姻状态:0 未婚,1 已婚
    schoolint32N是否在校:0 不在校,1 在校
    categoryuint64 arrayN人群标签
    dmp_idsuint64 arrayN人群包 ID
    user_idstringN用户 ID

    2.6 Protobuf 格式#

    Protobuf 接口使用以下 proto3 格式。字段说明和枚举取值以本文档对应章节为准。
    syntax = "proto3";
    package showtx.bidding;
    
    message BidRequest {
      string sdk_version = 1;
      string id = 2;
      repeated Imp imps = 3;
      Site site = 4;
      App app = 5;
      Content content = 6;
      Device device = 7;
      User user = 8;
      bool is_test = 9;
      bool is_ping = 10;
      bool is_preview = 11;
      int32 adx_type = 12;
      bool https_required = 13;
      string extend_info = 14;
      int32 max_bid_time = 15;
      repeated string media_exp_ids = 17;
    
      message Imp {
        string imp_id = 1;
        string pid = 2;
        string publisher_id = 3;
        int32 resource_type = 4;
        repeated int32 creative_types = 5;
        int32 refresh_num = 6;
        int32 screen_num = 7;
        int32 position = 8;
        int32 width = 9;
        int32 height = 10;
        Video video = 11;
        int32 max_ad_num = 12;
        int32 min_cpm_price = 13;
        int32 min_cpc_price = 14;
        bool impression_repeatable = 15;
        repeated Template templates = 16;
        repeated Deal deals = 17;
        string campaign_date = 18;
        repeated int32 open_types = 19;
        repeated PricingType pricing_type = 20;
        repeated ProposedCreative proposed_creatives = 21;
        repeated ItemInfo item_infos = 22;
        ExcludedInfo excluded_info = 23;
        repeated int32 download_types = 24;
        int32 title_len = 25;
        string s_imp_id = 52;
    
        message Video {
          int32 videoad_start_delay = 1;
          int32 videoad_section_start_delay = 2;
          int32 min_ad_duration = 3;
          int32 max_ad_duration = 4;
        }
        message Template {
          uint64 id = 1;
          repeated string required_fields = 2;
          repeated string optional_fields = 3;
          repeated Attribute attributes = 4;
          message Attribute {
            string name = 1;
            string value = 2;
          }
        }
        message Deal {
          uint64 deal_id = 1;
          DealType deal_type = 2;
          repeated uint64 adv_ids = 3;
          int32 price = 4;
          bool impression_repeatable = 5;
          enum DealType {
            UNKNOWN = 0;
            PRIVATE_AUCTION = 1;
            PREFERRED_DEAL = 2;
            DIRECT_BUY = 3;
          }
        }
        message ProposedCreative {
          string crid = 1;
        }
        message ItemInfo {
          repeated string item_id = 1;
          string seller_id = 2;
        }
        message ExcludedInfo {
          repeated string publisher_filter_ids = 1;
          repeated string creative_ids = 2;
          repeated string excluded_click_through_urls = 3;
          repeated uint64 adv_ids = 4;
          repeated uint64 ad_category = 5;
          repeated uint64 streamer_ids = 6;
          repeated uint64 item_ids = 7;
        }
      }
    
      message Site {
        string name = 1;
        string page = 2;
        string ref = 3;
        repeated int32 category = 4;
      }
      message App {
        string media_id = 1;
        string name = 2;
        string package_name = 3;
        string version = 4;
        repeated int32 category = 5;
        string app_id = 6;
        int32 version_code = 7;
      }
      message Content {
        string title = 1;
        int32 duration = 2;
        repeated string keywords = 3;
        string query_term = 4;
        repeated string query_suggestion = 5;
        string program_id = 6;
        string video_id = 7;
        repeated string producer_id = 8;
        repeated int32 category = 9;
        string view_session_id = 10;
      }
      message Device {
        string ip = 1;
        string user_agent = 2;
        int32 device_type = 3;
        int32 os = 4;
        string osv = 5;
        string make = 6;
        string model = 7;
        int32 carrier = 8;
        int32 connection_type = 9;
        int32 screen_width = 10;
        int32 screen_height = 11;
        Geo geo = 12;
        repeated string installed_pkgs = 13;
        string media_device_id = 14;
        string idfa = 15;
        string oaid = 16;
        string android_id = 17;
        string uuid = 18;
        string mac = 19;
        string imei_md5 = 20;
        string idfa_md5 = 21;
        string oaid_md5 = 22;
        string mac_md5 = 23;
        repeated CAID caids = 24;
        string open_udid = 25;
        string cookie_id = 26;
        string imei = 27;
        string ver_code_of_ag = 28;
        string ver_code_of_hms = 29;
        string boot_mark = 30;
        string update_mark = 31;
        string device_birth_time = 32;
        string boot_time_sec = 33;
        string os_update_time_sec = 34;
        string rom_version = 35;
        int32 ppi = 36;
        bool wx_installed = 37;
        string paid = 38;
        string hwv = 39;
        int32 memory = 40;
        int32 disk = 41;
        string device_name = 42;
        string device_name_md5 = 43;
        string sys_memory = 44;
        string sys_disk_size = 45;
        message Geo {
          string lon = 1;
          string lat = 2;
          string country_code = 3;
          string province_code = 4;
          string city_code = 5;
          string district_code = 6;
        }
        message CAID {
          string ver = 1;
          string caid = 2;
        }
      }
      message User {
        int32 age = 1;
        int32 gender = 2;
        int32 marriage = 3;
        int32 school = 4;
        repeated uint64 category = 5;
        repeated uint64 dmp_ids = 6;
        repeated float embedding = 7;
        string user_id = 8;
      }
    }
    
    message BidResponse {
      int32 code = 1;
      string id = 2;
      repeated SeatBid seat_bids = 3;
      int32 cache_duration = 4;
      UserInfo user_info = 5;
      string extend_info = 6;
    
      message SeatBid {
        string imp_id = 1;
        repeated Bid bids = 2;
      }
      message Bid {
        CreativeData creative = 3;
        Monitor monitor = 4;
        PricingType pricing_type = 5;
        int32 max_cpm_price = 6;
        int32 max_cpc_price = 7;
        uint64 deal_id = 8;
        uint64 adv_id = 9;
        string campaign_date = 10;
        BidType bid_type = 11;
        string network_guid = 13;
        string extend_data = 14;
        string platform_name = 55;
        enum BidType {
          NORMAL = 0;
          DEFAULT = 1;
          MARKET = 2;
        }
      }
      message CreativeData {
        string id = 1;
        int32 type = 2;
        string title = 3;
        string description = 4;
        string action_text = 5;
        repeated ImageData images = 6;
        repeated VideoData videos = 7;
        string html_snippet = 8;
        AppInfo app = 9;
        Landing landing = 10;
        string adv_name = 11;
        string adv_logo = 12;
        int32 sub_type = 13;
        TemplateData template_data = 14;
        TemplateData sub_template_data = 15;
    
        message ImageData {
          int32 type = 1;
          int32 width = 2;
          int32 height = 3;
          string url = 4;
          string md5 = 5;
        }
        message VideoData {
          int32 type = 1;
          int32 width = 2;
          int32 height = 3;
          int32 duration = 4;
          string url = 5;
          string md5 = 6;
          ImageData cover_img = 7;
        }
        message TemplateData {
          uint64 template_id = 1;
          repeated Field fields = 2;
          message Field {
            string name = 1;
            string value = 2;
          }
        }
      }
      message Landing {
        string landing_url = 1;
        string deeplink_uri = 2;
        string universal_link = 3;
        string app_schema_ids = 4;
        int32 open_type = 5;
        repeated string click_area = 6;
        MiniApp mini_app = 7;
        message MiniApp {
          int32 host_app = 1;
          string app_id = 2;
          string path = 3;
          string query = 4;
          string program_id = 5;
        }
      }
      message Monitor {
        repeated string imp_tracking_url = 1;
        repeated string click_tracking_url = 2;
        repeated string dp_tracking_url = 3;
        repeated string dp_success_tracking_url = 4;
        repeated string dp_fail_tracking_url = 5;
        repeated string download_start_url = 6;
        repeated string download_complete_url = 7;
        repeated string install_start_url = 8;
        repeated string install_complete_url = 9;
        repeated string install_open_url = 10;
        repeated EventTrack event_tracks = 15;
        string win_notice_url = 16;
        string loss_notice_url = 17;
        message EventTrack {
          int32 type = 1;
          repeated string url = 2;
          int32 time = 3;
          int32 send_type = 4;
        }
      }
      message AppInfo {
        string app_name = 1;
        string package_name = 2;
        string download_url = 3;
        int32 download_type = 4;
        string app_store_id = 5;
        int32 size = 6;
        string ver = 7;
        string per_url = 8;
        string pri_url = 9;
        string intro_url = 10;
        string publisher = 11;
      }
      message UserInfo {
        string user_id = 1;
      }
    }
    
    enum PricingType {
      PRICING_CPM = 0;
      PRICING_CPC = 1;
    }

    3. 广告响应 BidResponse#

    3.1 BidResponse 对象#

    参数名类型必填描述
    codeint32Y0 表示无异常;非 0 表示异常
    idstringY对应请求 id
    seat_bidsobject arrayN出价结果列表
    cache_durationint32N不参竞缓存时长,单位秒
    user_infoobjectN用户信息
    extend_infostringN扩展信息或错误说明

    3.2 SeatBid 对象#

    参数名类型必填描述
    imp_idstringY对应请求中的 imp_id
    bidsobject arrayN该曝光机会下的广告列表

    3.3 Bid 对象#

    参数名类型必填描述
    creativeobjectY创意信息
    monitorobjectN监测信息
    pricing_typeint32N计费类型,见附录计费类型
    max_cpm_priceint32CPM 必填CPM 出价,单位分/千次展现
    max_cpc_priceint32CPC 必填CPC 出价,单位分/点击
    deal_iduint64NPMP Deal ID
    adv_iduint64N广告主 ID
    bid_typeint32N出价类型:0 正常,1 抄底,2 市场广告
    network_guidstringN自定义数据,最长 64 字节
    extend_datastringN自定义扩展字段,最长 128 字节
    platform_namestringN广告平台名称

    3.4 Creative 对象#

    参数名类型必填描述
    idstringY创意 ID
    typeint32Y创意类型:1 大图,2 图文,3 组图,4 互动广告,5 开屏,6 横幅,7 视频,8 激励视频,9 插屏
    titlestringN标题
    descriptionstringN描述
    action_textstringN按钮或互动引导文案
    imagesobject arrayN图片素材
    videosobject arrayN视频素材
    html_snippetstringNHTML 创意片段
    appobject下载类广告推荐应用信息
    landingobjectY落地页与打开方式信息
    adv_namestringN广告主名称
    adv_logostringN广告主 Logo
    template_dataobjectN模板字段信息

    3.5 AppInfo 对象#

    下载类广告应返回应用合规信息,供客户端展示和合规校验。
    参数名类型必填描述
    app_namestringYAPP 名称
    package_namestringYAndroid package name 或 iOS Bundle ID
    download_urlstringY下载地址
    download_typeint32N下载类型
    app_store_idstringiOS 下载必填iOS App Store ID
    sizeint32N应用大小,单位字节
    verstringN应用版本号
    per_urlstringN权限说明 URL
    pri_urlstringN隐私政策 URL
    intro_urlstringN应用介绍 URL
    publisherstringN开发者名称

    3.6 Monitor 对象#

    参数名类型触发时机
    imp_tracking_urlstring array广告真实曝光
    click_tracking_urlstring array用户有效点击
    dp_tracking_urlstring array准备发起 Deeplink
    dp_success_tracking_urlstring arrayDeeplink 唤起成功
    dp_fail_tracking_urlstring arrayDeeplink 唤起失败
    download_start_urlstring array开始下载
    download_complete_urlstring array下载完成
    install_start_urlstring array开始安装
    install_complete_urlstring array安装完成
    install_open_urlstring array安装后首次打开
    event_tracksobject array扩展事件监测
    win_notice_urlstring竞价胜出反馈
    loss_notice_urlstring竞价失败反馈

    4. 示例#

    4.1 JSON 请求示例#

    {
      "id": "req-202608280001",
      "imps": [
        {
          "imp_id": "1",
          "pid": "slot_10001",
          "publisher_id": "media_10001",
          "resource_type": 2,
          "creative_types": [1, 2],
          "width": 640,
          "height": 320,
          "min_cpm_price": 100,
          "max_ad_num": 1,
          "open_types": [1, 2, 3],
          "pricing_type": [0]
        }
      ],
      "app": {
        "media_id": "media_10001",
        "name": "Demo App",
        "package_name": "com.demo.app",
        "version": "1.0.0"
      },
      "device": {
        "ip": "127.0.0.1",
        "user_agent": "Mozilla/5.0",
        "device_type": 0,
        "os": 3,
        "osv": "14",
        "make": "HUAWEI",
        "model": "demo",
        "oaid": "oaid-example",
        "connection_type": 1
      },
      "max_bid_time": 300
    }

    4.2 JSON 响应示例#

    {
      "code": 0,
      "id": "req-202608280001",
      "seat_bids": [
        {
          "imp_id": "1",
          "bids": [
            {
              "pricing_type": 0,
              "max_cpm_price": 120,
              "creative": {
                "id": "cr_10001",
                "type": 2,
                "title": "广告标题",
                "description": "广告描述",
                "action_text": "立即查看",
                "images": [
                  {
                    "type": 0,
                    "width": 640,
                    "height": 320,
                    "url": "https://example.com/image.jpg"
                  }
                ],
                "landing": {
                  "landing_url": "https://example.com/landing",
                  "open_type": 1
                }
              },
              "monitor": {
                "imp_tracking_url": ["https://track.example.com/imp?price=__WIN_PRICE__"],
                "click_tracking_url": ["https://track.example.com/click"]
              }
            }
          ]
        }
      ]
    }

    4.3 Curl 示例#

    5. 监测与宏替换#

    监测 URL 由客户端或媒体服务端在对应事件发生时上报。URL 中如包含宏,需要在上报前完成替换。
    宏含义
    __WIN_PRICE__竞价成交价
    __LOSS_REASON__竞败原因
    __WIDTH__ / __HEIGHT__实际广告位宽高
    __WIDTH_PX__ / __HEIGHT_PX__实际广告位像素宽高
    __DOWN_X__ / __DOWN_Y__点击按下坐标
    __UP_X__ / __UP_Y__点击抬起坐标
    __SLD__点击交互方式
    更完整的宏替换规则见《客户端打点与宏替换说明》。

    6. 附录:枚举#

    6.1 计费类型 PricingType#

    值含义
    0CPM
    1CPC

    6.2 资源类型 ResourceType#

    值含义
    0未知
    1开屏
    2信息流/推荐流/视频流
    3激励视频
    4插屏/弹窗
    5Draw 沉浸全屏
    6Banner

    6.3 创意类型 CreativeType#

    值含义
    0未知
    1图片
    2视频
    3图文
    4图文视频
    5组图
    6H5
    7竖版视频

    6.4 打开方式 OpenType#

    请求字段 imps[].open_types 表示广告位支持的打开方式,可同时传多个值;响应字段 creative.landing.open_type 表示本次返回广告的实际打开方式。
    值含义
    0未知
    1落地页
    2下载
    3Deeplink
    4Universal Link
    5直播间
    6半屏落地页
    7小程序

    6.5 设备类型 DeviceType#

    值含义
    0手机
    1平板
    2PC
    3互联网电视

    6.6 操作系统 Os#

    值含义
    0未识别
    1PC/Windows
    2iOS
    3Android
    4Windows Phone
    5Mac
    6Linux
    7Yun
    8Tizen
    9Cycle
    10HarmonyOS

    6.7 网络类型 ConnectionType#

    值含义
    0未识别
    1Wi-Fi
    22G
    33G
    44G
    55G

    6.8 运营商 Carrier#

    值含义
    0未识别
    1中国移动
    2中国联通
    3中国电信

    6.9 性别 Gender#

    值含义
    0未知
    1男性
    2女性
    修改于 2026-08-28 09:30:17
    Built with