وثائق واجهة برمجة التطبيقات
احصل على بيانات UN Comtrade مباشرة في برامجك: ما تقدمه كل واجهة برمجة، وكيفية استدعائها، وأمثلة للنسخ.
البدء
-
احصل على مفتاح اشتراك
لا تحتاج الواجهة العامة إلى مفتاح. أما الأخرى فتحتاج إلى مفتاح اشتراك، مجاني مع أي حساب، من بوابة واجهات البرمجة الخاصة بي.
-
أرسل المفتاح مع كل طلب
ضعه في رأس الطلب هذا:
Ocp-Apim-Subscription-Key: مفتاح اشتراككأو أضفه إلى العنوان على النحو
subscription-key= -
جرّب أول طلب
هذا الطلب لا يحتاج إلى مفتاح: افتحه في متصفحك أو استدعه من برنامجك.
GET https://comtradeapi.un.org/public/v1/preview/C/A/HS?reporterCode=36&period=2023&partnerCode=0&cmdCode=TOTAL&flowCode=X
منتجات واجهات البرمجة
-
الواجهة العامة
معاينات لبيانات التجارة (حتى 500 صف)، وتوافر البيانات، والإصدارات، وقوائم المراجع، دون مفتاح.
-
واجهة الملفات المجمّعة
مجموعات بيانات كاملة في ملفات مضغوطة، ملف لكل جهة مُبلِّغة وفترة.
-
الواجهة غير المتزامنة
استعلامات كبيرة تُعدّ في الخلفية؛ وتتلقى رسالة بريد إلكتروني عندما يصبح الملف جاهزا.
سجّل الدخول لرؤية واجهات البرمجة المتاحة مع اشتراكك. تسجيل الدخول
جرّب
ترسل وحدة التحكم التفاعلية (Swagger UI) الطلبات من هذه الصفحة وتعرض الإجابات. اختر واجهة في الأعلى، وافتح نقطة وصول، ثم Try it out؛ وللواجهات التي تتطلب مفتاحا، أدخل مفتاحك في Authorize.
وحدة التحكم أداة خارجية بالإنكليزية وليست ميسّرة بالكامل: كل ما تصفه موجود أيضا في المرجع أدناه.
الواجهة العامة
Free API to preview trade data. Results are limited to 500 records. No subscription key required. See examples at https://unstats.un.org/go/498d8e
- العنوان
https://comtradeapi.un.org/public/v1- مفتاح الاشتراك
- غير مطلوب
GET
/preview/{typeCode}/{freqCode}/{clCode}
Get Trade Data (limited selection)
| الاسم | الموضع | إلزامي | الوصف |
|---|---|---|---|
typeCode |
في المسار | نعم |
Type of trade: C for commodities and S for service
القيم: C, S
|
freqCode |
في المسار | نعم |
Trade frequency: A for annual and M for monthly
القيم: A, M
|
clCode |
في المسار | نعم |
Product classifications: HS, SITC, BEC (for goods) or EBOPS (for services).
القيم: HS, H6, H5, H4, H3, H2, H1, H0, S4, S3, S2, S1, BE, BE5, EB, EB10, EB02, EBS
|
reporterCode |
في الاستعلام | لا | Reporter code (Possible values are code of the countries separated by comma (,)) |
period |
في الاستعلام | لا | Year or month. Year should be 4 digit year. Month should be six digit integer with the values of the form YYYYMM. Ex: 201002 for 2010 February. Maximum 1 period for preview |
partnerCode |
في الاستعلام | لا | Partner code (Possible values are code of the countries separated by comma (,)) |
cmdCode |
في الاستعلام | لا | Commodity code. Maximum 1 commodity code for preview |
flowCode |
في الاستعلام | لا | Trade flow code. Multi value input should be in the form of csv (Codes separated by comma (,)) Allowed values (case-insensitive): M, X, RX, RM, MIP, XIP, MOP, XOP, MIF, XIF, DX, FM. Omit to not filter. |
مثال على طلب
GET https://comtradeapi.un.org/public/v1/preview/C/A/HS?reporterCode=36&period=2023&partnerCode=0&cmdCode=TOTAL&flowCode=X
الإجابات
200Success400Invalid or missing parameters.500Unexpected server error.
مثال على إجابة
{
"elapsedTime": "1.07 secs",
"count": 1,
"data": [
{
"typeCode": "C",
"freqCode": "A",
"refPeriodId": 20220101,
"refYear": 2022,
"refMonth": 52,
"period": "2022",
"reporterCode": 842,
"reporterISO": null,
"reporterDesc": null,
"flowCode": "M",
"flowDesc": null,
"partnerCode": 0,
"partnerISO": null,
"partnerDesc": null,
"partner2Code": 0,
"partner2ISO": null,
"partner2Desc": null,
"classificationCode": "H6",
"classificationSearchCode": "HS",
"isOriginalClassification": true,
"cmdCode": "TOTAL",
"cmdDesc": null,
"aggrLevel": null,
"isLeaf": null,
"customsCode": "C00",
"customsDesc": null,
"mosCode": "0",
"motCode": 0,
"motDesc": null,
"qtyUnitCode": -1,
"qtyUnitAbbr": null,
"qty": 0.0,
"isQtyEstimated": false,
"altQtyUnitCode": -1,
"altQtyUnitAbbr": null,
…
GET
/previewTariffline/{typeCode}/{freqCode}/{clCode}
Get Tariffline Data (limited selection)
| الاسم | الموضع | إلزامي | الوصف |
|---|---|---|---|
typeCode |
في المسار | نعم |
Type of trade: C for commodities and S for service
القيم: C, S
|
freqCode |
في المسار | نعم |
Trade frequency: A for annual and M for monthly
القيم: A, M
|
clCode |
في المسار | نعم |
Product classifications: HS (for goods).
القيم: HS, H6, H5, H4, H3, H2, H1, H0
|
reporterCode |
في الاستعلام | لا | Reporter code (Possible values are code of the countries separated by comma (,)) |
period |
في الاستعلام | لا | Year or month. Year should be 4 digit year. Month should be six digit integer with the values of the form YYYYMM. Ex: 201002 for 2010 February. Multi value input should be in the form of csv (Codes separated by comma (,)) |
partnerCode |
في الاستعلام | لا | Partner code (Possible values are code of the countries separated by comma (,)) |
partner2Code |
في الاستعلام | لا | Second partner/consignment code (Possible values are code of the countries separated by comma (,)) |
cmdCode |
في الاستعلام | لا | Commodity code. Multi value input should be in the form of csv (Codes separated by comma (,)) |
flowCode |
في الاستعلام | لا | Trade flow code. Multi value input should be in the form of csv (Codes separated by comma (,)) Allowed values (case-insensitive): M, X, RX, RM, MIP, XIP, MOP, XOP, MIF, XIF, DX, FM. Omit to not filter. |
customsCode |
في الاستعلام | لا | Customs code. Multi value input should be in the form of csv (Codes separated by comma (,)) Allowed values: C00, C01, C02, C03, C04, C05, C06, C07, C08, C09, C10, C11, C12, C13, C14, C15, C20. Omit to not filter. |
motCode |
في الاستعلام | لا | Mode of transport code. Multi value input should be in the form of csv (Codes separated by comma (,)) Allowed values: 0, 1000, 2000, 2100, 2200, 2900, 3000, 3100, 3200, 3900, 9000, 9100, 9110, 9120, 9190, 9200, 9300, 9900. Omit to not filter. |
مثال على طلب
GET https://comtradeapi.un.org/public/v1/previewTariffline/C/A/HS?reporterCode=36&period=2023&partnerCode=0&cmdCode=TOTAL&flowCode=X
الإجابات
200Success400Invalid or missing parameters.500Unexpected server error.
مثال على إجابة
{
"elapsedTime": "38.07 secs",
"count": 1,
"data": [
{
"typeCode": "C",
"freqCode": "M",
"refPeriodId": 20230101,
"period": 202301,
"reporterCode": 36,
"reporterDesc": null,
"reporterISO": null,
"flowCode": "X",
"flowDesc": null,
"partnerCode": 344,
"partnerDesc": null,
"partnerISO": null,
"partner2Code": -1,
"partner2Desc": null,
"partner2ISO": null,
"classificationCode": "H6",
"cmdCode": "010121",
"cmdDesc": null,
"customsCode": "-1",
"customsDesc": null,
"mosCode": "-1",
"motCode": 9900,
"motDesc": null,
"qtyUnitCode": 5,
"qtyUnitAbbr": null,
"qty": 10.0,
"altQtyUnitCode": 5,
"altQtyUnitAbbr": null,
"altQty": 10.0,
"netWgt": 0.0,
"grossWgt": 5000.0,
"cifvalue": 0.0,
"fobvalue": 2739872.41,
"primaryValue": 2739872.41
}
…
GET
/getComtradeReleases
Get list of recent data releases
مثال على طلب
GET https://comtradeapi.un.org/public/v1/getComtradeReleases
الإجابات
200Success500Unexpected server error.
مثال على إجابة
{
"elapsedTime": "0.33 secs",
"count": 1,
"data": [
{
"reporterCode": 364,
"flagCode": "IR",
"datasetDesc": "Iran CA 2023",
"nr": "N",
"dateRelease": "2026-09-24T00:00:00"
}
],
"error": ""
}
GET
/getMetadata/{typeCode}/{freqCode}/{clCode}
Get Metadata (i.e., exchange rate, publication notes) for specific datasets
| الاسم | الموضع | إلزامي | الوصف |
|---|---|---|---|
typeCode |
في المسار | نعم |
القيم: C, S
|
freqCode |
في المسار | نعم |
القيم: A, M
|
clCode |
في المسار | نعم |
القيم: HS, H6, H5, H4, H3, H2, H1, H0, S4, S3, S2, S1, BE, BE5, EB, EB10, EB02, EBS
|
مثال على طلب
GET https://comtradeapi.un.org/public/v1/getMetadata/C/A/HS
الإجابات
200Success400Invalid or missing parameters.500Unexpected server error.
مثال على إجابة
{
"elapsedTime": "0.01 secs",
"count": 1,
"data": [
{
"reporterCode": 842,
"period": 2022,
"typeCode": "C",
"freqCode": "A",
"datasetCode": 20842202201202100,
"notes": [
{
"datasetCode": 20842202201202100,
"typeCode": "C",
"freqCode": "A",
"period": 2022,
"reporterCode": 842,
"reporterDescription": "USA",
"currency": "USD",
"importConvFactor": "1",
"exportConvFactor": "1",
"tradeSystem": "General",
"classificationCode": "H6",
"importValuation": "CIF",
"exportValuation": "FOB",
"importPartnerCountry": "Origin",
"exportPartnerCountry": "Last Known Destination",
"importPartner2Country": "N/A",
"exportPartner2Country": "N/A",
"publicationNote": "New Data: Data for this period is published for the first time; the new data was collected from US Census Bureau on 09 Feb 23.",
"publicationDate": "2023-03-09T17:58:13.15",
"publicationDateShort": "2023-03-09"
}
]
}
],
"error": ""
}
GET
/getDA/{typeCode}/{freqCode}/{clCode}
Get Trade Data Availability
| الاسم | الموضع | إلزامي | الوصف |
|---|---|---|---|
typeCode |
في المسار | نعم |
القيم: C, S
|
freqCode |
في المسار | نعم |
القيم: A, M
|
clCode |
في المسار | نعم |
القيم: HS, H6, H5, H4, H3, H2, H1, H0, S4, S3, S2, S1, BE, BE5, EB, EB10, EB02, EBS
|
مثال على طلب
GET https://comtradeapi.un.org/public/v1/getDA/C/A/HS
الإجابات
200Success400Invalid or missing parameters.500Unexpected server error.
مثال على إجابة
{
"elapsedTime": "0.12 secs",
"count": 1,
"data": [
{
"datasetCode": 20842202201202100,
"typeCode": "C",
"freqCode": "A",
"period": 2022,
"reporterCode": 842,
"reporterISO": "USA",
"reporterDesc": "USA",
"classificationCode": "H6",
"classificationSearchCode": "HS",
"isOriginalClassification": true,
"isExtendedFlowCode": true,
"isExtendedPartnerCode": true,
"isExtendedPartner2Code": false,
"isExtendedCmdCode": true,
"isExtendedCustomsCode": false,
"isExtendedMotCode": false,
"totalRecords": 1210614,
"datasetChecksum": 1750866618,
"firstReleased": "2023-03-09T19:23:39.45",
"lastReleased": "2023-03-09T19:23:39.45"
}
],
"error": ""
}
GET
/getDATariffline/{typeCode}/{freqCode}/{clCode}
Get Tariffline Data Availability
| الاسم | الموضع | إلزامي | الوصف |
|---|---|---|---|
typeCode |
في المسار | نعم |
القيم: C, S
|
freqCode |
في المسار | نعم |
القيم: A, M
|
clCode |
في المسار | نعم |
القيم: HS, H6, H5, H4, H3, H2, H1, H0, S4, S3, S2, S1, BE, BE5, EB, EB10, EB02, EBS
|
مثال على طلب
GET https://comtradeapi.un.org/public/v1/getDATariffline/C/A/HS
الإجابات
200Success400Invalid or missing parameters.500Unexpected server error.
مثال على إجابة
{
"elapsedTime": "0.06 secs",
"count": 1,
"data": [
{
"datasetCode": 30036202301202100,
"typeCode": "C",
"freqCode": "M",
"period": 202301,
"reporterCode": 36,
"reporterISO": "AUS",
"classificationCode": "H6",
"isOriginalClassification": true,
"isExtendedFlowCode": false,
"isExtendedPartnerCode": true,
"isExtendedPartner2Code": false,
"isExtendedCmdCode": true,
"isExtendedCustomsCode": false,
"isExtendedMotCode": true,
"totalRecords": 250125,
"datasetChecksum": 1356064231,
"lengthCmdCode": 6,
"firstReleased": "2023-04-27T00:23:19.56",
"lastReleased": "2024-03-14T08:42:10.66"
}
],
"error": ""
}
GET
/getMBS
The MBS data API gives users access to historical time series of MBS trade tables, notably Tables 38 and 35. Data availability and frequency of update depend on data series. T35 Total trade - value (1946-) T38 Conversion factors (1946-)
| الاسم | الموضع | إلزامي | الوصف |
|---|---|---|---|
series_type |
في الاستعلام | لا |
Combination of table number, frequency, type of measurement and currenty. T35.Q.V.$ T35.A.V.$ T38.Q.CF. T38.A.CF. T35.M.V.$ T38.M.CF.
القيم: T35.Q.V.$, T35.A.V.$, T38.Q.CF., T38.A.CF., T35.M.V.$, T38.M.CF.
|
year |
في الاستعلام | لا | Reference year (default = any):The reference year of period. As an example: 2015,2016 |
country_code |
في الاستعلام | لا | Country code (Possible values are code of the countries separated by comma (,)) |
period |
في الاستعلام | لا | Year or month. Year should be 4 digit year. Month should be six digit integer with the values of the form YYYYMM. Ex: 201002 for 2010 February. Multi value input should be in the form of csv (Codes separated by comma (,)) |
period_type |
في الاستعلام | لا |
data set frequency: Valid values:
A Annual
Q Quarterly
M Monthly
القيم: A, Q, M
|
table_type |
في الاستعلام | لا |
(default = any) MBS Table numbers: MBS and ITSY table identifier.
القيم: T35, T38
|
format |
في الاستعلام | لا |
Output format (default = json): Valid value are json, txt or csv
القيم: csv, txt, json
|
مثال على طلب
GET https://comtradeapi.un.org/public/v1/getMBS?series_type=T35.A.V.%24&year=2023&country_code=36&period=2023&period_type=A&table_type=T35
الإجابات
200Success (JSON by default; CSV/TXT when format is set)400Invalid or missing parameters.500Unexpected server error.
مثال على إجابة
{
"elapsedTime": "1.72 secs",
"count": 1,
"data": [
{
"series_Type": "T35.A.V.$",
"table_Type": "T35",
"table_Type_Desc": "Total trade - value",
"country_Code": 842,
"country_Type": "C",
"country_English_Name": "United States",
"year": 2022,
"period_Type": "A",
"period_Number": 0,
"period": "202252",
"period_In_Date": "01/01/2022",
"trade_Flow": "X",
"trade_Flow_Desc": "Exports",
"commodity_Classification": "",
"commodity_Group_Code": "1",
"commodity_Group_Name": "Total",
"partner_Country_Code": 0,
"partner_Country_English_Name": "World",
"base_Year": null,
"currency_Type": "$",
"value": 2065156.971,
"value_Unit": "M",
"value_Type": "V",
"value_Type_Desc": "Value",
"estimation_Type": "A",
"estimation_Type_Desc": "Actual"
}
],
"error": ""
}