Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Latest commit

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Getting started

The general-purpose API

Initialization

Authentication

In order to setup authentication and initialization of the API client, you need the following information.

ParameterDescription
user_idYour user ID
api_keyYour API key

API client can be initialized as following.

# Configuration parameters and credentialsuser_id='user_id'# Your user IDapi_key='api_key'# Your API keyclient=NeutrinoApi::NeutrinoApiClient.new(user_id: user_id,api_key: api_key)

Class Reference

List of Controllers

Class: Imaging

Get singleton instance

The singleton instance of the Imaging class can be accessed from the API Client.

imaging_controller=client.imaging

Method: image_resize

Resize an image and output as either JPEG or PNG. See: https://www.neutrinoapi.com/api/image-resize/

defimage_resize(image_url,width,height,format='png');end

Parameters

ParameterTagsDescription
image_urlRequiredThe URL to the source image
widthRequiredThe width to resize to (in px) while preserving aspect ratio
heightRequiredThe height to resize to (in px) while preserving aspect ratio
formatOptionalDefaultValueThe output image format, can be either png or jpg

Example Usage

image_url='image-url'width=105height=105format='png'result=imaging_controller.image_resize(image_url,width,height,format)

Method: qr_code

Generate a QR code as a PNG image. See: https://www.neutrinoapi.com/api/qr-code/

defqr_code(content,width=256,height=256,fg_color='#000000',bg_color='#ffffff');end

Parameters

ParameterTagsDescription
contentRequiredThe content to encode into the QR code (e.g. a URL or a phone number)
widthOptionalDefaultValueThe width of the QR code (in px)
heightOptionalDefaultValueThe height of the QR code (in px)
fg_colorOptionalDefaultValueThe QR code foreground color
bg_colorOptionalDefaultValueThe QR code background color

Example Usage

content='content'width=256height=256fg_color='#000000'bg_color='#ffffff'result=imaging_controller.qr_code(content,width,height,fg_color,bg_color)

Method: image_watermark

Watermark one image with another image. See: https://www.neutrinoapi.com/api/image-watermark/

defimage_watermark(image_url,watermark_url,opacity=50,format='png',position='center',width=nil,height=nil);end

Parameters

ParameterTagsDescription
image_urlRequiredThe URL to the source image
watermark_urlRequiredThe URL to the watermark image
opacityOptionalDefaultValueThe opacity of the watermark (0 to 100)
formatOptionalDefaultValueThe output image format, can be either png or jpg
positionOptionalDefaultValueThe position of the watermark image, possible values are: center, top-left, top-center, top-right, bottom-left, bottom-center, bottom-right
widthOptionalIf set resize the resulting image to this width (in px) while preserving aspect ratio
heightOptionalIf set resize the resulting image to this height (in px) while preserving aspect ratio

Example Usage

image_url='image-url'watermark_url='watermark-url'opacity=50format='png'position='center'width=105height=105result=imaging_controller.image_watermark(image_url,watermark_url,opacity,format,position,width,height)

Method: html5_render

Render HTML content to PDF, JPG or PNG. See: https://www.neutrinoapi.com/api/html5-render/

defhtml5_render(content,format='PDF',page_size='A4',title=nil,margin=0,margin_left=0,margin_right=0,margin_top=0,margin_bottom=0,landscape=false,zoom=1,grayscale=false,media_print=false,media_queries=false,forms=false,css=nil,image_width=1024,image_height=nil,render_delay=0,header_text_left=nil,header_text_center=nil,header_text_right=nil,header_size=9,header_font='Courier',header_font_size=11,header_line=false,footer_text_left=nil,footer_text_center=nil,footer_text_right=nil,footer_size=9,footer_font='Courier',footer_font_size=11,footer_line=false,page_width=nil,page_height=nil);end

Parameters

ParameterTagsDescription
contentRequiredThe HTML content. This can be either a URL to load HTML from or an actual HTML content string
formatOptionalDefaultValueWhich format to output, available options are: PDF, PNG, JPG
page_sizeOptionalDefaultValueSet the document page size, can be one of: A0 - A9, B0 - B10, Comm10E, DLE or Letter
titleOptionalThe document title
marginOptionalDefaultValueThe document margin (in mm)
margin_leftOptionalDefaultValueThe document left margin (in mm)
margin_rightOptionalDefaultValueThe document right margin (in mm)
margin_topOptionalDefaultValueThe document top margin (in mm)
margin_bottomOptionalDefaultValueThe document bottom margin (in mm)
landscapeOptionalDefaultValueSet the document to lanscape orientation
zoomOptionalDefaultValueSet the zoom factor when rendering the page (2.0 for double size, 0.5 for half size)
grayscaleOptionalDefaultValueRender the final document in grayscale
media_printOptionalDefaultValueUse @media print CSS styles to render the document
media_queriesOptionalDefaultValueActivate all @media queries before rendering. This can be useful if you wan't to render the mobile version of a responsive website
formsOptionalDefaultValueGenerate real (fillable) PDF forms from HTML forms
cssOptionalInject custom CSS into the HTML. e.g. 'body { background-color: red;}'
image_widthOptionalDefaultValueIf rendering to an image format (PNG or JPG) use this image width (in pixels)
image_heightOptionalIf rendering to an image format (PNG or JPG) use this image height (in pixels). The default is automatic which dynamically sets the image height based on the content
render_delayOptionalDefaultValueNumber of milliseconds to wait before rendering the page (can be useful for pages with animations etc)
header_text_leftOptionalText to print to the left-hand side header of each page. e.g. 'My header - Page {page_number} of {total_pages}'
header_text_centerOptionalText to print to the center header of each page
header_text_rightOptionalText to print to the right-hand side header of each page
header_sizeOptionalDefaultValueThe height of your header (in mm)
header_fontOptionalDefaultValueSet the header font. Fonts available: Times, Courier, Helvetica, Arial
header_font_sizeOptionalDefaultValueSet the header font size (in pt)
header_lineOptionalDefaultValueDraw a full page width horizontal line under your header
footer_text_leftOptionalText to print to the left-hand side footer of each page. e.g. 'My footer - Page {page_number} of {total_pages}'
footer_text_centerOptionalText to print to the center header of each page
footer_text_rightOptionalText to print to the right-hand side header of each page
footer_sizeOptionalDefaultValueThe height of your footer (in mm)
footer_fontOptionalDefaultValueSet the footer font. Fonts available: Times, Courier, Helvetica, Arial
footer_font_sizeOptionalDefaultValueSet the footer font size (in pt)
footer_lineOptionalDefaultValueDraw a full page width horizontal line above your footer
page_widthOptionalSet the PDF page width explicitly (in mm)
page_heightOptionalSet the PDF page height explicitly (in mm)

Example Usage

content='content'format='PDF'page_size='A4'title='title'margin=0margin_left=0margin_right=0margin_top=0margin_bottom=0landscape=falsezoom=1grayscale=falsemedia_print=falsemedia_queries=falseforms=falsecss='css'image_width=1024image_height=105render_delay=0header_text_left='header-text-left'header_text_center='header-text-center'header_text_right='header-text-right'header_size=9header_font='Courier'header_font_size=11header_line=falsefooter_text_left='footer-text-left'footer_text_center='footer-text-center'footer_text_right='footer-text-right'footer_size=9footer_font='Courier'footer_font_size=11footer_line=falsepage_width=105page_height=105result=imaging_controller.html5_render(content,format,page_size,title,margin,margin_left,margin_right,margin_top,margin_bottom,landscape,zoom,grayscale,media_print,media_queries,forms,css,image_width,image_height,render_delay,header_text_left,header_text_center,header_text_right,header_size,header_font,header_font_size,header_line,footer_text_left,footer_text_center,footer_text_right,footer_size,footer_font,footer_font_size,footer_line,page_width,page_height)

Back to List of Controllers

Class: Telephony

Get singleton instance

The singleton instance of the Telephony class can be accessed from the API Client.

telephony_controller=client.telephony

Method: verify_security_code

Check if a security code from one of the verify APIs is valid. See: https://www.neutrinoapi.com/api/verify-security-code/

defverify_security_code(security_code);end

Parameters

ParameterTagsDescription
security_codeRequiredThe security code to verify

Example Usage

security_code='security-code'result=telephony_controller.verify_security_code(security_code)

Method: hlr_lookup

Connect to the global mobile cellular network and retrieve the status of a mobile device. See: https://www.neutrinoapi.com/api/hlr-lookup/

defhlr_lookup(number,country_code=nil);end

Parameters

ParameterTagsDescription
numberRequiredA phone number
country_codeOptionalISO 2-letter country code, assume numbers are based in this country. If not set numbers are assumed to be in international format (with or without the leading + sign)

Example Usage

number='number'country_code='country-code'result=telephony_controller.hlr_lookup(number,country_code)

Method: phone_playback

Make an automated call to any valid phone number and playback an audio message. See: https://www.neutrinoapi.com/api/phone-playback/

defphone_playback(number,audio_url);end

Parameters

ParameterTagsDescription
numberRequiredThe phone number to call. Must be in valid international format
audio_urlRequiredA URL to a valid audio file. Accepted audio formats are:
  • MP3
  • WAV
  • OGG
You can use the following MP3 URL for testing: https://www.neutrinoapi.com/test-files/test1.mp3

Example Usage

number='number'audio_url='audio-url'result=telephony_controller.phone_playback(number,audio_url)

Method: sms_verify

Send a unique security code to any mobile device via SMS. See: https://www.neutrinoapi.com/api/sms-verify/

defsms_verify(number,code_length=5,security_code=nil,country_code=nil,language_code='en');end

Parameters

ParameterTagsDescription
numberRequiredThe phone number to send a verification code to
code_lengthOptionalDefaultValueThe number of digits to use in the security code (must be between 4 and 12)
security_codeOptionalPass in your own security code. This is useful if you have implemented TOTP or similar 2FA methods. If not set then we will generate a secure random code
country_codeOptionalISO 2-letter country code, assume numbers are based in this country. If not set numbers are assumed to be in international format (with or without the leading + sign)
language_codeOptionalDefaultValueThe language to send the verification code in, available languages are:
  • de - German
  • en - English
  • es - Spanish
  • fr - French
  • it - Italian
  • pt - Portuguese
  • ru - Russian

Example Usage

number='number'code_length=5security_code=105country_code='country-code'language_code='en'result=telephony_controller.sms_verify(number,code_length,security_code,country_code,language_code)

Method: sms_message

Send a free-form message to any mobile device via SMS. See: https://www.neutrinoapi.com/api/sms-message/

defsms_message(number,message,country_code=nil);end

Parameters

ParameterTagsDescription
numberRequiredThe phone number to send a message to
messageRequiredThe SMS message to send. Messages are truncated to a maximum of 150 characters for ASCII content OR 70 characters for UTF content
country_codeOptionalISO 2-letter country code, assume numbers are based in this country. If not set numbers are assumed to be in international format (with or without the leading + sign)

Example Usage

number='number'message='message'country_code='country-code'result=telephony_controller.sms_message(number,message,country_code)

Method: phone_verify

Make an automated call to any valid phone number and playback a unique security code. See: https://www.neutrinoapi.com/api/phone-verify/

defphone_verify(number,code_length=6,security_code=nil,playback_delay=800,country_code=nil,language_code='en');end

Parameters

ParameterTagsDescription
numberRequiredThe phone number to send the verification code to
code_lengthOptionalDefaultValueThe number of digits to use in the security code (between 4 and 12)
security_codeOptionalPass in your own security code. This is useful if you have implemented TOTP or similar 2FA methods. If not set then we will generate a secure random code
playback_delayOptionalDefaultValueThe delay in milliseconds between the playback of each security code
country_codeOptionalISO 2-letter country code, assume numbers are based in this country. If not set numbers are assumed to be in international format (with or without the leading + sign)
language_codeOptionalDefaultValueThe language to playback the verification code in, available languages are:
  • de - German
  • en - English
  • es - Spanish
  • fr - French
  • it - Italian
  • pt - Portuguese
  • ru - Russian

Example Usage

number='number'code_length=6security_code=105playback_delay=800country_code='country-code'language_code='en'result=telephony_controller.phone_verify(number,code_length,security_code,playback_delay,country_code,language_code)

Back to List of Controllers

Class: DataTools

Get singleton instance

The singleton instance of the DataTools class can be accessed from the API Client.

dataTools_controller=client.data_tools

Method: email_validate

Parse, validate and clean an email address. See: https://www.neutrinoapi.com/api/email-validate/

defemail_validate(email,fix_typos=false);end

Parameters

ParameterTagsDescription
emailRequiredAn email address
fix_typosOptionalDefaultValueAutomatically attempt to fix typos in the address

Example Usage

email='email'fix_typos=falseresult=dataTools_controller.email_validate(email,fix_typos)

Method: user_agent_info

Parse, validate and get detailed user-agent information from a user agent string. See: https://www.neutrinoapi.com/api/user-agent-info/

defuser_agent_info(user_agent);end

Parameters

ParameterTagsDescription
user_agentRequiredA user agent string

Example Usage

user_agent='user-agent'result=dataTools_controller.user_agent_info(user_agent)

Method: bad_word_filter

Detect bad words, swear words and profanity in a given text. See: https://www.neutrinoapi.com/api/bad-word-filter/

defbad_word_filter(content,censor_character=nil);end

Parameters

ParameterTagsDescription
contentRequiredThe content to scan. This can be either a URL to load content from or an actual content string
censor_characterOptionalThe character to use to censor out the bad words found

Example Usage

content='content'censor_character='censor-character'result=dataTools_controller.bad_word_filter(content,censor_character)

Method: convert

A powerful unit conversion tool. See: https://www.neutrinoapi.com/api/convert/

defconvert(from_value,from_type,to_type);end

Parameters

ParameterTagsDescription
from_valueRequiredThe value to convert from (e.g. 10.95)
from_typeRequiredThe type of the value to convert from (e.g. USD)
to_typeRequiredThe type to convert to (e.g. EUR)

Example Usage

from_value='from-value'from_type='from-type'to_type='to-type'result=dataTools_controller.convert(from_value,from_type,to_type)

Method: phone_validate

Parse, validate and get location information about a phone number. See: https://www.neutrinoapi.com/api/phone-validate/

defphone_validate(number,country_code=nil,ip=nil);end

Parameters

ParameterTagsDescription
numberRequiredA phone number. This can be in international format (E.164) or local format. If passing local format you should use the 'country-code' or 'ip' options as well
country_codeOptionalISO 2-letter country code, assume numbers are based in this country. If not set numbers are assumed to be in international format (with or without the leading + sign)
ipOptionalPass in a users IP address and we will assume numbers are based in the country of the IP address

Example Usage

number='number'country_code='country-code'ip='ip'result=dataTools_controller.phone_validate(number,country_code,ip)

Back to List of Controllers

Class: SecurityAndNetworking

Get singleton instance

The singleton instance of the SecurityAndNetworking class can be accessed from the API Client.

securityAndNetworking_controller=client.security_and_networking

Method: ip_probe

Analyze and extract provider information for an IP address. See: https://www.neutrinoapi.com/api/ip-probe/

defip_probe(ip);end

Parameters

ParameterTagsDescription
ipRequiredIPv4 or IPv6 address

Example Usage

ip='ip'result=securityAndNetworking_controller.ip_probe(ip)

Method: email_verify

SMTP based email address verification. See: https://www.neutrinoapi.com/api/email-verify/

defemail_verify(email,fix_typos=false);end

Parameters

ParameterTagsDescription
emailRequiredAn email address
fix_typosOptionalDefaultValueAutomatically attempt to fix typos in the address

Example Usage

email='email'fix_typos=falseresult=securityAndNetworking_controller.email_verify(email,fix_typos)

Method: ip_blocklist

The IP Blocklist API will detect potentially malicious or dangerous IP addresses. See: https://www.neutrinoapi.com/api/ip-blocklist/

defip_blocklist(ip);end

Parameters

ParameterTagsDescription
ipRequiredAn IPv4 or IPv6 address

Example Usage

ip='ip'result=securityAndNetworking_controller.ip_blocklist(ip)

Method: host_reputation

Check the reputation of an IP address, domain name, FQDN or URL against a comprehensive list of blacklists and blocklists. See: https://www.neutrinoapi.com/api/host-reputation/

defhost_reputation(host,list_rating=3);end

Parameters

ParameterTagsDescription
hostRequiredAn IP address, domain name, FQDN or URL. If you supply a domain/URL it will be checked against the URI DNSBL lists
list_ratingOptionalDefaultValueOnly check lists with this rating or better

Example Usage

host='host'list_rating=3result=securityAndNetworking_controller.host_reputation(host,list_rating)

Back to List of Controllers

Class: Geolocation

Get singleton instance

The singleton instance of the Geolocation class can be accessed from the API Client.

geolocation_controller=client.geolocation

Method: geocode_reverse

Convert a geographic coordinate (latitude and longitude) into a real world address. See: https://www.neutrinoapi.com/api/geocode-reverse/

defgeocode_reverse(latitude,longitude,language_code='en',zoom='address');end

Parameters

ParameterTagsDescription
latitudeRequiredThe location latitude in decimal degrees format
longitudeRequiredThe location longitude in decimal degrees format
language_codeOptionalDefaultValueThe language to display results in, available languages are:
  • de, en, es, fr, it, pt, ru
zoomOptionalDefaultValueThe zoom level to respond with:
  • address - the most precise address available
  • street - the street level
  • city - the city level
  • state - the state level
  • country - the country level

Example Usage

latitude='latitude'longitude='longitude'language_code='en'zoom='address'result=geolocation_controller.geocode_reverse(latitude,longitude,language_code,zoom)

Method: ip_info

Get location information about an IP address and do reverse DNS (PTR) lookups. See: https://www.neutrinoapi.com/api/ip-info/

defip_info(ip,reverse_lookup=false);end

Parameters

ParameterTagsDescription
ipRequiredIPv4 or IPv6 address
reverse_lookupOptionalDefaultValueDo a reverse DNS (PTR) lookup. This option can add extra delay to the request so only use it if you need it

Example Usage

ip='ip'reverse_lookup=falseresult=geolocation_controller.ip_info(ip,reverse_lookup)

Method: geocode_address

Geocode an address, partial address or just the name of a place. See: https://www.neutrinoapi.com/api/geocode-address/

defgeocode_address(address,country_code=nil,language_code='en',fuzzy_search=false);end

Parameters

ParameterTagsDescription
addressRequiredThe address, partial address or name of a place to try and locate
country_codeOptionalThe ISO 2-letter country code to be biased towards (the default is no country bias)
language_codeOptionalDefaultValueThe language to display results in, available languages are:
  • de, en, es, fr, it, pt, ru
fuzzy_searchOptionalDefaultValueIf no matches are found for the given address, start performing a recursive fuzzy search until a geolocation is found. This option is recommended for processing user input or implementing auto-complete. We use a combination of approximate string matching and data cleansing to find possible location matches

Example Usage

address='address'country_code='country-code'language_code='en'fuzzy_search=falseresult=geolocation_controller.geocode_address(address,country_code,language_code,fuzzy_search)

Back to List of Controllers

Class: ECommerce

Get singleton instance

The singleton instance of the ECommerce class can be accessed from the API Client.

eCommerce_controller=client.e_commerce

Method: bin_lookup

Perform a BIN (Bank Identification Number) or IIN (Issuer Identification Number) lookup. See: https://www.neutrinoapi.com/api/bin-lookup/

defbin_lookup(bin_number,customer_ip=nil);end

Parameters

ParameterTagsDescription
bin_numberRequiredThe BIN or IIN number (the first 6 digits of a credit card number)
customer_ipOptionalPass in the customers IP address and we will return some extra information about them

Example Usage

bin_number='bin-number'customer_ip='customer-ip'result=eCommerce_controller.bin_lookup(bin_number,customer_ip)

Back to List of Controllers

Class: WWW

Get singleton instance

The singleton instance of the WWW class can be accessed from the API Client.

wWW_controller=client.www

Method: url_info

Parse, analyze and retrieve content from the supplied URL. See: https://www.neutrinoapi.com/api/url-info/

defurl_info(url,fetch_content=false,ignore_certificate_errors=false,timeout=20);end

Parameters

ParameterTagsDescription
urlRequiredThe URL to probe
fetch_contentOptionalDefaultValueIf this URL responds with html, text, json or xml then return the response. This option is useful if you want to perform further processing on the URL content (e.g. with the HTML Extract or HTML Clean APIs)
ignore_certificate_errorsOptionalDefaultValueIgnore any TLS/SSL certificate errors and load the URL anyway
timeoutOptionalDefaultValueTimeout in seconds. Give up if still trying to load the URL after this number of seconds

Example Usage

url='url'fetch_content=falseignore_certificate_errors=falsetimeout=20result=wWW_controller.url_info(url,fetch_content,ignore_certificate_errors,timeout)

Method: html_clean

Clean and sanitize untrusted HTML. See: https://www.neutrinoapi.com/api/html-clean/

defhtml_clean(content,output_type);end

Parameters

ParameterTagsDescription
contentRequiredThe HTML content. This can be either a URL to load HTML from or an actual HTML content string
output_typeRequiredThe level of sanitization, possible values are: plain-text: reduce the content to plain text only (no HTML tags at all) simple-text: allow only very basic text formatting tags like b, em, i, strong, u basic-html: allow advanced text formatting and hyper links basic-html-with-images: same as basic html but also allows image tags advanced-html: same as basic html with images but also allows many more common HTML tags like table, ul, dl, pre

Example Usage

content='content'output_type='output-type'result=wWW_controller.html_clean(content,output_type)

Method: browser_bot

Browser bot can extract content, interact with keyboard and mouse events, and execute JavaScript on a website. See: https://www.neutrinoapi.com/api/browser-bot/

defbrowser_bot(url,timeout=30,delay=3,selector=nil,exec=nil,user_agent=nil,ignore_certificate_errors=false);end

Parameters

ParameterTagsDescription
urlRequiredThe URL to load
timeoutOptionalDefaultValueTimeout in seconds. Give up if still trying to load the page after this number of seconds
delayOptionalDefaultValueDelay in seconds to wait before capturing any page data, executing selectors or JavaScript
selectorOptionalExtract content from the page DOM using this selector. Commonly known as a CSS selector, you can find a good reference here
execOptionalCollectionExecute JavaScript on the page. Each array element should contain a valid JavaScript statement in string form. If a statement returns any kind of value it will be returned in the 'exec-results' response. For your convenience you can also use the following special shortcut functions:
sleep(seconds); Just wait/sleep for the specified number of seconds. click('selector'); Click on the first element matching the given selector. focus('selector'); Focus on the first element matching the given selector. keys('characters'); Send the specified keyboard characters. Use click() or focus() first to send keys to a specific element. enter(); Send the Enter key. tab(); Send the Tab key.
Example:
[ "click('#button-id')", "sleep(1)", "click('.field-class')", "keys('1234')", "enter()" ]
user_agentOptionalOverride the browsers default user-agent string with this one
ignore_certificate_errorsOptionalDefaultValueIgnore any TLS/SSL certificate errors and load the page anyway

Example Usage

url='url'timeout=30delay=3selector='selector'exec=['exec']user_agent='user-agent'ignore_certificate_errors=falseresult=wWW_controller.browser_bot(url,timeout,delay,selector,exec,user_agent,ignore_certificate_errors)

Back to List of Controllers

About

Neutrino API SDK - A Ruby Gem based on Ruby >= 2.0.0

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages