Installation

For Node.js

npm install odin-sdk --save

For Browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: “Module not found: Error: Cannot resolve module”. Most certainly, you should disable the AMD loader:

module: {
  rules: [
    {
      parser: {
        amd: false,
      },
    },
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

var Odin = require("odin-sdk");

var defaultClient = Odin.ApiClient.instance;
// Configure API key authorization: ApiKeyAuth
var ApiKeyAuth = defaultClient.authentications["ApiKeyAuth"];
ApiKeyAuth.apiKey = "YOUR API KEY";
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuth.apiKeyPrefix['X-API-Key'] = "Token"

// search exposed buckets (using pagination)
var api = new OdinApis.ExposedBucketsApi();
var buckets = [];

for (var i = 0; i < 10; i++) {
  var query = new OdinApis.ExposedCountRequest();
  query.query = "name:'lit-link-prd.appspot.com'";
  var callback = function (error, data, response) {
    if (error) {
      console.error(error);
    } else {
      buckets.push(data);
    }
  };
  api.exposedBucketsCountPost(query, callback);
  console.log(JSON.stringify(buckets));
}

// search files in a exposed bucket
var api = new OdinApis.ExposedFilesApi();
var query = {
  query: "provider: aws",
  limit: 1,
  sortDir: "desc",
  sortBy: "files",
};
var callback = function (error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log(JSON.stringify(data));
  }
};
api.exposedFilesSearchPost(query, callback);

// search hosts
var api = new OdinApis.ExposedHostsApi();
var query = {
  query:
    '(last_updated_at:["2024-07-08T02:41:15.528Z" TO *] AND services.port:80) OR asn.number:AS63949',
  limit: 1,
};
var callback = function (error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log(JSON.stringify(data));
  }
};
api.exposedHostsSearchPost(query, callback);

Authorization

API Key Authentication

  • Type: API key

  • API key parameter name: X-API-Key

  • Location: HTTP header

Support and Contribution

Thank you for using the Odin SDK for Javascript. If you encounter any issues, find a bug, or want to contribute, feel free to open an issue or submit a pull request on our GitHub Repository. Your feedback and contributions are highly appreciated!

For more information about our other projects and services, visit our website at https://odin.io.