查询发票
按外部订单号查询发票详情、发票列表与发票文件。查询是主动拉取结果的方式,建议优先使用 回调通知,查询接口用于补偿与对账。
查询发票详情
GET
/invoice/{outOrderNo}/query返回外部订单号对应最新一张发票的完整信息。发票处于开票中时,接口会顺带向电子税务局查询一次开票结果。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| outOrderNo | string | 必填 | 路径参数,外部订单号 |
| appKey | string | 条件必填 | 服务密钥 Key,与 appSecret 成对使用;传了 accessToken 时可不传 |
| appSecret | string | 条件必填 | 服务密钥 Secret |
| accessToken | string | 条件必填 | 访问令牌,通过 获取访问令牌 接口获取;传了 accessToken 则无需 appKey / appSecret |
| taxNumber | string | 必填 | 企业纳税人识别号,指定本次操作的开票企业;必须是该密钥已关联的企业 |
| color | string | 选填 | 发票颜色:blue 蓝票(默认)、red 红票 |
查询频率限制
同一外部订单号 3 秒内重复查询会返回 请不要连续访问接口,建议使用回调接口,请勿轮询。
curl "https://fapiao-api.easyapi.com/invoice/ORDER20260101001/query?appKey=你的appKey&appSecret=你的appSecret&taxNumber=91320211MA1WML8X6T"
响应示例
{
"code": 1,
"message": "获取成功",
"content": {
"invoiceId": 10001,
"color": "blue",
"addTime": "2026-01-01 10:00:00",
"auditTime": "2026-01-01 10:00:00",
"printTime": "2026-01-01 10:00:35",
"outOrderNo": "ORDER20260101001",
"no": "FP20260101100000001",
"orderType": null,
"serviceType": "接口开票",
"category": "全电电子普通发票",
"state": 1,
"auditState": 1,
"printState": 1,
"cancelState": 0,
"redState": 0,
"statements": "已开票",
"price": 1000,
"tax": 56.6,
"purchaserName": "深圳市腾讯计算机系统有限公司",
"purchaserTaxpayerNumber": "91440300708461136T",
"purchaserAddress": "",
"purchaserPhone": "",
"purchaserBank": "",
"purchaserBankAccount": "",
"ifPerson": false,
"showPurchaserAddressPhoneBank": null,
"sellerName": "无锡帮趣数据服务有限公司",
"sellerTaxpayerNumber": "91320211MA1WML8X6T",
"sellerAddress": "无锡市滨湖区蠡太路118号天圣达科创中心A栋502室",
"sellerPhone": "021-00000000",
"sellerBank": "建设银行无锡滨湖支行",
"sellerBankAccount": "32050161483600001096",
"showSellerAddressPhoneBank": null,
"receiverName": "",
"checkerName": "",
"drawerName": "张三",
"showReceiverCheckerName": false,
"specificBusinessCode": null,
"specificBusiness": null,
"differenceType": null,
"mobile": "13800000000",
"email": "finance@example.com",
"sendSuccessCount": 1,
"userReason": null,
"consoleReason": null,
"shopReason": null,
"username": "",
"chinaTaxMobile": "13600000000",
"remark": "订单号:ORDER20260101001",
"callbackUrl": "https://www.example.com/invoice/callback",
"failMsg": null,
"provider": "数电发票",
"electronicInvoiceImg": "https://.../invoice.jpg",
"electronicInvoiceUrl": "https://.../invoice.pdf",
"electronicInvoiceOfd": "https://.../invoice.ofd",
"electronicInvoiceXml": "https://.../invoice.xml",
"downloadUrl": "https://.../download",
"code": "",
"number": "",
"checkCode": "",
"allElectronicInvoiceNumber": "26312000000000000001",
"invoiceItems": [
{
"invoiceItemId": 20001,
"lineNumber": 1,
"name": "*生产生活服务*技术服务费",
"category": "生产生活服务",
"no": "3040201010000000000",
"model": "",
"unit": "次",
"number": 1,
"price": 1000,
"sum": 1000,
"difference": null,
"discount": 0,
"taxRate": 0.06,
"tax": 56.6,
"zeroRateFlag": null,
"preferentialPolicyFlag": null,
"preferentialPolicyName": null,
"origLineNumber": null
}
],
"invoiceExtends": [],
"differenceVouchers": [],
"usedCar": null,
"parentInvoice": null
}
}
发票字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
| invoiceId | int | 发票 ID,修改、重试、红冲等接口使用 |
| color | string | blue 蓝票、red 红票 |
| addTime / auditTime / printTime | string | 申请时间 / 审核时间 / 开票成功时间 |
| outOrderNo | string | 外部订单号 |
| no | string | EasyAPI 发票业务订单号 |
| serviceType | string | 开票方式:接口开票、订单开票、合并订单开票、商品服务开票、金额开票、扫码开票 |
| category | string | 发票类型 |
| state / auditState / printState / cancelState / redState | int | 状态,见 发票状态说明 |
| statements | string | 状态说明文字 |
| price / tax | decimal | 价税合计 / 税额 |
| purchaser* / seller* | string | 购买方 / 销售方信息 |
| receiverName / checkerName / drawerName | string | 收款人 / 复核人 / 开票人 |
| specificBusinessCode / specificBusiness | string / object | 特定业务代码与内容 |
| differenceType / differenceVouchers | string / array | 差额征税类型与凭证 |
| mobile / email / sendSuccessCount | string / int | 交付手机号、邮箱与交付成功次数 |
| username | string | 用户标识 |
| chinaTaxMobile | string | 实际开票的开票员手机号 |
| remark | string | 备注 |
| callbackUrl | string | 回调地址 |
| failMsg | string | 开票失败原因 |
| provider | string | 开票通道 |
| electronicInvoiceImg / electronicInvoiceUrl / electronicInvoiceOfd / electronicInvoiceXml | string | 发票图片 / PDF / OFD / XML 文件地址 |
| downloadUrl | string | 发票交付(下载)页地址,可直接发给购买方 |
| code / number / checkCode | string | 发票代码 / 发票号码 / 校验码(税控发票) |
| allElectronicInvoiceNumber | string | 数电发票号码(20 位) |
| invoiceItems | array | 商品明细,字段同开票时的 items,origLineNumber 为红票对应的蓝票行号 |
| invoiceExtends | array | 扩展信息 |
| usedCar | object | 二手车发票信息,仅二手车发票返回 |
| parentInvoice | object | 红票对应的原蓝票信息,仅红票返回 |
查询发票列表
GET
/invoices/{outOrderNo}/query同一外部订单号可能对应多条记录(例如红冲后重新开票),该接口返回该订单号下的全部发票,按申请时间倒序。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| outOrderNo | string | 必填 | 路径参数,外部订单号 |
| appKey | string | 条件必填 | 服务密钥 Key,与 appSecret 成对使用;传了 accessToken 时可不传 |
| appSecret | string | 条件必填 | 服务密钥 Secret |
| accessToken | string | 条件必填 | 访问令牌,通过 获取访问令牌 接口获取;传了 accessToken 则无需 appKey / appSecret |
| taxNumber | string | 必填 | 企业纳税人识别号,指定本次操作的开票企业;必须是该密钥已关联的企业 |
| color | string | 选填 | blue(默认)/ red |
{
"code": 1,
"message": "获取成功",
"content": [
{ "invoiceId": 10002, "outOrderNo": "ORDER20260101001", "state": 1, "...": "字段同发票详情" },
{ "invoiceId": 10001, "outOrderNo": "ORDER20260101001", "state": 1, "redState": 2, "...": "字段同发票详情" }
]
}
没有记录时返回 {"code":0,"message":"暂无数据"}。
获取发票文件 Base64
GET
/invoices/{outOrderNo}/pdf-base64返回发票 PDF 文件(electronicInvoiceUrl)的 Base64 编码,适合需要自行存档或转发文件的场景。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| outOrderNo | string | 必填 | 路径参数,外部订单号 |
| appKey | string | 条件必填 | 服务密钥 Key,与 appSecret 成对使用;传了 accessToken 时可不传 |
| appSecret | string | 条件必填 | 服务密钥 Secret |
| accessToken | string | 条件必填 | 访问令牌,通过 获取访问令牌 接口获取;传了 accessToken 则无需 appKey / appSecret |
| taxNumber | string | 必填 | 企业纳税人识别号,指定本次操作的开票企业;必须是该密钥已关联的企业 |
| color | string | 选填 | blue(默认)/ red |
{
"code": 1,
"message": "获取成功",
"content": "JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmo..."
}
发票尚未生成文件时返回 发票文件不存在。
按数电发票号码查询
GET
/dzfp/{allElectronicInvoiceNumber}_{time}免鉴权接口,通过数电发票号码与开票时间查询发票信息,用于在购买方可见的页面(如发票交付页)展示发票。两个参数都正确才会返回数据。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| allElectronicInvoiceNumber | string | 必填 | 路径参数,20 位数电发票号码 |
| time | string | 必填 | 路径参数,开票成功时间,格式 yyyyMMddHHmmss |
curl "https://fapiao-api.easyapi.com/dzfp/26312000000000000001_20260101100035"
响应 content 结构同发票详情;号码或时间不匹配时返回 非法参数。