|
| 1 | +# BigDataCloud NodeJS API Client |
| 2 | + |
| 3 | + |
| 4 | +A NodeJS 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 | +## Installation |
| 39 | + |
| 40 | +`npm install @bigdatacloudapi/client` |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +## Example usage |
| 45 | + |
| 46 | +```javascript |
| 47 | + const client = require('@bigdatacloudapi/client')('XXX'); // XXX being your api key found at: https://www.bigdatacloud.net/customer/account |
| 48 | + |
| 49 | + /* |
| 50 | + * All api endpoints can be accessed via magic methods in the following camelised format: |
| 51 | + * method | endpoint |
| 52 | + * For example: an asynchronous "GET" call to the "ip-geolocation-full" endpoint would be: client.getIpGeolocationFull(); |
| 53 | + * All endpoints return a promise |
| 54 | + */ |
| 55 | + |
| 56 | + //Asynchronous example using 'then': |
| 57 | + client |
| 58 | + .getIpGeolocationFull({ip:'8.8.8.8'}) |
| 59 | + .then(function(jsonResult) { |
| 60 | + console.log('Asynchronous "then" result:',jsonResult); |
| 61 | + }) |
| 62 | + .catch(function(error) { |
| 63 | + console.error('Asynchronous "then" error:', error); |
| 64 | + }); |
| 65 | + |
| 66 | + //Asynchronous example using 'await': |
| 67 | + (async function() { |
| 68 | + try { |
| 69 | + var jsonResult = await client.getIpGeolocationFull({ip:'8.8.8.8'}); |
| 70 | + console.log('Asynchronous "await" result:',jsonResult); |
| 71 | + } catch (error) { |
| 72 | + console.error('Asynchronous "await" error:', error); |
| 73 | + } |
| 74 | + })(); |
| 75 | + |
| 76 | +</script> |
| 77 | +``` |
| 78 | + |
| 79 | + |
| 80 | +## Example output |
| 81 | + |
| 82 | +```javascript |
| 83 | +{ |
| 84 | + "ip": "8.8.8.8", |
| 85 | + "country": { |
| 86 | + "isoAlpha2": "US", |
| 87 | + "isoAlpha3": "USA", |
| 88 | + "m49Code": 840, |
| 89 | + "isoName": "United States of America (the)", |
| 90 | + "isoAdminLanguages": [ |
| 91 | + { |
| 92 | + "isoAlpha3": "eng", |
| 93 | + "isoAlpha2": "en", |
| 94 | + "isoName": "English" |
| 95 | + } |
| 96 | + ], |
| 97 | + "unRegion": "Americas/Northern America", |
| 98 | + "currency": { |
| 99 | + "numericCode": 840, |
| 100 | + "code": "USD", |
| 101 | + "name": "US Dollar", |
| 102 | + "minorUnits": 2 |
| 103 | + }, |
| 104 | + "wbRegion": { |
| 105 | + "id": "NAC", |
| 106 | + "iso2Code": "XU", |
| 107 | + "value": "North America" |
| 108 | + }, |
| 109 | + "wbIncomeLevel": { |
| 110 | + "id": "HIC", |
| 111 | + "iso2Code": "XD", |
| 112 | + "value": "High income" |
| 113 | + }, |
| 114 | + "callingCode": "1", |
| 115 | + "countryFlagEmoji": "🇺🇸" |
| 116 | + }, |
| 117 | + "location": { |
| 118 | + "isoPrincipalSubdivision": "California", |
| 119 | + "isoPrincipalSubdivisionCode": "US-CA", |
| 120 | + "city": "Mountain View", |
| 121 | + "postcode": "94043", |
| 122 | + "latitude": 37.42, |
| 123 | + "longitude": -122.09, |
| 124 | + "timeZone": { |
| 125 | + "ianaTimeId": "America/Los_Angeles", |
| 126 | + "displayName": "(UTC-08:00) Pacific Time (US & Canada)", |
| 127 | + "effectiveTimeZoneFull": "Pacific Daylight Time", |
| 128 | + "effectiveTimeZoneShort": "PDT", |
| 129 | + "UtcOffsetSeconds": -25200, |
| 130 | + "UtcOffset": "-07", |
| 131 | + "isDaylightSavingTime": true, |
| 132 | + "localTime": "2019-04-06T04:06:39.1691744" |
| 133 | + } |
| 134 | + }, |
| 135 | + "lastUpdated": "2019-04-06T09:09:36.1877959Z", |
| 136 | + "network": { |
| 137 | + "registry": "ARIN", |
| 138 | + "registryStatus": "assigned", |
| 139 | + "registeredCountry": "US", |
| 140 | + "registeredCountryName": "United States of America (the)", |
| 141 | + "organisation": "Google LLC", |
| 142 | + "isReachableGlobally": true, |
| 143 | + "isBogon": false, |
| 144 | + "bgpPrefix": "8.8.8.0/24", |
| 145 | + "bgpPrefixNetworkAddress": "8.8.8.0", |
| 146 | + "bgpPrefixLastAddress": "8.8.8.255", |
| 147 | + "totalAddresses": 256, |
| 148 | + "carriers": [ |
| 149 | + { |
| 150 | + "asn": "AS15169", |
| 151 | + "asnNumeric": 15169, |
| 152 | + "organisation": "Google LLC", |
| 153 | + "name": "GOOGLE", |
| 154 | + "registry": "ARIN", |
| 155 | + "registeredCountry": "US", |
| 156 | + "registeredCountryName": "United States of America (the)", |
| 157 | + "registrationDate": "2000-03-30", |
| 158 | + "registrationLastChange": "2012-02-25", |
| 159 | + "totalIpv4Addresses": 8698103, |
| 160 | + "totalIpv4Prefixes": 435, |
| 161 | + "totalIpv4BogonPrefixes": 0, |
| 162 | + "rank": 53, |
| 163 | + "rankText": "#53 out of 62,872" |
| 164 | + } |
| 165 | + ], |
| 166 | + "viaCarriers": [ |
| 167 | + { |
| 168 | + "asn": "AS7018", |
| 169 | + "asnNumeric": 7018, |
| 170 | + "organisation": "ATT Services Inc.", |
| 171 | + "registeredCountry": "US", |
| 172 | + "registeredCountryName": "United States of America (the)", |
| 173 | + "rank": 2 |
| 174 | + }, |
| 175 | + /*........*/ |
| 176 | + { |
| 177 | + "asn": "AS31019", |
| 178 | + "asnNumeric": 31019, |
| 179 | + "organisation": "Paulus M. Hoogsteder trading as Meanie", |
| 180 | + "registeredCountry": "NL", |
| 181 | + "registeredCountryName": "Netherlands (the)", |
| 182 | + "rank": 51153 |
| 183 | + } |
| 184 | + ] |
| 185 | + }, |
| 186 | + "confidence": "low", |
| 187 | + "confidenceArea": [ |
| 188 | + { |
| 189 | + "latitude": 18.0256672, |
| 190 | + "longitude": -66.5275345 |
| 191 | + }, |
| 192 | + /*........*/ |
| 193 | + { |
| 194 | + "latitude": 18.0256672, |
| 195 | + "longitude": -66.5275345 |
| 196 | + } |
| 197 | + ], |
| 198 | + "securityThreat": "unknown", |
| 199 | + "hazardReport": { |
| 200 | + "isKnownAsTorServer": false, |
| 201 | + "isKnownAsProxy": false, |
| 202 | + "isKnownAsMailServer": false, |
| 203 | + "isKnownAsPublicRouter": false, |
| 204 | + "isBogon": false, |
| 205 | + "isUnreachable": false |
| 206 | + } |
| 207 | +} |
| 208 | +``` |
0 commit comments