GTT REST API User Manual - Global Trade Tracker

Transcription

GTT RESTAPI UserManualGTT REST API HowToJuly 14, 2022

Table of Contents1Introduction . 12Accessing the GTT REST API . 13Retrieving an API Token . 14URIs and Endpoints . 24.1Subscription details . 24.2Available Countries . 24.3Available Trade details . 34.4Report fields . 34.5Data updates . 34.6Report Generation . 45Accessing Trade Data . 46Output Format . 47Parameters. 57.1accumulatecommoditygroups. 57.2accumulateotherpartners. 57.3accumulatepartnergroups. 57.4accumulatereportergroups . 57.5currency. 57.6customconversionrules. 67.7dataelements . 67.8decimalscale. 67.9excludeintratrade . 77.10 fallbacktomirrordata . 77.11 field . 77.12 filterbysource . 77.13 format . 77.14 from . 87.15 hscode . 87.16 hslevel . 87.17 impexp . 87.18 includeotherpartners. 97.19 lang. 97.20 latestmonths . 97.21 layout . 97.22 maxQ1 . 107.23 maxQ2 . 107.24 maxV . 107.25 metadata . 107.26 minQ1 . 107.27 minQ2 . 117.28 minV . 117.29 mirrored . 11

7.30 onlycompleteperiods . 117.31 partner . 117.32 periodtype. 117.33 reporter . 127.34 requirealldatareported . 127.35 source. 127.36 to . 127.37 token. 137.38 tradedetails . 137.38.1Create the report data only for the certain trade details . 137.39 unit. 137.40 updatedAfter . 14

GTT REST API User manual1 IntroductionThis guide will show you how to access Global Trade Tracker (‘GTT’) with the GTT REST API. Theguide assumes that you are a programmer or researcher who is familiar with the concepts andtechniques of retrieving data from Web Services.2 Accessing the GTT REST APIFollowing requirements have to be fulfilled to be able to access the GTT REST API: You need a valid GTT userid3 Retrieving an API TokenPlease note: The REST API itself can be accessed only with a valid Token.With a valid GTT userid you can retrieve an API Token to access the REST API which will be valid for14 days.This Token must then be sent in all subsequent calls to the API, either in the http header request (thepreferred way) or as URL or POST parameter.The Header must have the following format:Authorization : Bearer 61D1345AFF690F8F5D13DAB12F6EC9DEIf the Token is sent as URL GET parameter: /?para1 &token 61D1345AFF690F8F5D13DAB12F6EC9DE¶N Or as POST/Form parameter “token”The target URL to retrieve a token tokenBoth methods ‘GET’ and ‘POST’ are supported to retrieve a Token.Parameters which are mandatory to retrieve a token:userida valid GTT useridpassword the password for the supplied GTT useridExample GET t/gettoken?userid myGTTuserid&password myPasswordOr a Token can be retrieved through the basic user interface found at:https://www.globaltradetracker.com/api/Zen Innovations AG, Bernstrasse 99, CH-3122 Kehrsatzwww.globaltradetracker.com www.zen-innovations.comP a g e 1 of 14

GTT REST API User manual4 URIs and EndpointsThe following services are available4.1 Subscription detailsTo get the details of your current subscription (countries and commodity codes) for the actualcontract/userid, treport/subscriptionsSupported method: ‘GET’Parameter:periodTypefollowing periodType’s are currently supported: M (month) Y (year) Q (quarter) S (semester) YTD (year-to-date)If not selected, the default is periodType MResponse: JSON4.2 Available CountriesTo get a list of all available countries on GTT (including alphageonom2 code, source, first/last availabledate, date of last update, update frequency, extra information etc.) treport/countriesSupported method: ‘GET’Parameter: periodsif specified with the value “true”, the country information also contains the list of availableperiods with the data status for each period.The status values are:o FULL – complete trade data is availableo PART – partial data is availableo VALUES – only the values are available, no quantity informationo EXTRAEU – only the extra-EU information is available (used for the EU countries only). langdefines the language used for the translation of the country names.Allowed values: en de fr zh CN es hi jaZen Innovations AG, Bernstrasse 99, CH-3122 Kehrsatzwww.globaltradetracker.com www.zen-innovations.comP a g e 2 of 14

GTT REST API User manualDefault value if missing/not set: enResponse: JSON4.3 Available Trade detailsTo get a list of names and ids of the available trade details for the countries on GTT treport/tradedetailsSupported method: ‘GET’Parameter: tradedetailsdefined the type of the trade details.The values are:o SUBDIVISION – country subdivisions, states, provinces, etc.o PORT – country portso TRANSPORT – transportation modeo CUSTOM – the available information depends on the country.The parameter is required.Please note: Only a certain number of countries report this type of information. Please refer tothe data availability list to get the different countries and their supplementary data elements. countryCodeGeonom alpha-2 country code.Some of the reporting countries have several sets of the trade data. It is possible to select thespecific trade data by appending the suffix to the country code.E.g. ‘FR customs’ specifies the trade data provided by the national statistics office,‘FR eurostat’ specifies the data provided by Eurostat.If the reporting country has several sets of the trade data, it will be specified several times in thelist of countries provided by the ‘Available Countries’ end-point (see 4.2 above) with therespective suffixes in the ‘reportercode’ property.The parameter is required unless, the parameter tradedetails TRANSPORT is specified (theavaialable transportation modes are not country-specific). langdefines the language used for the translation of the trade detail names.Allowed values: en de fr zh CN es hi jaDefault value if missing/not set: enResponse: JSON4.4 Report fieldsTo get a list of all available report fields treport/fieldsSupported method: ‘GET’Parameter: langdefines the language used for the translation of the field names and desriptions.Allowed values: en de fr zh CN es hi jaDefault value if missing/not set: enResponse: JSON4.5 Data updatesTo retrieve information regarding data updates on GTT (whether this is newly added data or updateddata) following URL can be etreport/dataupdatesSupported method: ‘GET’Zen Innovations AG, Bernstrasse 99, CH-3122 Kehrsatzwww.globaltradetracker.com www.zen-innovations.comP a g e 3 of 14

GTT REST API User manualParameter: countryCodea list of comma-separated country codes, e.g. “US,CA,CH” periodTypefollowing periodType’s are currently supported:- M (month)- Y (year)- Q (quarter)- S (semester)- YTD (year-to-date)If not selected, the default is M updatedAfterthe date to check for updates/additions (i.e. updates/additions will be reported from this dateonwards)supported formats:- yyyy-MM-ddTHH:mm:ss- yyyy-MM-dd (will become yyyy-MM-ddT00:00:00 internally)- yyyy-MM (will become yyyy-MM-01T00:00:00 internally)- yyyy (will become yyyy-01-01T00:00:00 internally)Response: JSON4.6 Report GenerationTo create a GTT report, treportSupported methods: ‘GET’ and ‘POST’5 Accessing Trade DataUse the URI defined in chapter 4.6 to create and access datasets using GTT’s REST API.You can retrieve data by sending an HTTPS GET or POST request to the URI with the appropriate(query string) parameters.Chapter 7 lists all the available parameters you can use.Example:The following API call will retrieve the monthly import value from January 2016 to June 2016 forGermany and Switzerland for HS Codes 8401 and 2703 in JSON format (if the following API Token wasvalid – the one below is not /getreport?token NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN&impexp I&periodtype M&from 2016-01&to 201606&reporter DE%2CCH&accumulatereportergroups true&partner &accumulatepartnergroups true&source DEFAULT&hscode 8401%2C2703&accumulatecommoditygroups true&hslevel 0¤cy &unit &decimalscale &customconversionrules true&layout brief&format json6 Output FormatThe API returns data in following formats:-Javascript Object Notation (JSON) formatComma-separated values format (CSV)Microsoft Excel Open XML format (XLSX)Zen Innovations AG, Bernstrasse 99, CH-3122 Kehrsatzwww.globaltradetracker.com www.zen-innovations.comP a g e 4 of 14

GTT REST API User manual7 ParametersBeside the authorization token which has to be provided either in the request HEADER or as parameter“token”, the following 4 parameters MUST be provided with valid values, otherwise a GTT report cannotbe created:reporter, hscode, impexp, sourceOne of the following two parameters is required (if both parameters are set, latestmonths hasprecedence):from, latestmonths7.1 accumulatecommoditygroupsallowed values:true falsedefault value if missing/not set:falsedescription: If a commodity group is used (chapter 7.15) and ifaccumulatecommoditygroups is set to true, then all commodity codes (HSCodes) defined for that group will be aggregated. If set to false, the dataset will list trade for each commodity code listed in that group.7.2 accumulateotherpartnersallowed values:true falsedefault value if missing/not set:falsedescription: If a set of countries is defined for partner countries (chapter 0)and accumulateotherpartners is set to true, then trade with all countriesother than those specified in partner countries will be aggregated as atotal. If set to false, then the trade will be listed for each other partnercountry.7.3 accumulatepartnergroupsallowed values:true falsedefault value if missing/not set:falsedescription: If country groups are listed for partner countries (chapter 0) andif accumulatepartnergroups is set to true, then trade will be aggregated foreach of these country groups. If set to false, trade will be listed for eachpartner country.7.4 accumulatereportergroupsallowed values:true falsedefault value if missing/not set:falsedescription: If country groups are listed for reporting countries (chapter 7.33)and if accumulatereportergroups is set to true, then trade will beaggregated for each of these country groups. If set to false, trade will belisted for each partner country.7.5 currencyallowed values:default value if missing/not set:one of the currency 3-letter ISO codes supportedfrom GTT (see below)original currency (as reported)description: The following currencies are supported in GTT and can be used:Zen Innovations AG, Bernstrasse 99, CH-3122 Kehrsatzwww.globaltradetracker.com www.zen-innovations.comP a g e 5 of 14

GTT REST API User ralian DollarBahraini DinarBotswana PulaBelize DollarCanadian DollarSwiss FrancEgyptian PoundEthiopian BirrEuroBritish PoundGhanaian New CediHong Kong DollarIndian RupeeIsland KronJordanian DinarJapanese YenKenian ShillingMoroccan DirhamMacau PatacaMalaysian RinggitNorvegian KronerNew Zealand DollarQatari RialSaudi RiyalSingapore DollarThai BahtTaiwan DollarUS DollarCFA Franc BCEAOSouth African Rand7.6 customconversionrulesallowed values:true falsedefault value if missing/not set:falsedescription: If set to true, this option allows to apply custom conversion rules(defined on the options page in the GTT web application) for that userid orshared with that userid. If set to false, then only the standard conversionrules will be used to convert the reported quantities to the requestedquantity unit (chapter 7.23).7.7 dataelementsallowed values:default value if missing/not set:Comma or semicolon separated list of constants‘V’, ‘Q1’ or ‘Q2’V,Q1,Q2description: This parameter defines the data elements which should be includedin the report:Vmonetary valuesQ1primary quantityQ2secondary quantity7.8 decimalscaleallowed values:must be an integer, e.g. 1 or 2 or 3 etc.default value if missing/not set:0description: This parameter allows to specify the precision with which theresults are reported. The default of 0 will round decimals to an integervalue.Zen Innovations AG, Bernstrasse 99, CH-3122 Kehrsatzwww.globaltradetracker.com www.zen-innovations.comP a g e 6 of 14

GTT REST API User manual7.9 excludeintratradeallowed values:true falsedefault value if missing/not set:falsedescription: This parameter allows to exclude intra trade amongst a countrygroup. If several country groups are listed, then intra trade is removedwithin each individual group. In this case, the result will be externaltrade for each country group. E.g. if Nafta and EU28 are listed and thisparameter is set to true, then the result would be a data set listingexternal trade of EU28 with the world (including NAFTA) and external tradeof NAFTA with the world (including EU28). If set to false, then all reportedtrade is returned.7.10 fallbacktomirrordataallowed values:default value if missing/not set:true falsefalsedescription: This parameter allows to use the mirror data if the countryspecified in the ‘reporter’ parameter (see 7.33 below) does not provide thetrade data.7.11 fieldallowed values:default value if missing/not set:Comma or semicolon separated list of field ids.-description: This parameter allows to define the fieldsThe list of available report fields can be obtainedfields’ (see 4.44.4 above).If this parameter is not specified, the report willof fields.The names of the report JSON properties or CSV/XLSXthe ‘layout’ parameter (see 7.21 below).7.12 filterbysourceallowed values:default value if missing/not set:in the generated report.from the service ‘Reportcontain the default setcolumns is defined bySupported values areDEFAULTNATIONALEUROSTATCOMTRADE-description: This parameter defines the source of the data. For some Europeancountries there are two sources available (e.g. France, Germany, etc.).NATIONAL will provide the national statistics data while EUROSTAT willprovide the one from Eurostat.If this parameter is specified, only the reporting countries with thedefined data source will be used in the report. If the country does not havethe requested source available, it will be skipped.If the value DEFAULT is specified, the countries with the national datasource will be selected if they exit, otherwise the country with the otherdata source will be used.This parameter cannot be used together with the ‘source’ parameter (see 7.35below).PLEASE NOTE: This parameter is used only if the reporter code is specifiedwithout suffix (i.e. without e.g. “FR eurostat” or FR customs”.7.13 formatallowed values:JSON CSV XLSXZen Innovations AG, Bernstrasse 99, CH-3122 Kehrsatzwww.globaltradetracker.com www.zen-innovations.comP a g e 7 of 14

GTT REST API User manualdefault value if missing/not set:JSONdescription: This parameter defines the report format which is either JSON, XLSX(Microsoft Excel Open XML format) or CSV.7.14 fromallowed values:The start of the date period.This is a required parameter which must be inthe format YYYY-MM or YYYYMM. If yearly data isrequested (chapter 7.17) then the date can be inthe format YYYY.default value if missing/not set:(please note: one of either “from” or latestmonths” is required;if both parameters are set, “latestmonths” has precedence!)description: This parameter defines the start date for which data should beconsidered from7.15 hscodeallowed values:Comma or semicolon separated list of HS codes orcommodity group names. Sections can as well bereferenced as e.g. S01 for Section 01.default value if missing/not set:not alloweddescription: This parameter defines the hs codes for the data set. Please notethat you will need to have a valid subscription to access all of the listedHS codes whether they are directly listed or indirectly defined via yourcommodity groups.7.16 hslevelallowed values:the following values are allowed:-1explode to tariff level0do not explode2Explode to HS2 level4Explode to HS4 level6Explode to HS6 leveldefault value if missing/not set:0description: This parameter allows to explode the commodity codes defined inchapter 7.15 to the desired level. The codes in the commodity groups are notexploded if the parameter accumulatecommoditygroups is set to true.7.17 impexpallowed values:IEIETBTTRIRERIERTBRTTNINENIENTBNTTfor Imports plus Re-Importsfor Exports plus Re-Exportsfor Imports and Exports in the same reportfor trade balance (Exports – Imports)for total trade (Exports Imports)Re-Imports onlyRe-Exports onlyRe-Imports and Re-Exports in the same reportRe-Exports – Re-ImportsRe-Exports Re-ImportsNet ImportsNet ExportsNet Imports and Net Exports in the same reportNet Exports – Net ImportsNet Exports Net ImportsZen Innovations AG, Bernstrasse 99, CH-3122 Kehrsatzwww.globaltradetracker.com www.zen-innovations.comP a g e 8 of 14

GTT REST API User manualdefault value if missing/not set:not allowed.description: This parameter defines the tradeflow of interest.Please note:Only ONE value is allowed, i.e. the different values (even if they are all import or export) can NOT becombined in a call!7.18 includeotherpartnersInclude all other partner countries.allowed values:true falsedefault value if missing/not set:falsedescription: If partner countries are filtered using a list of countries orcountry groups, then it is possible to list all other countries as well byspecifying this parameter to true. If it is set to false, then only thecountries defined in the partner country parameters will be listed in thedata set. This parameter is typically used in conjunction withaccumulateotherpartners (chapter 7.2).7.19 langallowed values:en de fr zh CN es hi jadefault value if missing/not set:endescription: Defines the language used for the translation of the country namesand commodity descriptions.7.20 latestmonthsallowed values:default value if missing/not set:positive number from 1 to max 36 months(please note: one of either “from” or latestmonths” is required;if both parameters are set, “latestmonths” has precedence!)description: Selects the latest N months back from the current month – or if “to”is set: the latest N months back from “to”Example: to 2018-12 latestmonths 6. Will get data from 2018-06 to 2018-127.21 layoutallowed values:default briefdefault value if missing/not set:defaultdescription: If the ‘default’ layout is specified, the column headers in CSV andExcel formats and property values in the JSON format are verbose, humanreadable and translated to the language, defined in the ‘lang’ parameter.This layout is mainly intended to be used with the CSV and Excel formats,but can be used with JSON as well:"Trade flow", "Period Type", "Year", "Month", "Reporter”, "Partner", "HS Code", "CommodityDescription", "Currency", "Value", "Unit1", "Quantity1", "Unit2", "Quantity2"The ‘brief’ layout is mainly intended for the JSON format and will producethe fixed property names (or column headers):{"tradeFlow": "import","periodType": "MONTH","year": 2016,Zen Innovations AG, Bernstrasse 99, CH-3122 Kehrsatzwww.globaltradetracker.com www.zen-innovations.comP a g e 9 of 14

GTT REST API User manual"month": 1,"reporterCode": "BR","reporterName": "Brasilien","partnerName": "world","hsCode": "84","commodityDescriptionOriginal": "NUCLEAR REACTORS, BOILERS, MACHINERY ANDMECHANICAL APPLIANCES; PARTS THEREOF","commodityDescriptionTranslation": "KERNREAKTOREN, Kessel, Maschinen undmechanische Geräte DAVON","currency": "USD","value": 491008922,"unit1": "KG","quantity1": 25716978,"unit2": "KGL","quantity2": 25716978}The default set of the report fields can be overridden with the ‘field’parameter (see 7.11 above).Attention: If the ‘layout’ and ‘field’ parameters are missing and the JSONformat is requested, the report will be generated in a legacy JSON format,used in the versions 1.16.x and earlier.It is discouraged to skip the ‘layout’ parameter and use the the legacy JSONformat – it might not be supported in future.7.22 maxQ1allowed values:any numberdefault value if missing/not set:not useddescription: If specified, the generated report will contain only trade data withthe quantity1 numbers less or equal to the provided number.7.23 maxQ2allowed values:any numberdefault value if missing/not set:not useddescription: If specified, the generated report will contain only trade data withthe quantity2 numbers less or equal to the provided number.7.24 maxVallowed values:any numberdefault value if missing/not set:not useddescription: If specified, the generated report will contain only trade data withthe value numbers less or equal to the provided number.7.25 metadataallowed values:true falsedefault value if missing/not set:falsedescription: If set to true, metadata of the generated report will be added aswell.Attention: metadata is ONLY supported in JSON and XLSX format but not inCSV!7.26 minQ1allowed values:any numberdefault value if missing/not set:not usedZen Innovations AG, Bernstrasse 99, CH-3122 Kehrsatzwww.globaltradetracker.com www.zen-innovations.comP a g e 10 of 14

GTT REST API User manualdescription: If specified, the generated report will contain only trade data withthe quantity1 numbers greater or equal to the provided number.7.27 minQ2allowed values:any numberdefault value if missing/not set:not useddescription: If specified, the generated report will contain only trade data withthe quantity2 numbers greater or equal to the provided number.7.28 minVallowed values:any numberdefault value if missing/not set:not useddescription: If specified, the generated report will contain only trade data withthe value numbers greater or equal to the provided number.7.29 mirroredallowed values:true falsedefault value if missing/not set:falsedescription: This parameter defines whether the data should be generated as amirrored data set (set to true) or as reported (set to false)7.30 onlycompleteperiodsallowed values:true falsedefault value if missing/not set:truedescription: include only the periods for which all reporters have complete data(typically used for Eurostat data)7.31 partnerallowed values:Comma or semicolon separated list of Geonomalpha-2 codes or GTT country group names.see http://ec.europa.eu/eurostat/ramon/other documents/geonom/index.htm fora list of codes.default value if missing/not set:all countriesdescription: This parameter allows to filter the trade to only some partnercountries - which can be a list of countries (i.e. country codes) or one ormore country groups.7.32 periodtypeallowed values:Supported values are:MYQSYTDdefault value if missing/not set:monthly datayearly dataquarterly datasemester datayear-to-datecomputes period type based on values, or “M”Zen Innovations AG, Bernstrasse 99, CH-3122 Kehrsatzwww.globaltradetracker.com www.zen-innovations.comP a g e 11 of 14

GTT REST API User manualdescription: This parameter defines the level of time aggregates for the dataset.7.33 reporterRequired parameter.Comma or semicolon separated list of Geonom alpha-2 codes(http://ec.europa.eu/eurostat/ramon/other documents/geonom/index.htm) or GTTcountry group names.Some of the reporting countries have several sets of the trade data. It ispossib

3 Retrieving an API Token Please note: The REST API itself can be accessed only with a valid Token. With a valid GTT userid you can retrieve an API Token to access the REST API which will be valid for 14 days. This Token must then be sent in all subsequent calls to the API, either in the http header request (the