{"_id":"@anuraio/anura-sdk","_rev":"8-27eb3544829c27a54343cf0e6a81710f","name":"@anuraio/anura-sdk","dist-tags":{"latest":"3.0.1"},"versions":{"0.0.1":{"name":"@anuraio/anura-sdk","version":"0.0.1","author":{"name":"Xavier Mejia"},"license":"GPL-3.0","_id":"@anuraio/anura-sdk@0.0.1","maintainers":[{"name":"anurajoe","email":"jrodichok@anura.io"}],"dist":{"shasum":"61887bea34ec59dd1d9ec64be49ed6329096d317","tarball":"https://registry.npmjs.org/@anuraio/anura-sdk/-/anura-sdk-0.0.1.tgz","fileCount":2,"integrity":"sha512-jnhlDwviRuYGCb0jqMy8fsEto8M5fndmOo3fXiCp7fAgOSUz5ua2W/hM2bXjQs+CIy6kr3g+aNI285heqWd+bQ==","signatures":[{"sig":"MEUCIGfowkG/rKkB4MOL+rkcg5Ud48PYl190oGDlLitljkcLAiEA/xYfyUnhzCcGo4hc1tOLH+YGcKBkK47eTOzKkYFSFOQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6259},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"a352b578874c7e83b22a1451011dd5e265ebf0b2","scripts":{"test":"jest","build":"tsc","start":"tsx src/test.ts"},"_npmUser":{"name":"anurajoe","email":"jrodichok@anura.io"},"_npmVersion":"10.8.2","description":"Anura SDK for JavaScript","directories":{},"_nodeVersion":"18.20.5","_hasShrinkwrap":false,"devDependencies":{"tsx":"4.19.2","jest":"29.7.0","babel-jest":"29.7.0","typescript":"5.7.2","@babel/core":"7.26.0","@types/jest":"29.5.14","@types/node":"22.9.1","@babel/preset-env":"7.26.0","@babel/preset-typescript":"7.26.0"},"_npmOperationalInternal":{"tmp":"tmp/anura-sdk_0.0.1_1734042813878_0.9655463873914365","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"name":"@anuraio/anura-sdk","version":"1.0.0","keywords":["ad fraud","affiliate fraud detection","click-fraud","spam"],"author":{"name":"Xavier Mejia"},"license":"GPL-3.0","_id":"@anuraio/anura-sdk@1.0.0","maintainers":[{"name":"anurajoe","email":"jrodichok@anura.io"}],"dist":{"shasum":"d0dbcef9a2f06bc5d72fc06635448adf288c705d","tarball":"https://registry.npmjs.org/@anuraio/anura-sdk/-/anura-sdk-1.0.0.tgz","fileCount":2,"integrity":"sha512-XqfcvJR0bFAjwdknMkMfmkFRV9sK/kXaYbQBEayS1cAR8SQE9fagaZZHKYLGtGSQPCuY0+6niSMus6uH6guueQ==","signatures":[{"sig":"MEUCIQCxEu3j84UlPIOQYOOwbyUriRudv8LyixTooTUDW/jOJwIgSXabddRWhQZjFImar/DykxQx2ixDSmx3QRnNReUpb9U=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6361},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"21017abdf4dab1385d491edd559f7f738873ac5a","scripts":{"test":"jest","build":"tsc","start":"tsx src/test.ts"},"_npmUser":{"name":"anurajoe","email":"jrodichok@anura.io"},"_npmVersion":"10.8.2","description":"Anura SDK for JavaScript","directories":{},"_nodeVersion":"18.20.5","_hasShrinkwrap":false,"devDependencies":{"tsx":"4.19.2","jest":"29.7.0","babel-jest":"29.7.0","typescript":"5.7.2","@babel/core":"7.26.0","@types/jest":"29.5.14","@types/node":"22.9.1","@babel/preset-env":"7.26.0","@babel/preset-typescript":"7.26.0"},"_npmOperationalInternal":{"tmp":"tmp/anura-sdk_1.0.0_1734043302391_0.11103118880933582","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@anuraio/anura-sdk","version":"1.0.1","keywords":["ad fraud","affiliate fraud detection","click-fraud","spam"],"author":{"name":"Xavier Mejia"},"license":"GPL-3.0","_id":"@anuraio/anura-sdk@1.0.1","maintainers":[{"name":"anurajoe","email":"jrodichok@anura.io"},{"name":"xmejia-anura","email":"xmejia@anura.io"},{"name":"bread_pc","email":"vincentrkahn@gmail.com"}],"dist":{"shasum":"b08ca5d1b762b65244efd6b24af510b05779751c","tarball":"https://registry.npmjs.org/@anuraio/anura-sdk/-/anura-sdk-1.0.1.tgz","fileCount":23,"integrity":"sha512-9ZRxHIk3DeFPBcYCJormpcFHYxAOn2uW9F6yzxqelI0kuUeG3zK1njOudqvIF1xB0hw1f7dhn1SWuUhoNXUgzA==","signatures":[{"sig":"MEUCIQCiQvAXntN0ekRrJgYzuFlw+K7j9PZzfabw4huAqoaRPgIgbDIH7eiPfcE5sWxASDAMPnGLvO5XVfy3jSHGxGsnEto=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25368},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"a4e5d7102c1830579ba0baa58ae63aa2c20ce3f6","scripts":{"test":"jest","build":"tsc","start":"tsx src/test.ts"},"_npmUser":{"name":"anurajoe","email":"jrodichok@anura.io"},"_npmVersion":"10.8.2","description":"Anura SDK for JavaScript","directories":{},"_nodeVersion":"18.20.5","_hasShrinkwrap":false,"devDependencies":{"tsx":"4.19.2","jest":"29.7.0","babel-jest":"29.7.0","typescript":"5.7.2","@babel/core":"7.26.0","@types/jest":"29.5.14","@types/node":"22.9.1","@babel/preset-env":"7.26.0","@babel/preset-typescript":"7.26.0"},"_npmOperationalInternal":{"tmp":"tmp/anura-sdk_1.0.1_1734112809678_0.39125096000309845","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@anuraio/anura-sdk","version":"2.0.0","keywords":["ad fraud","affiliate fraud detection","click-fraud","spam"],"author":{"name":"Xavier Mejia"},"license":"GPL-3.0","_id":"@anuraio/anura-sdk@2.0.0","maintainers":[{"name":"anurajoe","email":"jrodichok@anura.io"},{"name":"xmejia-anura","email":"xmejia@anura.io"},{"name":"bread_pc","email":"vincentrkahn@gmail.com"}],"dist":{"shasum":"09f44bcd920a313487e5202b9ce1a5a04c05dc5d","tarball":"https://registry.npmjs.org/@anuraio/anura-sdk/-/anura-sdk-2.0.0.tgz","fileCount":20,"integrity":"sha512-F3KDMg917kZ3zTgqfbDKt4j6MJ2a8VtnO99xffjdY2rjZzGGNOU2Di7hZ7fnOl0I5bVn9vsitWvCIl6sg1/jBA==","signatures":[{"sig":"MEQCIE2euW5TkuoBotAOOS6zRjbaym1GkEU1mEtVl/WYsGp5AiBFqLYSGu/NxGNGk4wWxk9CNth0LCKhYIGv3Ocr1aBJHA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24270},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"a6dd926b5e878cfb3204da3dabb5cda147412080","scripts":{"test":"jest","build":"tsc","start":"tsx src/test.ts"},"_npmUser":{"name":"anurajoe","email":"jrodichok@anura.io"},"_npmVersion":"10.8.2","description":"Anura SDK for JavaScript","directories":{},"_nodeVersion":"18.20.6","_hasShrinkwrap":false,"devDependencies":{"tsx":"4.19.2","jest":"29.7.0","babel-jest":"29.7.0","typescript":"5.7.2","@babel/core":"7.26.0","@types/jest":"29.5.14","@types/node":"22.9.1","@babel/preset-env":"7.26.0","@babel/preset-typescript":"7.26.0"},"_npmOperationalInternal":{"tmp":"tmp/anura-sdk_2.0.0_1739480989275_0.9019727262188253","host":"s3://npm-registry-packages-npm-production"}},"3.0.0":{"name":"@anuraio/anura-sdk","version":"3.0.0","keywords":["ad fraud","affiliate fraud detection","click-fraud","spam"],"author":{"name":"Xavier Mejia"},"license":"GPL-3.0","_id":"@anuraio/anura-sdk@3.0.0","maintainers":[{"name":"anurajoe","email":"jrodichok@anura.io"},{"name":"xmejia-anura","email":"xmejia@anura.io"},{"name":"bread_pc","email":"vincentrkahn@gmail.com"}],"dist":{"shasum":"0a76cff870c81e484e2f9f2945edfc561867127a","tarball":"https://registry.npmjs.org/@anuraio/anura-sdk/-/anura-sdk-3.0.0.tgz","fileCount":23,"integrity":"sha512-sE0aFqe7JG8UGkO4BR1c2ntS4pmKY/OaU7ijhguoD/lPhuCYOkcn1zepJYDhF8t0TYIU3DBiNWCaLjvcqY1ibw==","signatures":[{"sig":"MEUCIDQD0W8OcOE3wlLGdWTuq7PXaBIpAU4ThtlB/J2tUsvfAiEA9x9JTIK9rahqPaKhSRMCf7BG3GYrCuqi3RKghBKt26w=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27718},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"8d0c3a6fbacde26c0ba26a0bd4d6e91fdf21d196","scripts":{"test":"vitest --coverage","build":"tsc","start":"tsx src/test.ts","test:unit":"vitest .unit.test.ts","test:integration":"vitest .integration.test.ts"},"_npmUser":{"name":"anurajoe","email":"jrodichok@anura.io"},"_npmVersion":"10.8.2","description":"Anura SDK for JavaScript","directories":{},"_nodeVersion":"18.20.7","_hasShrinkwrap":false,"devDependencies":{"tsx":"4.19.3","vitest":"3.0.6","typescript":"5.7.3","@types/node":"22.9.1","@vitest/coverage-v8":"3.0.6"},"_npmOperationalInternal":{"tmp":"tmp/anura-sdk_3.0.0_1741273501680_0.12545268236367924","host":"s3://npm-registry-packages-npm-production"}},"3.0.1":{"name":"@anuraio/anura-sdk","version":"3.0.1","description":"Anura SDK for JavaScript","main":"dist/index.js","types":"dist/index.d.ts","keywords":["ad fraud","affiliate fraud detection","click-fraud","spam"],"scripts":{"start":"tsx src/test.ts","build":"tsc","test":"vitest --coverage","test:unit":"vitest .unit.test.ts","test:integration":"vitest .integration.test.ts"},"author":{"name":"Xavier Mejia"},"license":"GPL-3.0","devDependencies":{"@types/node":"22.9.1","@vitest/coverage-v8":"3.0.6","tsx":"4.19.3","typescript":"5.7.3","vitest":"3.0.6"},"_id":"@anuraio/anura-sdk@3.0.1","gitHead":"a7b40287c5a0f35174db1009d64d854f6070078f","_nodeVersion":"18.20.7","_npmVersion":"10.8.2","dist":{"integrity":"sha512-pJKBln1nKgNE1eTzsKA7ww22+ktrB4ZWKgTQDXVajug1g0UEdYp4srLwuoiLPIVfmohG61pLw2PxyuzRHlAnhA==","shasum":"f360c4878f297dbd60edd737cbde3ac4a1270017","tarball":"https://registry.npmjs.org/@anuraio/anura-sdk/-/anura-sdk-3.0.1.tgz","fileCount":23,"unpackedSize":27610,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCZxwTAw9petUaytsSjC80W4XOQfz36DIqGJmqH7rEaHwIhAPWWNJE1xeMfrC0icIlcR7dcAfCX7jPBUgZXE2VnYIOV"}]},"_npmUser":{"name":"anurajoe","email":"jrodichok@anura.io"},"directories":{},"maintainers":[{"name":"anurajoe","email":"jrodichok@anura.io"},{"name":"xmejia-anura","email":"xmejia@anura.io"},{"name":"bread_pc","email":"vincentrkahn@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/anura-sdk_3.0.1_1742841226077_0.7663981994456563"},"_hasShrinkwrap":false}},"time":{"created":"2024-12-12T22:33:33.808Z","modified":"2025-03-24T18:33:46.495Z","0.0.1":"2024-12-12T22:33:34.059Z","1.0.0":"2024-12-12T22:41:42.554Z","1.0.1":"2024-12-13T18:00:09.925Z","2.0.0":"2025-02-13T21:09:49.500Z","3.0.0":"2025-03-06T15:05:01.873Z","3.0.1":"2025-03-24T18:33:46.282Z"},"author":{"name":"Xavier Mejia"},"license":"GPL-3.0","keywords":["ad fraud","affiliate fraud detection","click-fraud","spam"],"description":"Anura SDK for JavaScript","maintainers":[{"name":"anurajoe","email":"jrodichok@anura.io"},{"name":"xmejia-anura","email":"xmejia@anura.io"},{"name":"bread_pc","email":"vincentrkahn@gmail.com"}],"readme":"# Anura SDK for Node.js\nThe **Anura SDK for Node.js** makes it easy for developers to utilize Anura Direct within their Node.js projects, and begin analyzing their traffic. You can get started in minutes by installing the SDK from [npm](https://www.npmjs.com/).\n\n## Getting Started\n1. **Have an open active account with Anura**. You an see more about Anura's offerings [here.](https://www.anura.io/product#plans-pricing)\n2. **Minimum Requirements** - To use the SDK, you will need **Node >=18**.\n3. **Install the SDK**\n4. View our [**Quick Examples**](#quick-examples) to immediately begin using the SDK!\n\n## Installing the SDK\nYou can install the SDK with `npm` by running the following:\n```sh\nnpm install @anuraio/anura-sdk\n```\n\n## Quick Examples\n\n### Create the Anura Direct Client\n```javascript\nimport { AnuraDirect, AdditionalData, AnuraClientError, AnuraServerError } from '@anuraio/anura-sdk'; // ESModule Import\nconst { AnuraDirect, AdditionalData, AnuraClientError, AnuraServerError } = require('@anuraio/anura-sdk'); // CommonJS Import\n\nconst direct = new AnuraDirect('your-instance');\n```\n\n### Set additional data for Anura Direct\n```javascript\n/**\n * To send additional data to Anura Direct, use the AdditionalData class. \n * We will provide this object when calling direct.getResult()\n */\nconst additionalData = new AdditionalData();\nadditionalData.addElement(1, 'your-data-value');\n```\n\n### Updating additional data at a specific index\n```javascript\n/**\n * To update an element of additional data at a specific index,\n * simply add the element again but with a new value.\n */\nconst indexToUpdate = 1;\nadditionalData.addElement(indexToUpdate, 'your-new-data-value');\n```\n\n### Removing an element from additional data\n```javascript\nconst indexToRemove = 1;\nadditionalData.removeElement(indexToRemove);\n```\n\n### Get a result from Anura Direct\n```javascript\n(async function() {\n  const direct = new AnuraDirect('your-instance-id');\n  try {\n    const result = await direct.getResult({\n      ipAddress: 'visitors-ip-address',\n      userAgent: 'visitors-user-agent', // optional\n      app: 'visitors-app-package-id',   // optional\n      device: 'visitors-device-id',     // optional\n      source: 'your-source-value',      // optional\n      campaign: 'your-campaign-value',  // optional\n      additionalData: additionalData,   // optional\n    });\n\n    console.log(result);\n  } catch (error) {\n      if (error instanceof AnuraClientError) {\n        // Handle 4XX responses here.\n      } else if (error instanceof AnuraServerError) {\n        // Handle 5XX responses here.\n      } else {\n        // Handle any other type of error thrown here.\n      }\n  }\n})();\n```\n\n## API Reference\n### AnuraDirect\nCan get results from Anura Direct. These results are fetched during Direct's `/direct.json` API endpoint.\n\n#### Methods\n**`async getResult(options: GetResultOptions): Promise<DirectResult>`**\n- Gets a result from Anura Direct. Throws an exception if an error was received from Anura Direct.\n- Exceptions thrown:\n  - `AnuraClientError`: Thrown if a 4XX response is returned from Anura Direct\n  - `AnuraServerError`: Thrown if a 5XX response is returned from Anura Direct\n  - `AnuraError`: General exception that represents any other type of error that occurred while fetching from Anura Direct.\n\n  `GetResultOptions` Parameters:\n  | Name | Type | Description | Required |\n  | ---- | ---- | ----------- | -------- |\n  | `ipAddress` | `string` | The IP address of your visitor. Both IPv4 & IPv6 addresses are supported. | Yes |\n  | `userAgent` | `string\\|null` | The user agent string of your visitor |  |\n  | `app` | `string\\|null` | The application package identifier of your visitor (when available.) | |\n  | `device` | `string\\|null` | The device identifer of your visitor (when available.) | |\n  | `source` | `string\\|null` | A variable, declared by you, to identify \"source\" traffic within Anura's dashboard interface. | |\n  | `campaign` | `string\\|null` | A subset variable of \"source\", declared by you, to identify \"campaign\" traffic within Anura's dashboard interface. | |\n  | `additionalData`| `AdditionalData\\|null` | Additional Data gives you the ability to pass in select points of data with your direct requests, essentially turning Anura into \"your database for transactional data\". | |\n\n**`get instance(): string`**\n- Returns the instance you have set within the `AnuraDirect` client.\n\n**`set instance(instance: string): void`**\n- Sets the Instance ID of the `AnuraDirect` client to the `instance` value passed.\n\n**`get useHttps(): boolean`**\n- Returns whether or you're currently using the **HTTPS** when calling the Anura Direct API. If false, you are using **HTTP** instead.\n\n**`set useHttps(useHttps: boolean): void`**\n- Sets whether to use **HTTPS** or **HTTP** according to the `useHttps` value passed.\n\n### AdditionalData\nAn object used for sending [additional data](https://docs.anura.io/integration/additional-data) to Anura Direct.\n\n### Methods\n**`addElement(key: number, value: string): void`**\n- Adds an element of data to your `AdditionalData`.\n\n**`removeElement(key: number): void`**\n- Removes the element of data located at the provided `key` from your `AdditionalData`.\n\n**`toString(): string`**\n- Returns your `AdditionalData` as a JSON string.\n\n**`size(): number`**\n- Returns the number of elements currently set within your `AdditionalData`\n\n### DirectResult\nThe result upon a successful call to `getResult()` from the `AnuraDirect` client. It contains not only the result from Anura Direct, but some other methods to help you use the result as well.\n\n#### Methods\n**`isSuspect(): boolean`**\n- Returns whether or not the visitor has been determined to be **suspect**.\n\n**`isNonSuspect(): boolean`**\n- Returns whether or not the visitor as been determined to be **non-suspect**.\n\n**`isMobile(): boolean`**\n- Returns whether or  not the visitor has been determined to be on a mobile device.\n\n**`get result(): string`**\n- Returns the raw result string value.\n\n**`get mobile(): number|null`**\n- Returns the raw mobile result value.\n\n**`get ruleSets(): string[]|null`**\n- If you have **return rule sets** enabled, you will be able to see which specific rules were violated upon a **suspect** result. This value will be null if the visitor is **non-suspect**, or if you do not have **return rule sets enabled**.\n- You can talk to [support](mailto:support@anura.io) about enabling or disabling the return rule sets feature.\n\n**`get invalidTrafficType(): string|null`**\n- If you have **return invalid traffic type** enabled, you will be able to access which type of invalid traffic occurred upon a **suspect** result.\n- You can talk to [support](mailto:support@anura.io) about enabling or disabling the return invalid traffic type feature.","readmeFilename":"README.md"}