Trustip
HomeFeaturesAboutPricing
  • Get Started
  • Code Examples
    • PHP
    • Laravel
    • Node js
    • JavaScript
  • API Rate Limits
Powered by GitBook
On this page

Was this helpful?

  1. Code Examples

Node js

To call this API using Node.js, you can use the built-in http module or an external library like axios. Here is an example using the http module:


const https = require('https');

const apiKey = 'YOUR_API_KEY';
const ipAddress = 'IP_ADDRESS';

const options = {
  method: 'GET',
  hostname: 'api.trustip.io',
  path: `/v1/check.php?key=${apiKey}&ip=${ipAddress}`
};

const req = https.request(options, res => {
  let data = '';
  res.on('data', chunk => {
    data += chunk;
  });
  res.on('end', () => {
    console.log(data);
  });
});

req.on('error', error => {
  console.error(error);
});

req.end();

Replace YOUR_API_KEY and IP_ADDRESS with your actual API key and IP address, respectively. This code sends a GET request to the API endpoint and logs the response data to the console.

PreviousLaravelNextJavaScript

Last updated 1 year ago

Was this helpful?