abstract_api package#
Subpackages#
Module contents#
- class abstract_api.Avatars(api_key: str | None = None)[source]#
Bases:
BaseService[AvatarsResponse]AbstractAPI avatar generation service.
Used for creating highly customizable avatar images with a person’s name or initials to improve your user experience.
- Attributes:
_subdomain: Avatars service subdomain.
- create(name: str, image_size: int | None = None, image_format: str | None = None, font_size: float | None = None, char_limit: int | None = None, background_color: str | None = None, font_color: str | None = None, is_rounded: bool | None = None, is_uppercase: bool | None = None, is_italic: bool | None = None, is_bold: bool | None = None) AvatarsResponse[source]#
Create a new avatar with the given parameters.
- Args:
- name: The name you want to create an avatar for.
You can submit multiple names (such as first, middle, and last) and the API will default to displaying two letters in the avatar. You can change the number of letters displayed with the char_limit parameter.
- image_size: The size of the square avatar image in pixels.
It defaults to 128 pixels, and is available in sizes from 6 to 512 pixels.
- image_format: The desired format of the returned image. It defaults
to “png”, but can also be specified as “svg”.
- font_size: The size of the font as a percent of the image_size.
It defaults to 0.7, but it can be set between 0.1 and 1.0.
- char_limit: The maximum number of characters displayed in
the avatar. It defaults to 2. The actual number of characters displayed can be less than this number, but it cannot be more. The characters will first be chosen from distinct words, then from the second letter of distinct words.
- background_color: The hex color for the background.
It defaults to #335eea.
- font_color: The hex color for the font.
It defaults to white, i.e.,ffffff.
- is_rounded: Create a rounded avatar picture instead of squared one.
It defaults to false.
- is_uppercase: Set the initials in the avatar to all capitals.
It defaults to true.
- is_italic: Set the initials in the avatar to all italics.
It defaults to false.
- is_bold: Set the initials in the avatar to bold.
It defaults to false.
- Returns:
AvatarsResponse representing API call response.
- class abstract_api.CompanyEnrichment(*, response_fields: Iterable[str] | None = None, **kwargs)[source]#
Bases:
ResponseFieldsMixin,BaseService[CompanyEnrichmentResponse]AbstractAPI company enrichment service.
Used to find a company’s details using its domain.
- Attributes:
_subdomain: Company enrichment service subdomain. _response_fields: API response fields.
- check(domain: str, fields: Iterable[str] | None = None) CompanyEnrichmentResponse[source]#
Finds a company’s details using its domain.
- Args:
domain: The domain of the company you want to get data for. fields: Selected response fields (optional).
- Returns:
CompanyEnrichmentResponse representing API call response.
- class abstract_api.EmailValidation(api_key: str | None = None)[source]#
Bases:
BaseService[EmailValidationResponse]AbstractAPI email validation and verification service.
Used to validate and verify an email address.
- Attributes:
_subdomain: Email validation service subdomain.
- check(email: str, auto_correct: bool | None = False) EmailValidationResponse[source]#
Validates and verifies an email address.
- Args:
email: An email address to be validated and verified. auto_correct: Whether the given email address should be
autocorrected and returned in API response.
- Returns:
EmailValidationResponse representing API call response.
- class abstract_api.ExchangeRates(api_key: str | None = None)[source]#
Bases:
BaseServiceAbstractAPI exchange rates service.
Used to looking up the latest exchange rates for 80+ currencies, getting historical exchange rates, and converting an arbitrary amount from one currency to another.
- Attributes:
_subdomain: Exchange rates service subdomain.
- convert(base: str, target: str, date: str | None = None, base_amount: float | None = None) ExchangeRatesConversionResponse[source]#
Converts amount of money from base currency to target currency/ies.
- Args:
- base: Base currency used to get the latest exchange rate(s) for.
Uses the ISO 4217 currency standard (e.g., USD for United States Dollars).
- target: The target currency to convert the base_amount to.
Like the base parameters, any currency passed here follows the ISO 4217 standard. Note that unlike the other endpoints, convert only accepts one target currency at a time.
- date: The historical date you’d like to get rates from, in the
format of YYYY-MM-DD. If you leave this blank, it will use the latest available rate.
- base_amount: The amount of the base currency you would like to
convert to the target currency.
- Returns:
ExchangeRatesConversionResponse representing API call response.
- historical(base: str, date: str, target: Iterable[str] | None = None) HistoricalExchangeRatesResponse[source]#
Finds historical exchange rates from base to target currencies.
- Args:
- base: Base currency used to get the latest exchange rate(s) for.
Uses the ISO 4217 currency standard (e.g., USD for United States Dollars).
- date: The historical date you’d like to get rates from, in the
format of YYYY-MM-DD.
- target: The target currency or currencies to get the exchange rate
of versus the base currency. Like the base parameters, any currency passed here follows the ISO 4217 standard.
- Returns:
HistoricalExchangeRatesResponse representing API call response.
- live(base: str, target: Iterable[str] | None = None) LiveExchangeRatesResponse[source]#
Finds exchange rates from base currency to target currency/ies.
- Args:
- base: Base currency used to get the latest exchange rate(s) for.
Uses the ISO 4217 currency standard (e.g., USD for United States Dollars).
- target: The target currency or currencies to get the exchange rate
of versus the base currency. Like the base parameters, any currency passed here follows the ISO 4217 standard.
- Returns:
VATValidationResponse representing API call response.
- class abstract_api.Holidays(api_key: str | None = None)[source]#
Bases:
BaseService[HolidaysResponse]AbstractAPI Holidays service.
Used to get the public, local, religious, and other holidays of a particular country.
- Attributes:
_subdomain: Holidays service subdomain.
- lookup(country: str, year: int | None = None, month: int | None = None, day: int | None = None) HolidaysResponse[source]#
Gets the list of holidays of a particular country.
Can get the public, local, religious, and other holidays.
- Args:
country: The country’s two-letter ISO 3166-1 alpha-2 code. year: The year to get the holiday(s) from. Note that this is
optional on paid plans and required on free plans, and if left blank it will default to the current year.
- month: The month to get the holiday(s) from, in the format
of 1-12 (e.g., 1 is January, 2 is February, etc.). Note that this is optional on paid plans and required on free plans, and if left blank it will default to the current month.
- day: The day to get the holiday(s) from, in the format of 1-31.
Note that this is optional on paid plans and required on free plans, and if left blank it will default to the current day.
- Returns:
HolidaysResponse representing API call response.
- class abstract_api.IBANValidation(api_key: str | None = None)[source]#
Bases:
BaseService[IBANValidationResponse]AbstractAPI IBAN validation and verification service.
Used to validate and verify a IBAN number.
- Attributes:
_subdomain: IBAN validation service subdomain.
- check(iban: str) IBANValidationResponse[source]#
Validates an IBAN.
- Args:
- iban: The IBAN to validate. Note that the API will accept white
spaces, so BE71 0961 2345 6769 is considered as valid as BE71096123456769.
- Returns:
IBANValidationResponse representing API call response.
- class abstract_api.IPGeolocation(*, response_fields: Iterable[str] | None = None, **kwargs)[source]#
Bases:
ResponseFieldsMixin,BaseService[IPGeolocationResponse]AbstractAPI IP geolocation service.
Used to determine the location and other details of IP addresses.
- Attributes:
_subdomain: IP Geolocation service subdomain. _response_fields: Selected response fields to be returned from IP
Geolocation service endpoint.
- check(ip: str, fields: Iterable[str] | None = None) IPGeolocationResponse[source]#
Analyzes an IP address for geographical data.
- Args:
ip: A valid IP address to analyze. fields: Selected response fields (optional).
- Returns:
IPGeolocationResponse representing API call response.
- class abstract_api.ImageProcessing(api_key: str | None = None)[source]#
Bases:
BaseService[ImageProcessingResponse]AbstractAPI image processing service.
Used to convert, compress, or optimize an image.
- Attributes:
_subdomain: Image processing service subdomain.
- upload(image: BinaryIO, lossy: bool | None = None, quality: int | None = None, resize: BaseStrategy | None = None) ImageProcessingResponse[source]#
Converts, compresses, or optimizes an image.
- Args:
- image: The image to be processed, it should be a file-like or a
file opened in binary reading mode.
- lossy: If True, the API will perform a lossy compression on the
image, reducing the size massively with a small drop in image quality. If False, the image size will only be reduced slightly (10% - 20% at most), but there will be no reduction in image quality. The default value is False if this is not provided.
- quality: This is an integer between 0 and 100 that determines
the quality level for lossy compression. If not submitted it will be determined intelligently by AbstractAPI. Generally a quality above 95 is useless and may result in an image that is larger than the input image, and a quality below 25 will result in an image so low in quality that it will be useless.
- resize: This is an instance of BaseStrategy subclasses that
specifies how to resize the image. If not provided, we will only compress the image as desired.
- Returns:
ImageProcessingResponse representing API call response.
- url(url: str, lossy: bool | None = None, quality: int | None = None, resize: BaseStrategy | None = None) ImageProcessingResponse[source]#
Converts, compresses, or optimizes an image in the given URL.
- Args:
- url: The URL of the image that you would like to edit.
Note that is cannot be more than 32 MB in size.
- lossy: If True, the API will perform a lossy compression on the
image, reducing the size massively with a small drop in image quality. If False, the image size will only be reduced slightly (10% - 20% at most), but there will be no reduction in image quality. The default value is False if this is not provided.
- quality: This is an integer between 0 and 100 that determines
the quality level for lossy compression. If not submitted it will be determined intelligently by AbstractAPI. Generally a quality above 95 is useless and may result in an image that is larger than the input image, and a quality below 25 will result in an image so low in quality that it will be useless.
- resize: This is an instance of BaseStrategy subclasses that
specifies how to resize the image. If not provided, we will only compress the image as desired.
- Returns:
ImageProcessingResponse representing API call response.
- class abstract_api.PhoneValidation(api_key: str | None = None)[source]#
Bases:
BaseService[PhoneValidationResponse]AbstractAPI phone validation and verification service.
Used to validate and verify a phone number.
- Attributes:
_subdomain: Phone validation service subdomain.
- check(phone: str) PhoneValidationResponse[source]#
Validates and verifies a phone number.
- Args:
phone: An phone number to be validated and verified.
- Returns:
PhoneValidationResponse representing API call response.
- class abstract_api.Timezone(api_key: str | None = None)[source]#
Bases:
BaseServiceAbstractAPI timezone service.
Used to find, convert, and manage time and timezone data across the world.
- Attributes:
_subdomain: Timezone service subdomain.
- convert(base_location: str | list[float] | tuple[float, float], target_location: str | list[float] | tuple[float, float], base_datetime: str | None = None) TimezoneConversionResponse[source]#
Converts datetime of base location to target location’s datetime.
By default, it converts the current time, but the conversion can take place in either the past or future with a simple parameter.
- Args:
- base_location: The location you use as a base to convert the
datetime for. This parameter accepts the location as a string (e.g., Los Angeles, CA), a longitude and latitude (e.g., -31.4173391,-64.183319), or an IP address (e.g., 82.111.111.111).
- target_location: The location you want to get the datetime for.
This parameter accepts the location as a string (e.g., Los Angeles, CA), a longitude and latitude (e.g., -31.4173391,-64.183319), or an IP address (e.g., 82.111.111.111).
base_datetime: The datetime you’re converting.
- Returns:
TimezoneConversionResponse representing API call response.
- current(location: str | list[float] | tuple[float, float]) CurrentTimezoneResponse[source]#
Finds the current time, date, and timezone of a given location.
- Args:
- location: The location to determine the current time and
timezone of. This parameter accepts the location as a string (e.g., Los Angeles, CA), a longitude and latitude (e.g., -31.4173391,-64.183319), or an IP address (e.g., 82.111.111.111).
- Returns:
CurrentTimezoneResponse representing API call response.
- class abstract_api.VAT(api_key: str | None = None)[source]#
Bases:
BaseServiceAbstractAPI VAT categories, validation, and calculation service.
Used to validate and calculate VAT numbers and also to inquery about VAT categories.
- Attributes:
_subdomain: VAT service subdomain.
- calculate(amount: float, country_code: str, is_vat_incl: bool | None = None, vat_category: str | None = None) VATCalculationResponse[source]#
Calculates a VAT compliant price given a country and price.
- Args:
- amount: The amount that you would like to get the VAT amount
for or from.
- country_code: The two-letter ISO 3166-1 alpha-2 code of the
country in which the transaction takes place.
- is_vat_incl: If the amount already has VAT added, and you’d like
to do the reverse calculation and split out the amount and VAT, set this parameter to true. If this parameter is not explicitly included it will default to False.
- vat_category: Some countries offer a reduced VAT rate for
certain categories of goods. To determine if a reduced VAT is available and to apply it to the final amount, include the vat_category in the request.
- Returns:
VATCalculationResponse representing API call response.
- categories(country_code: str) VATCategoriesResponse[source]#
Gets the list of VAT categories for a country.
- Args:
- country_code: The two-letter ISO 3166-1 alpha-2 code of the
country in which the transaction takes place.
- Returns:
VATCategoriesResponse representing API call response.
- check(vat_number: str) VATValidationResponse[source]#
Validates a VAT number.
- Args:
vat_number: The VAT number to validate.
- Returns:
VATValidationResponse representing API call response.
- class abstract_api.WebScraping(api_key: str | None = None)[source]#
Bases:
BaseService[WebScrapingResponse]AbstractAPI web scraping service.
Used to extract data from a given URL.
- Attributes:
_subdomain: Web scraping service subdomain.
- scrape(url: str, render_js: bool | None = None, block_ads: bool | None = None, proxy_country: str | None = None) WebScrapingResponse[source]#
Extracts data from the given URL.
- Args:
- url: The URL to extract the data from. Note that this parameter
should include the full HTTP Protocol (http:// or https://). If your URL has parameters, you should encode it. For example the & character would be encoded to %26.
- render_js: If True the request will render Javascript on the
target site. Note that Javascript is rendered via a Google Chrome headless browser. Defaults to False.
- block_ads: If True the request will block any advertisements it
can identify on the target site. Defaults to False.
- proxy_country: The country to make the request from.
The country should be submitted in the two letter, ISO 3166-1 alpha-2 code.
- Returns:
WebScrapingResponse representing API call response.
- class abstract_api.WebsiteScreenshot(api_key: str | None = None)[source]#
Bases:
BaseService[WebsiteScreenshotResponse]AbstractAPI website screenshot service.
Used to request a screenshot of a webpage in a given URL.
- Attributes:
_subdomain: Website screenshot service subdomain.
- capture(url: str, capture_full_page: bool | None = None, width: int | None = None, height: int | None = None, delay: int | None = None, css_injection: str | None = None, user_agent: str | None = None, export_format: str | None = None) WebsiteScreenshotResponse[source]#
Captures a screenshot of a webpage in the given URL.
- Args:
- url: The URL to get the screenshot of. Note that this parameter
should include the full HTTP Protocol (http:// or https://).
- capture_full_page: If true the request will capture the entire
height and width of the page. Defaults to True.
- width: The width in pixels of the view port to use to capture
the image.
- height: The height in pixels of the view port to use to capture
the image.
- delay: The time in seconds to wait between loading the page and
taking the screenshot.
- css_injection: A CSS string to inject into the website before
capturing the image.
user_agent: The User Agent to use when capturing the screenshot. export_format: The image format to use for the screenshot.
Can be jpeg or png, and defaults to jpeg.
- Returns:
WebsiteScreenshotResponse representing API call response.