|
| 1 | +#BigDataCloud Python API Client |
| 2 | + |
| 3 | + |
| 4 | +A Python client for connecting to the API services provided by[BigDataCloud](https://www.bigdatacloud.net) |
| 5 | + |
| 6 | + |
| 7 | +##What API services does[BigDataCloud](https://www.bigdatacloud.net) offer? |
| 8 | + |
| 9 | +BigDataCloud offers a range of extremely useful and fast APIs that can be utilised in both backend and frontend scenarios. |
| 10 | +From validating customer input live to the next generation of IP Geolocation technology, BigDataCloud has an API suitable to your needs. |
| 11 | + |
| 12 | +For a full list of APIs, visit our[documentation area](https://www.bigdatacloud.net/ip-geolocation-apis). |
| 13 | + |
| 14 | +You can access any and all BigDataCloud APIs with a free API Key. |
| 15 | +To get your API Key, just access your account and retrieve it from your[Account Dashboard](https://www.bigdatacloud.net/customer/account). |
| 16 | +If you are not yet a customer, it is completely free to join. |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +##Documentation |
| 21 | + |
| 22 | +For documentation specific to this api client, please read below. |
| 23 | +For more specific documentation to the APIs available, including endpoints, request and response data, please visit our[documentation area](https://www.bigdatacloud.net/ip-geolocation-apis). |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +##Authentication / Identification |
| 28 | + |
| 29 | +To use this API client you must have a BigDataCloud API Key. |
| 30 | +To get your personal key, just access your account and retrieve it from your[Account Dashboard](https://www.bigdatacloud.net/customer/account). |
| 31 | +If you are not yet a customer, it is completely free to join. |
| 32 | + |
| 33 | +Simply provide this key when initiating the api client, and it will be included in all requests to the BigDataCloud API Server. |
| 34 | +See the example below. |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +##Python 2.x Installation |
| 39 | + |
| 40 | +`pip install bigdatacloudapi-client` |
| 41 | + |
| 42 | + |
| 43 | +##Python 3.x Installation |
| 44 | + |
| 45 | +`pip3 install bigdatacloudapi-client` |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +##Example usage |
| 50 | + |
| 51 | +```python |
| 52 | +import bigdatacloudapi |
| 53 | + |
| 54 | +apiKey='XXX'#XXX being your api key found at: https://www.bigdatacloud.net/customer/account |
| 55 | + |
| 56 | +client= bigdatacloudapi.Client(apiKey) |
| 57 | + |
| 58 | +resultObject,httpResponseCode= client.getIpGeolocationFull({"ip":"8.8.8.8"}) |
| 59 | + |
| 60 | +print('HTTP Response Code:',httpResponseCode) |
| 61 | +print('Result:',resultObject['ip']) |
| 62 | +print('Result:',resultObject['ip']) |
| 63 | +``` |
| 64 | + |
| 65 | + |
| 66 | +##Example output |
| 67 | + |
| 68 | +```python |
| 69 | +{ |
| 70 | +"ip":"8.8.8.8", |
| 71 | +"country": { |
| 72 | +"isoAlpha2":"US", |
| 73 | +"isoAlpha3":"USA", |
| 74 | +"m49Code":840, |
| 75 | +"isoName":"United States of America (the)", |
| 76 | +"isoAdminLanguages": [ |
| 77 | + { |
| 78 | +"isoAlpha3":"eng", |
| 79 | +"isoAlpha2":"en", |
| 80 | +"isoName":"English" |
| 81 | + } |
| 82 | + ], |
| 83 | +"unRegion":"Americas/Northern America", |
| 84 | +"currency": { |
| 85 | +"numericCode":840, |
| 86 | +"code":"USD", |
| 87 | +"name":"US Dollar", |
| 88 | +"minorUnits":2 |
| 89 | + }, |
| 90 | +"wbRegion": { |
| 91 | +"id":"NAC", |
| 92 | +"iso2Code":"XU", |
| 93 | +"value":"North America" |
| 94 | + }, |
| 95 | +"wbIncomeLevel": { |
| 96 | +"id":"HIC", |
| 97 | +"iso2Code":"XD", |
| 98 | +"value":"High income" |
| 99 | + }, |
| 100 | +"callingCode":"1", |
| 101 | +"countryFlagEmoji":"🇺🇸" |
| 102 | + }, |
| 103 | +"location": { |
| 104 | +"isoPrincipalSubdivision":"California", |
| 105 | +"isoPrincipalSubdivisionCode":"US-CA", |
| 106 | +"city":"Mountain View", |
| 107 | +"postcode":"94043", |
| 108 | +"latitude":37.42, |
| 109 | +"longitude":-122.09, |
| 110 | +"timeZone": { |
| 111 | +"ianaTimeId":"America/Los_Angeles", |
| 112 | +"displayName":"(UTC-08:00) Pacific Time (US & Canada)", |
| 113 | +"effectiveTimeZoneFull":"Pacific Daylight Time", |
| 114 | +"effectiveTimeZoneShort":"PDT", |
| 115 | +"UtcOffsetSeconds":-25200, |
| 116 | +"UtcOffset":"-07", |
| 117 | +"isDaylightSavingTime": true, |
| 118 | +"localTime":"2019-04-06T04:06:39.1691744" |
| 119 | + } |
| 120 | + }, |
| 121 | +"lastUpdated":"2019-04-06T09:09:36.1877959Z", |
| 122 | +"network": { |
| 123 | +"registry":"ARIN", |
| 124 | +"registryStatus":"assigned", |
| 125 | +"registeredCountry":"US", |
| 126 | +"registeredCountryName":"United States of America (the)", |
| 127 | +"organisation":"Google LLC", |
| 128 | +"isReachableGlobally": true, |
| 129 | +"isBogon": false, |
| 130 | +"bgpPrefix":"8.8.8.0/24", |
| 131 | +"bgpPrefixNetworkAddress":"8.8.8.0", |
| 132 | +"bgpPrefixLastAddress":"8.8.8.255", |
| 133 | +"totalAddresses":256, |
| 134 | +"carriers": [ |
| 135 | + { |
| 136 | +"asn":"AS15169", |
| 137 | +"asnNumeric":15169, |
| 138 | +"organisation":"Google LLC", |
| 139 | +"name":"GOOGLE", |
| 140 | +"registry":"ARIN", |
| 141 | +"registeredCountry":"US", |
| 142 | +"registeredCountryName":"United States of America (the)", |
| 143 | +"registrationDate":"2000-03-30", |
| 144 | +"registrationLastChange":"2012-02-25", |
| 145 | +"totalIpv4Addresses":8698103, |
| 146 | +"totalIpv4Prefixes":435, |
| 147 | +"totalIpv4BogonPrefixes":0, |
| 148 | +"rank":53, |
| 149 | +"rankText":"#53 out of 62,872" |
| 150 | + } |
| 151 | + ], |
| 152 | +"viaCarriers": [ |
| 153 | + { |
| 154 | +"asn":"AS7018", |
| 155 | +"asnNumeric":7018, |
| 156 | +"organisation":"ATT Services Inc.", |
| 157 | +"registeredCountry":"US", |
| 158 | +"registeredCountryName":"United States of America (the)", |
| 159 | +"rank":2 |
| 160 | + }, |
| 161 | +/*........*/ |
| 162 | + { |
| 163 | +"asn":"AS31019", |
| 164 | +"asnNumeric":31019, |
| 165 | +"organisation":"Paulus M. Hoogsteder trading as Meanie", |
| 166 | +"registeredCountry":"NL", |
| 167 | +"registeredCountryName":"Netherlands (the)", |
| 168 | +"rank":51153 |
| 169 | + } |
| 170 | + ] |
| 171 | + }, |
| 172 | +"confidence":"low", |
| 173 | +"confidenceArea": [ |
| 174 | + { |
| 175 | +"latitude":18.0256672, |
| 176 | +"longitude":-66.5275345 |
| 177 | + }, |
| 178 | +/*........*/ |
| 179 | + { |
| 180 | +"latitude":18.0256672, |
| 181 | +"longitude":-66.5275345 |
| 182 | + } |
| 183 | + ], |
| 184 | +"securityThreat":"unknown", |
| 185 | +"hazardReport": { |
| 186 | +"isKnownAsTorServer": false, |
| 187 | +"isKnownAsProxy": false, |
| 188 | +"isKnownAsMailServer": false, |
| 189 | +"isKnownAsPublicRouter": false, |
| 190 | +"isBogon": false, |
| 191 | +"isUnreachable": false |
| 192 | + } |
| 193 | +} |
| 194 | +``` |