parityvend-api


Nameparityvend-api JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/parityvend/api_python
SummaryThe official Python library for ParityVend API
upload_time2024-03-15 19:41:12
maintainer
docs_urlNone
authorParityVend
requires_python>=3.8
licenseApache-2.0
keywords parityvend purchasing power parity purchasing power location based pricing pricing optimization api library geographical pricing dynamic pricing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ParityVend API Python Library

**Welcome to the ParityVend API Python Library!** This library simplifies the process of integrating ParityVend's location-based pricing into your Python applications, allowing you to expand your business and take it to a global level.

[![ParityVend API Python Library - cover](https://github.com/ParityVend/parityvend_api_python/blob/main/images/_cover_gh.png?raw=true)](https://www.ambeteco.com/ParityVend/)

ParityVend is a powerful tool that helps businesses go global by offering smart pricing that adapts to each visitor's purchasing power based on their location. By using ParityVend, you can customize the prices of your products to match the economic diversity of the global market, just like industry giants Netflix, Google, Microsoft, Apple, and Spotify do. This approach ensures that your products are competitively priced in various countries, helping you expand your customer base, increase sales, and optimize profits.

The ParityVend API Python library helps you interact with the ParityVend API more easily. It provides ready-to-use functions that act as a wrapper for the ParityVend API's backend endpoints. This wrapper simplifies the use of ParityVend's features in your Python backends, microservices, or other server-side applications.

By using this library, you can take advantage of ParityVend's powerful API features to:

- adjust your prices based on visitors' locations.
- implement anti-abuse systems to protect against fraudulent activities like VPN, proxy, and TOR.
- get information about your customers' locations.

You can find more integration ideas in the ParityVend documentation: [ParityVend integration ideas](https://www.ambeteco.com/ParityVend/docs/api_integration_tutorial.html#integration-ideas).

**Key features include:**

- Easy Integration: Simplified access to the ParityVend API endpoints.
- Asynchronous Support: Provides both synchronous and asynchronous handlers.
- Simplified API Usage: The library abstracts away the complexities of the raw API, allowing you to focus on your application logic.
- Pythonic responses: Providing convenient response types, such as `Response`, `Country`, `Discounts`, etc. instead of raw JSON.

## Documentation

For the ParityVend API Python library, please refer to ['quick start' section](https://github.com/ParityVend/parityvend_api_python?tab=readme-ov-file#quick-start)

For general documentation on the ParityVend API, please refer to [https://www.ambeteco.com/ParityVend/docs/api_reference.html](https://www.ambeteco.com/ParityVend/docs/api_reference.html)

## Requirements and Dependencies

The library is cross-platform. It is compatible with all Python versions 3.8 to 3.13 (including support for PyPy). The ParityVend API Python library uses `requests` for the synchronous handler and `aiohttp` for the asynchronous handler, as well as `cachetools` for providing memoization.

[![ParityVend API Python Library - Getting Started](https://github.com/ParityVend/parityvend_api_python/blob/main/images/_get_started_cover_gh.png?raw=true)](https://www.ambeteco.com/ParityVend/)

## Getting Started

To use the ParityVend API, you need to obtain an API key, also known as a `private_key`. ParityVend offers a generous free plan that allows you to get your API key without any cost.

### Free Plan

The free plan provides the following benefits:

- 7,500 requests per month
- Full access to the API and its functionality (except for the currency exchange endpoint and anti-abuse systems)
- No "demo-like" restrictions or limitations

### Getting the Free API Key

To get your free API key, follow these steps:

1. Visit the [ParityVend Pricing Page](https://www.ambeteco.com/ParityVend/pricing/).
2. Sign up for the free plan by providing the required information.
3. Create a new project. Your API key (`private_key`) will be issued and made available to you.

### Paid Plans

If you require more monthly requests or need access to the currency exchange endpoint and advanced anti-abuse systems, you can consider upgrading to one of the paid plans offered by ParityVend.

To explore the paid plan options and pricing details, visit the [ParityVend Pricing Page](https://www.ambeteco.com/ParityVend/pricing/).

With your API key (`private_key`) in hand, you can start integrating the ParityVend API into your applications and benefiting from its features and functionality.

### Installation

**Pre-built Package**

If you simply want to use the library without modifying the source code, install it using pip:

```bash
pip install --upgrade parityvend_api
```

**Installation from Source**

To install from the source code (useful for development or customization):

```bash
python setup.py install
```

### Quick Start

The library provides two main handlers that provide convenient access to the ParityVend API: `ParityVendAPI` and `AsyncParityVendAPI`, which need to be initiated with your account's private API key, available in the [Dashboard](https://www.ambeteco.com/ParityVend/dash/).

- `ParityVendAPI`: This class is designed for synchronous interactions with the ParityVend API (via `requests`).
- `AsyncParityVendAPI`: Provides asynchronous functions for improved performance (via `aiohttp`).

Check out the [examples folder](https://github.com/ParityVend/parityvend_api_python/tree/main/examples) for more, or get started with these simple snippets below.

**Get country information from an IP Address**
View the full documentation for this API endpoint here: [get-country-from-ip](<https://www.ambeteco.com/ParityVend/docs/api_reference.html#get--backend-get-country-from-ip-(private_key)->)

```python
>>> from parityvend_api import ParityVendAPI
>>> parityvend = ParityVendAPI('your_private_key')
>>> ip_address = '190.206.117.0' # an example IP from Venezuela
>>> country = parityvend.get_country_from_ip(ip_address)
>>> country
Country('VE')
>>> country.name # you can use the dot notation to access data
'Venezuela'
>>> country.code
'VE'
>>> country.emoji_flag
'🇻🇪'
>>> country.currency_code
'VES'
>>> country.currency_symbol
'Bs.'
>>> country.currency_localized
'VESBs.'
>>> country['name']  # you can also use dictionary lookups
'Venezuela'
```

**Get discount information from an IP Address**
View the full documentation for this API endpoint here: [get-discount-from-ip](<https://www.ambeteco.com/ParityVend/docs/api_reference.html#get--backend-get-discount-from-ip-(private_key)-(opt.-base_currency)->)

```python
>>> from parityvend_api import ParityVendAPI
>>> parityvend = ParityVendAPI('your_private_key')
>>> ip_address = '190.206.117.0' # an example IP from Venezuela
>>> response = parityvend.get_discount_from_ip(ip_address)
>>> response
Response({'status': 'ok', 'discount': 0.4, 'discount_str': '40.00%', 'coupon_code': 'example_coupon', 'country': Country('VE'), 'currency': {'code': 'VES', 'symbol': 'Bs.', 'localized_symbol': 'VESBs.', 'conversion_rate': 36.092756259083146}})
>>> response.discount
0.4
>>> response.currency.code
'VES'
>>> response['coupon_code']
'example_coupon'
```

**Get discount banner from an IP Address**
View the full documentation for this API endpoint here: [get-banner-from-ip](<https://www.ambeteco.com/ParityVend/docs/api_reference.html#get--backend-get-banner-from-ip-(private_key)-(opt.-base_currency)->)

```python
>>> from parityvend_api import ParityVendAPI
>>> parityvend = ParityVendAPI('your_private_key')
>>> ip_address = '190.206.117.0' # an example IP from Venezuela
>>> banner = parityvend.get_banner_from_ip(ip_address)
>>> print(banner)
We're committed to fair pricing worldwide and support <span class="parityvend-var-country-name">Venezuela</span>'s purchasing power. Enjoy a <span class="parityvend-var-discount-str">40.00%</span> discount with code <span class="parityvend-var-coupon-code">example_coupon</span>. Happy shopping!
```

**Get discount information with the HTML banner from an IP Address**
View the full documentation for this API endpoint here: [get-discount-with-html-from-ip](<https://www.ambeteco.com/ParityVend/docs/api_reference.html#get--backend-get-discount-with-html-from-ip-(private_key)-(opt.-base_currency)->)

```python
>>> from parityvend_api import ParityVendAPI
>>> parityvend = ParityVendAPI('your_private_key')
>>> ip_address = '190.206.117.0' # an example IP from Venezuela
>>> response = parityvend.get_discount_with_html_from_ip(ip_address)
>>> response
Response({'status': 'ok', 'html': 'We\'re committed to fair pricing worldwide and support <span class="parityvend-var-country-name">Venezuela</span>\'s purchasing power. Enjoy a <span class="parityvend-var-discount-str">40.00%</span> discount with code <span class="parityvend-var-coupon-code">example_coupon</span>. Happy shopping!', 'discount': 0.4, 'discount_str': '40.00%', 'coupon_code': 'example_coupon', 'country': Country('VE'), 'currency': {'code': 'VES', 'symbol': 'Bs.', 'localized_symbol': 'VESBs.', 'conversion_rate': 36.092756259083146}})
>>> print(response.html)
We're committed to fair pricing worldwide and support <span class="parityvend-var-country-name">Venezuela</span>'s purchasing power. Enjoy a <span class="parityvend-var-discount-str">40.00%</span> discount with code <span class="parityvend-var-coupon-code">example_coupon</span>. Happy shopping!
>>> response.discount_str
'40.00%'
>>>
```

**Get your account quota information**
View the full documentation for this API endpoint here: [get-quota-info](<https://www.ambeteco.com/ParityVend/docs/api_reference.html#get--backend-get-quota-info-(private_key)->)

```python
>>> from parityvend_api import ParityVendAPI
>>> parityvend = ParityVendAPI('your_private_key')
>>> response = parityvend.get_quota_info()
>>> response
Response({'status': 'ok', 'quota_limit': 1000000, 'quota_used': 4716, 'quota_left': 995284})
>>> response.quota_limit
1000000
>>> response['quota_used']
4716
>>>
```

**Get all the discounts for the current project**
View the full documentation for this API endpoint here: [get-discounts-info](<https://www.ambeteco.com/ParityVend/docs/api_reference.html#get--backend-get-discounts-info-(private_key)->)

```python
>>> from parityvend_api import ParityVendAPI
>>> parityvend = ParityVendAPI('your_private_key')
>>> response = parityvend.get_discounts_info()
>>> response
Response({'status': 'ok', 'discounts': Discounts({'AC': Discount(Country('AC'), '', 0.0), 'AD': Discount(Country('AD'), '', 0.0), 'AE': Discount(Country('AE'), '', 0.0), 'AF': Discount(Country('AF'), 'example_coupon', 0.7), 'AG': Discount(Country('AG'), 'example_coupon', 0.2), 'AI': Discount(Country('AI'), 'example_coupon', 0.2), 'AL': Discount(Country('AL'),  ... })}) # discounts information for all 255 countries
>>>
>>> response.discounts['VE'] # access individual countries with key lookups
Discount(Country('VE'), 'example_coupon', 0.4)
>>> response.discounts['US']
Discount(Country('US'), '', 0.0)
>>> # or via the bound method:
>>> response.discounts.get_discount_by_country('CA')
Discount(Country('CA'), '', 0.0)
>>>
>>> # the discount object has the discount itself, as well as coupon code and country information
>>> response.discounts['VE'].discount_str
'40.00%'
>>> response.discounts['VE'].coupon_code
'example_coupon'
>>> response.discounts['VE'].country
Country('VE')
>>>
```

**Get the currency exchange rates (only for accounts with paid plans)**
View the full documentation for this API endpoint here: [get-exchange-rate-info](<https://www.ambeteco.com/ParityVend/docs/api_reference.html#get--backend-get-exchange-rate-info-(private_key)-(opt.-base_currency)->)

```python
>>> from parityvend_api import ParityVendAPI
>>> parityvend = ParityVendAPI('your_private_key')
>>> response = parityvend.get_exchange_rate_info()
>>> response
Response({'status': 'ok', 'rates': Response({'AED': 3.6728503704071045, 'AFN': 72.5033950805664, 'ALL': 95.3699951171875, 'AMD': 404.7422790527344, 'ANG': 1.803326964378357, 'AOA': 828.7760620117188, 'ARS': 819.7839965820312, 'AUD': 1.5208089351654053, 'AWG': 1.8025002479553223, 'AZN': 1.6963270902633667, 'BAM': 1.7974870204925537, 'BBD': 2.020319700241089, 'BDT': 109.81781005859375, 'BGN': 1.7990400791168213, 'BHD': 0.3769211173057556, 'BIF': 2859.500244140625, ... })})
>>> response.rates.EUR
0.9195351004600525
>>> response.rates.GBP
0.7895551323890686
>>>
>>> # you can also change the base currency
>>> response_eur = parityvend.get_exchange_rate_info(base_currency='EUR')
>>> response_eur.rates.USD
1.0875060558319092
>>> response_eur.rates.EUR
1.0
>>>
```

**Some utility functions and miscellaneous stuff:**

```python
>>> from parityvend_api import env_get, get_country_by_code, COUNTRIES
>>>
>>> COUNTRIES # a dict of country ISO codes to a pre-created 'Country' object
{'AC': Country('AC'), 'AD': Country('AD'), 'AE': Country('AE'), 'AF': Country('AF'), 'AG': Country('AG'), ..., 'ZM': Country('ZM'), 'ZW': Country('ZW'), 'XX': Country('XX')}
>>> COUNTRIES['GB']
Country('GB')
>>> COUNTRIES['AU']
Country('AU')
>>>
>>>
>>> get_country_by_code('CA') # get the 'Country' object from the ISO code
Country('CA')
>>> country = get_country_by_code('US')
>>> country.name
'United States of America'
>>>
>>>
>>> # get an environment variable if it exists, or return the default value
>>> env_get('some_env_variable', 'default value')
'default value'
>>>
```

### The `base_currency` argument

The functions `get_discount_from_ip`, `get_banner_from_ip`, `get_discount_with_html_from_ip`, and `get_exchange_rate_info` all have an optional keyword argument called `base_currency`. This argument allows you to specify a base currency for calculating the exchange rate of the IP's local currency. The default value for `base_currency` is `USD`.

```python
>>> ...
>>> # set the `base_currency` to 'EUR'. By default, it's set to 'USD'
>>> response_eur = parityvend.get_discount_from_ip(ip_address, base_currency='EUR')
>>> response_eur
Response({'status': 'ok', 'discount': 0.4, 'discount_str': '40.00%', 'coupon_code': 'example_coupon', 'country': Country('VE'), 'currency': Response({'code': 'VES', 'symbol': 'Bs.', 'localized_symbol': 'VESBs.', 'conversion_rate': 39.25109100341797})})
>>> print(f'1 EUR is {response_eur.currency.conversion_rate} {response_eur.currency.code}')
1 EUR is 39.25109100341797 VES
>>>
>>> response_gbp = parityvend.get_discount_from_ip(ip_address, base_currency='GBP')
>>> response_gbp
Response({'status': 'ok', 'discount': 0.4, 'discount_str': '40.00%', 'coupon_code': 'example_coupon', 'country': Country('VE'), 'currency': {'code': 'VES', 'symbol': 'Bs.', 'localized_symbol': 'VESBs.', 'conversion_rate': 45.71277583460257}})
>>> print(f'1 GBP is {response_gbp.currency.conversion_rate} {response_eur.currency.code}')
1 GBP is 45.71277583460257 VES
>>>
```

### Asynchronous support

An asynchronous handler, `AsyncParityVendAPI`, can be used in the same way as the synchronous handler:

```python
from parityvend_api import AsyncParityVendAPI
import asyncio

async def run():
    parityvend = AsyncParityVendAPI("your private key")
    ip_address = "190.206.117.0"  # an example IP from Venezuela
    country = await parityvend.get_country_from_ip(ip_address)
    print(repr(country)) # will print 'Country("VE")'
    await parityvend.deinit()  # don't forget to close the session

loop = asyncio.get_event_loop().run_until_complete(run())
```

### The `timeout` and `cache` Keyword Arguments

Each function in the library accepts two optional keyword arguments: `timeout` and `cache`. These arguments allow you to customize the behavior of the API requests and the caching mechanism on a per-call basis.

#### Using the `timeout` argument

The `timeout` argument specifies the maximum amount of time (in seconds) to wait for the API request to complete before raising a timeout error. By default, all functions in the library have `timeout=None`, which means that the operating system's default timeout value will be used.

You can override this default behavior by passing a specific value (in seconds) to the `timeout` argument. For example:

```python
parityvend.get_country_from_ip('8.8.8.8', timeout=5)  # set a 5-second timeout
```

Setting an appropriate timeout value can help prevent your application from getting stuck indefinitely waiting for a response from the API.

#### Using the `cache` argument

The `cache` argument allows you to enable or disable the caching mechanism for a specific API call. All functions in the library have `cache=True` by default, which means that they will return a cached response if it's available in the cache. This behavior helps optimize your API quota usage and reduce response times.

However, there may be situations where you want to bypass the cache and always fetch fresh data from the API. In such cases, you can set `cache=False` when calling the function.

One exception to the default behavior is the `get_quota_info` function, which has `cache=False` by default. This is because quota information is expected to change frequently, and serving stale cached data could lead to inaccurate quota calculations.

```python
parityvend.get_country_from_ip('8.8.8.8', cache=False)  # Bypass the cache
```

### The `Response` object

The functions in this library return a `Response` object that contains all fields listed in the [ParityVend API documentation](https://www.ambeteco.com/ParityVend/docs/api_reference.html#backend-primary-endpoints) for the given endpoint, along with some additional properties and functionality. You can access the response properties using dot notation or dictionary-style lookup methods. The `"country"` and `"discounts"` items in the response are automatically converted to auxiliary `Country` and `Discounts` objects, respectively. These objects provide additional methods and attributes for ease of use. For example:

```python
...
>>> r = parityvend.get_discount_from_ip("190.206.117.0")
>>> r # the Response object looks like this:
Response({'status': 'ok', 'discount': 0.4, 'discount_str': '40.00%', 'coupon_code': 'example_coupon', 'country': Country('VE'), 'currency': Response({'code': 'VES', 'symbol': 'Bs.', 'localized_symbol': 'VESBs.', 'conversion_rate': 36.092756259083146})})
>>> r.discount # access the data via dot notation...
0.4
>>> r.country.name
'Venezuela'
>>> r.currency.conversion_rate
36.092756259083146
>>> r['currency']['conversion_rate'] # ... or like a dictionary key lookup
36.092756259083146
>>>
...
>>> # All the functions return Response objects:
>>> parityvend.get_discount_from_ip("190.206.117.0")
Response({'status': 'ok', 'discount': 0.4, 'discount_str': '40.00%', 'coupon_code': 'example_coupon', 'country': Country('VE'), 'currency': {'code': 'VES', 'symbol': 'Bs.', 'localized_symbol': 'VESBs.', 'conversion_rate': 36.092756259083146}})
>>> parityvend.get_discount_with_html_from_ip("190.206.117.0")
Response({'status': 'ok', 'html': 'We\'re committed to fair pricing worldwide and support <span class="parityvend-var-country-name">Venezuela</span>\'s purchasing power. Enjoy a <span class="parityvend-var-discount-str">40.00%</span> discount with code <span class="parityvend-var-coupon-code">example_coupon</span>. Happy shopping!', 'discount': 0.4, 'discount_str': '40.00%', 'coupon_code': 'example_coupon', 'country': Country('VE'), 'currency': {'code': 'VES', 'symbol': 'Bs.', 'localized_symbol': 'VESBs.', 'conversion_rate': 36.092756259083146}})
>>> parityvend.get_quota_info("190.206.117.0")
Response({'status': 'ok', 'quota_limit': 1000000, 'quota_used': 4188, 'quota_left': 995812})
>>>
```

### Caching

This library provides in-memory caching of API responses by default, using the [cachetools](https://cachetools.readthedocs.io/en/latest/) library. The caching mechanism employs a Least Recently Used (LRU) cache with a Time to Live (TTL) value. This means that cached values will be kept for a specified duration, and when the cache reaches its maximum size, the least recently used entries will be automatically removed to accommodate new ones.

Caching helps optimize your API quota usage and reduces response times by serving cached data instead of making redundant API requests. However, it's important to note that cached data may become stale over time, so the cache should be invalidated or refreshed as needed, depending on your application's requirements.

#### Default Caching Options

By default, the following caching options are applied:

- **Maximum Cache Size**: 4096 entries (using multiples of 2 for memory efficiency)
- **Time to Live (TTL)**: 24 hours (86,400 seconds)

These default settings aim to provide a balance between cache performance and memory usage. However, you can modify these settings to suit your specific needs.

#### Modifying Cache Options

You can customize the cache behavior by setting the `cache_options` keyword argument when initializing the handler. The `cache_options` parameter should be a dictionary, where the keys are keyword arguments accepted by the `cachetools` library. For more advanced caching options and configurations, refer to the [cachetools documentation](https://cachetools.readthedocs.io/en/latest/).

```python
>>> from parityvend_api import ParityVendAPI
>>>
>>> # the cache is enabled by default! you don't have to do anything.
>>> parityvend = ParityVendAPI("your private key")
>>>
>>> # let's measure the quota usage via the 'get_quota_info' endpoint
>>> quota_used = parityvend.get_quota_info().quota_used
>>>
>>> # these three calls will only send one request and return the cached response
>>> parityvend.get_country_from_ip("190.206.117.0")
Country('VE')
>>> parityvend.get_country_from_ip("190.206.117.0")
Country('VE')
>>> parityvend.get_country_from_ip("190.206.117.0")
Country('VE')
>>>
>>> new_quota_used = parityvend.get_quota_info().quota_used
>>> print(new_quota_used - quota_used) # this will show how much quota was used
1
>>> # Thanks to the cache, only 1 request was sent, even though we called the function 3 times.
>>>
>>> # specify the cache options like this:
>>> ParityVendAPI(
...     "your private key",
...     cache_options={
...         "ttl": 60 * 60 * 8,
...         "maxsize": 2048,
...     },
... )
ParityVendAPI('...')
>>>
>>>
```

### Modifying Request Options

The library uses the popular `requests` (for synchronous requests) and `aiohttp` (for asynchronous requests) libraries under the hood to make API calls. You can modify the behavior of these requests by setting the `request_options` keyword argument when initializing the handler.

The `request_options` parameter should be a dictionary where the keys are keyword arguments accepted by the `requests` or `aiohttp` library, depending on whether you're using the synchronous or asynchronous handler. These options will be passed to each API request made by the handler, allowing you to customize various aspects of the requests, such as headers, timeouts, proxies, and more. For a complete list of available options and their descriptions, please refer to the documentation of the `requests` library (for synchronous handlers) or the `aiohttp` library (for asynchronous handlers).

```python
>>> from parityvend_api import ParityVendAPI
>>>
>>> parityvend = ParityVendAPI("your private key", request_options={
    "headers": {
        "User-Agent": "just an example"
    }
})
```

## Contributing

Contributions to the ParityVend API Python Library are welcome and encouraged! We appreciate any feedback, bug reports, or feature requests that can help improve the library and make it more useful for the community.

Please refer to the [`CONTRIBUTING.md`](https://github.com/ParityVend/parityvend_api_python/blob/main/CONTRIBUTING.md) file for more detailed guidelines on how to contribute, including the environment setup, coding standards, and testing requirements.

## License

The ParityVend API Python Library is released under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). This means that you are free to use, modify, and distribute this library in your commercial or non-commercial software products, as long as you comply with the terms of the license.

The Apache 2.0 License is a permissive open-source license that allows you to:

- Use the library in your projects, both commercial and non-commercial.
- Modify the library's source code to suit your needs.
- Distribute the library or your modified versions of it.

However, you must include a copy of the Apache 2.0 License and the copyright notice in any distribution of the library or modified versions of it.

## Support

If you encounter any issues or challenges during the integration process, we recommend referring to the ParityVend documentation as your first resource. It provides comprehensive guidance to help you troubleshoot and resolve any errors you may encounter. If you require further support, our team is always ready to assist you. Feel free to [contact us](https://www.ambeteco.com/ParityVend/contact-us/) for personalized assistance to ensure a seamless integration experience, or view the [FAQ section](https://www.ambeteco.com/ParityVend/support/) on the ParityVend Support page.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/parityvend/api_python",
    "name": "parityvend-api",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "parityvend,purchasing power parity,purchasing power,location based pricing,pricing optimization,api library,geographical pricing,dynamic pricing",
    "author": "ParityVend",
    "author_email": "ParityVend <help@ambeteco.com>",
    "download_url": "https://files.pythonhosted.org/packages/7b/61/232c7ddce53e4bd9944859a762ee56c7604b7ba5a6488f94d880640ac031/parityvend_api-1.0.0.tar.gz",
    "platform": null,
    "description": "# ParityVend API Python Library\r\n\r\n**Welcome to the ParityVend API Python Library!** This library simplifies the process of integrating ParityVend's location-based pricing into your Python applications, allowing you to expand your business and take it to a global level.\r\n\r\n[![ParityVend API Python Library - cover](https://github.com/ParityVend/parityvend_api_python/blob/main/images/_cover_gh.png?raw=true)](https://www.ambeteco.com/ParityVend/)\r\n\r\nParityVend is a powerful tool that helps businesses go global by offering smart pricing that adapts to each visitor's purchasing power based on their location. By using ParityVend, you can customize the prices of your products to match the economic diversity of the global market, just like industry giants Netflix, Google, Microsoft, Apple, and Spotify do. This approach ensures that your products are competitively priced in various countries, helping you expand your customer base, increase sales, and optimize profits.\r\n\r\nThe ParityVend API Python library helps you interact with the ParityVend API more easily. It provides ready-to-use functions that act as a wrapper for the ParityVend API's backend endpoints. This wrapper simplifies the use of ParityVend's features in your Python backends, microservices, or other server-side applications.\r\n\r\nBy using this library, you can take advantage of ParityVend's powerful API features to:\r\n\r\n- adjust your prices based on visitors' locations.\r\n- implement anti-abuse systems to protect against fraudulent activities like VPN, proxy, and TOR.\r\n- get information about your customers' locations.\r\n\r\nYou can find more integration ideas in the ParityVend documentation: [ParityVend integration ideas](https://www.ambeteco.com/ParityVend/docs/api_integration_tutorial.html#integration-ideas).\r\n\r\n**Key features include:**\r\n\r\n- Easy Integration: Simplified access to the ParityVend API endpoints.\r\n- Asynchronous Support: Provides both synchronous and asynchronous handlers.\r\n- Simplified API Usage: The library abstracts away the complexities of the raw API, allowing you to focus on your application logic.\r\n- Pythonic responses: Providing convenient response types, such as `Response`, `Country`, `Discounts`, etc. instead of raw JSON.\r\n\r\n## Documentation\r\n\r\nFor the ParityVend API Python library, please refer to ['quick start' section](https://github.com/ParityVend/parityvend_api_python?tab=readme-ov-file#quick-start)\r\n\r\nFor general documentation on the ParityVend API, please refer to [https://www.ambeteco.com/ParityVend/docs/api_reference.html](https://www.ambeteco.com/ParityVend/docs/api_reference.html)\r\n\r\n## Requirements and Dependencies\r\n\r\nThe library is cross-platform. It is compatible with all Python versions 3.8 to 3.13 (including support for PyPy). The ParityVend API Python library uses `requests` for the synchronous handler and `aiohttp` for the asynchronous handler, as well as `cachetools` for providing memoization.\r\n\r\n[![ParityVend API Python Library - Getting Started](https://github.com/ParityVend/parityvend_api_python/blob/main/images/_get_started_cover_gh.png?raw=true)](https://www.ambeteco.com/ParityVend/)\r\n\r\n## Getting Started\r\n\r\nTo use the ParityVend API, you need to obtain an API key, also known as a `private_key`. ParityVend offers a generous free plan that allows you to get your API key without any cost.\r\n\r\n### Free Plan\r\n\r\nThe free plan provides the following benefits:\r\n\r\n- 7,500 requests per month\r\n- Full access to the API and its functionality (except for the currency exchange endpoint and anti-abuse systems)\r\n- No \"demo-like\" restrictions or limitations\r\n\r\n### Getting the Free API Key\r\n\r\nTo get your free API key, follow these steps:\r\n\r\n1. Visit the [ParityVend Pricing Page](https://www.ambeteco.com/ParityVend/pricing/).\r\n2. Sign up for the free plan by providing the required information.\r\n3. Create a new project. Your API key (`private_key`) will be issued and made available to you.\r\n\r\n### Paid Plans\r\n\r\nIf you require more monthly requests or need access to the currency exchange endpoint and advanced anti-abuse systems, you can consider upgrading to one of the paid plans offered by ParityVend.\r\n\r\nTo explore the paid plan options and pricing details, visit the [ParityVend Pricing Page](https://www.ambeteco.com/ParityVend/pricing/).\r\n\r\nWith your API key (`private_key`) in hand, you can start integrating the ParityVend API into your applications and benefiting from its features and functionality.\r\n\r\n### Installation\r\n\r\n**Pre-built Package**\r\n\r\nIf you simply want to use the library without modifying the source code, install it using pip:\r\n\r\n```bash\r\npip install --upgrade parityvend_api\r\n```\r\n\r\n**Installation from Source**\r\n\r\nTo install from the source code (useful for development or customization):\r\n\r\n```bash\r\npython setup.py install\r\n```\r\n\r\n### Quick Start\r\n\r\nThe library provides two main handlers that provide convenient access to the ParityVend API: `ParityVendAPI` and `AsyncParityVendAPI`, which need to be initiated with your account's private API key, available in the [Dashboard](https://www.ambeteco.com/ParityVend/dash/).\r\n\r\n- `ParityVendAPI`: This class is designed for synchronous interactions with the ParityVend API (via `requests`).\r\n- `AsyncParityVendAPI`: Provides asynchronous functions for improved performance (via `aiohttp`).\r\n\r\nCheck out the [examples folder](https://github.com/ParityVend/parityvend_api_python/tree/main/examples) for more, or get started with these simple snippets below.\r\n\r\n**Get country information from an IP Address**\r\nView the full documentation for this API endpoint here: [get-country-from-ip](<https://www.ambeteco.com/ParityVend/docs/api_reference.html#get--backend-get-country-from-ip-(private_key)->)\r\n\r\n```python\r\n>>> from parityvend_api import ParityVendAPI\r\n>>> parityvend = ParityVendAPI('your_private_key')\r\n>>> ip_address = '190.206.117.0' # an example IP from Venezuela\r\n>>> country = parityvend.get_country_from_ip(ip_address)\r\n>>> country\r\nCountry('VE')\r\n>>> country.name # you can use the dot notation to access data\r\n'Venezuela'\r\n>>> country.code\r\n'VE'\r\n>>> country.emoji_flag\r\n'\ud83c\uddfb\ud83c\uddea'\r\n>>> country.currency_code\r\n'VES'\r\n>>> country.currency_symbol\r\n'Bs.'\r\n>>> country.currency_localized\r\n'VESBs.'\r\n>>> country['name']  # you can also use dictionary lookups\r\n'Venezuela'\r\n```\r\n\r\n**Get discount information from an IP Address**\r\nView the full documentation for this API endpoint here: [get-discount-from-ip](<https://www.ambeteco.com/ParityVend/docs/api_reference.html#get--backend-get-discount-from-ip-(private_key)-(opt.-base_currency)->)\r\n\r\n```python\r\n>>> from parityvend_api import ParityVendAPI\r\n>>> parityvend = ParityVendAPI('your_private_key')\r\n>>> ip_address = '190.206.117.0' # an example IP from Venezuela\r\n>>> response = parityvend.get_discount_from_ip(ip_address)\r\n>>> response\r\nResponse({'status': 'ok', 'discount': 0.4, 'discount_str': '40.00%', 'coupon_code': 'example_coupon', 'country': Country('VE'), 'currency': {'code': 'VES', 'symbol': 'Bs.', 'localized_symbol': 'VESBs.', 'conversion_rate': 36.092756259083146}})\r\n>>> response.discount\r\n0.4\r\n>>> response.currency.code\r\n'VES'\r\n>>> response['coupon_code']\r\n'example_coupon'\r\n```\r\n\r\n**Get discount banner from an IP Address**\r\nView the full documentation for this API endpoint here: [get-banner-from-ip](<https://www.ambeteco.com/ParityVend/docs/api_reference.html#get--backend-get-banner-from-ip-(private_key)-(opt.-base_currency)->)\r\n\r\n```python\r\n>>> from parityvend_api import ParityVendAPI\r\n>>> parityvend = ParityVendAPI('your_private_key')\r\n>>> ip_address = '190.206.117.0' # an example IP from Venezuela\r\n>>> banner = parityvend.get_banner_from_ip(ip_address)\r\n>>> print(banner)\r\nWe're committed to fair pricing worldwide and support <span class=\"parityvend-var-country-name\">Venezuela</span>'s purchasing power. Enjoy a <span class=\"parityvend-var-discount-str\">40.00%</span> discount with code <span class=\"parityvend-var-coupon-code\">example_coupon</span>. Happy shopping!\r\n```\r\n\r\n**Get discount information with the HTML banner from an IP Address**\r\nView the full documentation for this API endpoint here: [get-discount-with-html-from-ip](<https://www.ambeteco.com/ParityVend/docs/api_reference.html#get--backend-get-discount-with-html-from-ip-(private_key)-(opt.-base_currency)->)\r\n\r\n```python\r\n>>> from parityvend_api import ParityVendAPI\r\n>>> parityvend = ParityVendAPI('your_private_key')\r\n>>> ip_address = '190.206.117.0' # an example IP from Venezuela\r\n>>> response = parityvend.get_discount_with_html_from_ip(ip_address)\r\n>>> response\r\nResponse({'status': 'ok', 'html': 'We\\'re committed to fair pricing worldwide and support <span class=\"parityvend-var-country-name\">Venezuela</span>\\'s purchasing power. Enjoy a <span class=\"parityvend-var-discount-str\">40.00%</span> discount with code <span class=\"parityvend-var-coupon-code\">example_coupon</span>. Happy shopping!', 'discount': 0.4, 'discount_str': '40.00%', 'coupon_code': 'example_coupon', 'country': Country('VE'), 'currency': {'code': 'VES', 'symbol': 'Bs.', 'localized_symbol': 'VESBs.', 'conversion_rate': 36.092756259083146}})\r\n>>> print(response.html)\r\nWe're committed to fair pricing worldwide and support <span class=\"parityvend-var-country-name\">Venezuela</span>'s purchasing power. Enjoy a <span class=\"parityvend-var-discount-str\">40.00%</span> discount with code <span class=\"parityvend-var-coupon-code\">example_coupon</span>. Happy shopping!\r\n>>> response.discount_str\r\n'40.00%'\r\n>>>\r\n```\r\n\r\n**Get your account quota information**\r\nView the full documentation for this API endpoint here: [get-quota-info](<https://www.ambeteco.com/ParityVend/docs/api_reference.html#get--backend-get-quota-info-(private_key)->)\r\n\r\n```python\r\n>>> from parityvend_api import ParityVendAPI\r\n>>> parityvend = ParityVendAPI('your_private_key')\r\n>>> response = parityvend.get_quota_info()\r\n>>> response\r\nResponse({'status': 'ok', 'quota_limit': 1000000, 'quota_used': 4716, 'quota_left': 995284})\r\n>>> response.quota_limit\r\n1000000\r\n>>> response['quota_used']\r\n4716\r\n>>>\r\n```\r\n\r\n**Get all the discounts for the current project**\r\nView the full documentation for this API endpoint here: [get-discounts-info](<https://www.ambeteco.com/ParityVend/docs/api_reference.html#get--backend-get-discounts-info-(private_key)->)\r\n\r\n```python\r\n>>> from parityvend_api import ParityVendAPI\r\n>>> parityvend = ParityVendAPI('your_private_key')\r\n>>> response = parityvend.get_discounts_info()\r\n>>> response\r\nResponse({'status': 'ok', 'discounts': Discounts({'AC': Discount(Country('AC'), '', 0.0), 'AD': Discount(Country('AD'), '', 0.0), 'AE': Discount(Country('AE'), '', 0.0), 'AF': Discount(Country('AF'), 'example_coupon', 0.7), 'AG': Discount(Country('AG'), 'example_coupon', 0.2), 'AI': Discount(Country('AI'), 'example_coupon', 0.2), 'AL': Discount(Country('AL'),  ... })}) # discounts information for all 255 countries\r\n>>>\r\n>>> response.discounts['VE'] # access individual countries with key lookups\r\nDiscount(Country('VE'), 'example_coupon', 0.4)\r\n>>> response.discounts['US']\r\nDiscount(Country('US'), '', 0.0)\r\n>>> # or via the bound method:\r\n>>> response.discounts.get_discount_by_country('CA')\r\nDiscount(Country('CA'), '', 0.0)\r\n>>>\r\n>>> # the discount object has the discount itself, as well as coupon code and country information\r\n>>> response.discounts['VE'].discount_str\r\n'40.00%'\r\n>>> response.discounts['VE'].coupon_code\r\n'example_coupon'\r\n>>> response.discounts['VE'].country\r\nCountry('VE')\r\n>>>\r\n```\r\n\r\n**Get the currency exchange rates (only for accounts with paid plans)**\r\nView the full documentation for this API endpoint here: [get-exchange-rate-info](<https://www.ambeteco.com/ParityVend/docs/api_reference.html#get--backend-get-exchange-rate-info-(private_key)-(opt.-base_currency)->)\r\n\r\n```python\r\n>>> from parityvend_api import ParityVendAPI\r\n>>> parityvend = ParityVendAPI('your_private_key')\r\n>>> response = parityvend.get_exchange_rate_info()\r\n>>> response\r\nResponse({'status': 'ok', 'rates': Response({'AED': 3.6728503704071045, 'AFN': 72.5033950805664, 'ALL': 95.3699951171875, 'AMD': 404.7422790527344, 'ANG': 1.803326964378357, 'AOA': 828.7760620117188, 'ARS': 819.7839965820312, 'AUD': 1.5208089351654053, 'AWG': 1.8025002479553223, 'AZN': 1.6963270902633667, 'BAM': 1.7974870204925537, 'BBD': 2.020319700241089, 'BDT': 109.81781005859375, 'BGN': 1.7990400791168213, 'BHD': 0.3769211173057556, 'BIF': 2859.500244140625, ... })})\r\n>>> response.rates.EUR\r\n0.9195351004600525\r\n>>> response.rates.GBP\r\n0.7895551323890686\r\n>>>\r\n>>> # you can also change the base currency\r\n>>> response_eur = parityvend.get_exchange_rate_info(base_currency='EUR')\r\n>>> response_eur.rates.USD\r\n1.0875060558319092\r\n>>> response_eur.rates.EUR\r\n1.0\r\n>>>\r\n```\r\n\r\n**Some utility functions and miscellaneous stuff:**\r\n\r\n```python\r\n>>> from parityvend_api import env_get, get_country_by_code, COUNTRIES\r\n>>>\r\n>>> COUNTRIES # a dict of country ISO codes to a pre-created 'Country' object\r\n{'AC': Country('AC'), 'AD': Country('AD'), 'AE': Country('AE'), 'AF': Country('AF'), 'AG': Country('AG'), ..., 'ZM': Country('ZM'), 'ZW': Country('ZW'), 'XX': Country('XX')}\r\n>>> COUNTRIES['GB']\r\nCountry('GB')\r\n>>> COUNTRIES['AU']\r\nCountry('AU')\r\n>>>\r\n>>>\r\n>>> get_country_by_code('CA') # get the 'Country' object from the ISO code\r\nCountry('CA')\r\n>>> country = get_country_by_code('US')\r\n>>> country.name\r\n'United States of America'\r\n>>>\r\n>>>\r\n>>> # get an environment variable if it exists, or return the default value\r\n>>> env_get('some_env_variable', 'default value')\r\n'default value'\r\n>>>\r\n```\r\n\r\n### The `base_currency` argument\r\n\r\nThe functions `get_discount_from_ip`, `get_banner_from_ip`, `get_discount_with_html_from_ip`, and `get_exchange_rate_info` all have an optional keyword argument called `base_currency`. This argument allows you to specify a base currency for calculating the exchange rate of the IP's local currency. The default value for `base_currency` is `USD`.\r\n\r\n```python\r\n>>> ...\r\n>>> # set the `base_currency` to 'EUR'. By default, it's set to 'USD'\r\n>>> response_eur = parityvend.get_discount_from_ip(ip_address, base_currency='EUR')\r\n>>> response_eur\r\nResponse({'status': 'ok', 'discount': 0.4, 'discount_str': '40.00%', 'coupon_code': 'example_coupon', 'country': Country('VE'), 'currency': Response({'code': 'VES', 'symbol': 'Bs.', 'localized_symbol': 'VESBs.', 'conversion_rate': 39.25109100341797})})\r\n>>> print(f'1 EUR is {response_eur.currency.conversion_rate} {response_eur.currency.code}')\r\n1 EUR is 39.25109100341797 VES\r\n>>>\r\n>>> response_gbp = parityvend.get_discount_from_ip(ip_address, base_currency='GBP')\r\n>>> response_gbp\r\nResponse({'status': 'ok', 'discount': 0.4, 'discount_str': '40.00%', 'coupon_code': 'example_coupon', 'country': Country('VE'), 'currency': {'code': 'VES', 'symbol': 'Bs.', 'localized_symbol': 'VESBs.', 'conversion_rate': 45.71277583460257}})\r\n>>> print(f'1 GBP is {response_gbp.currency.conversion_rate} {response_eur.currency.code}')\r\n1 GBP is 45.71277583460257 VES\r\n>>>\r\n```\r\n\r\n### Asynchronous support\r\n\r\nAn asynchronous handler, `AsyncParityVendAPI`, can be used in the same way as the synchronous handler:\r\n\r\n```python\r\nfrom parityvend_api import AsyncParityVendAPI\r\nimport asyncio\r\n\r\nasync def run():\r\n    parityvend = AsyncParityVendAPI(\"your private key\")\r\n    ip_address = \"190.206.117.0\"  # an example IP from Venezuela\r\n    country = await parityvend.get_country_from_ip(ip_address)\r\n    print(repr(country)) # will print 'Country(\"VE\")'\r\n    await parityvend.deinit()  # don't forget to close the session\r\n\r\nloop = asyncio.get_event_loop().run_until_complete(run())\r\n```\r\n\r\n### The `timeout` and `cache` Keyword Arguments\r\n\r\nEach function in the library accepts two optional keyword arguments: `timeout` and `cache`. These arguments allow you to customize the behavior of the API requests and the caching mechanism on a per-call basis.\r\n\r\n#### Using the `timeout` argument\r\n\r\nThe `timeout` argument specifies the maximum amount of time (in seconds) to wait for the API request to complete before raising a timeout error. By default, all functions in the library have `timeout=None`, which means that the operating system's default timeout value will be used.\r\n\r\nYou can override this default behavior by passing a specific value (in seconds) to the `timeout` argument. For example:\r\n\r\n```python\r\nparityvend.get_country_from_ip('8.8.8.8', timeout=5)  # set a 5-second timeout\r\n```\r\n\r\nSetting an appropriate timeout value can help prevent your application from getting stuck indefinitely waiting for a response from the API.\r\n\r\n#### Using the `cache` argument\r\n\r\nThe `cache` argument allows you to enable or disable the caching mechanism for a specific API call. All functions in the library have `cache=True` by default, which means that they will return a cached response if it's available in the cache. This behavior helps optimize your API quota usage and reduce response times.\r\n\r\nHowever, there may be situations where you want to bypass the cache and always fetch fresh data from the API. In such cases, you can set `cache=False` when calling the function.\r\n\r\nOne exception to the default behavior is the `get_quota_info` function, which has `cache=False` by default. This is because quota information is expected to change frequently, and serving stale cached data could lead to inaccurate quota calculations.\r\n\r\n```python\r\nparityvend.get_country_from_ip('8.8.8.8', cache=False)  # Bypass the cache\r\n```\r\n\r\n### The `Response` object\r\n\r\nThe functions in this library return a `Response` object that contains all fields listed in the [ParityVend API documentation](https://www.ambeteco.com/ParityVend/docs/api_reference.html#backend-primary-endpoints) for the given endpoint, along with some additional properties and functionality. You can access the response properties using dot notation or dictionary-style lookup methods. The `\"country\"` and `\"discounts\"` items in the response are automatically converted to auxiliary `Country` and `Discounts` objects, respectively. These objects provide additional methods and attributes for ease of use. For example:\r\n\r\n```python\r\n...\r\n>>> r = parityvend.get_discount_from_ip(\"190.206.117.0\")\r\n>>> r # the Response object looks like this:\r\nResponse({'status': 'ok', 'discount': 0.4, 'discount_str': '40.00%', 'coupon_code': 'example_coupon', 'country': Country('VE'), 'currency': Response({'code': 'VES', 'symbol': 'Bs.', 'localized_symbol': 'VESBs.', 'conversion_rate': 36.092756259083146})})\r\n>>> r.discount # access the data via dot notation...\r\n0.4\r\n>>> r.country.name\r\n'Venezuela'\r\n>>> r.currency.conversion_rate\r\n36.092756259083146\r\n>>> r['currency']['conversion_rate'] # ... or like a dictionary key lookup\r\n36.092756259083146\r\n>>>\r\n...\r\n>>> # All the functions return Response objects:\r\n>>> parityvend.get_discount_from_ip(\"190.206.117.0\")\r\nResponse({'status': 'ok', 'discount': 0.4, 'discount_str': '40.00%', 'coupon_code': 'example_coupon', 'country': Country('VE'), 'currency': {'code': 'VES', 'symbol': 'Bs.', 'localized_symbol': 'VESBs.', 'conversion_rate': 36.092756259083146}})\r\n>>> parityvend.get_discount_with_html_from_ip(\"190.206.117.0\")\r\nResponse({'status': 'ok', 'html': 'We\\'re committed to fair pricing worldwide and support <span class=\"parityvend-var-country-name\">Venezuela</span>\\'s purchasing power. Enjoy a <span class=\"parityvend-var-discount-str\">40.00%</span> discount with code <span class=\"parityvend-var-coupon-code\">example_coupon</span>. Happy shopping!', 'discount': 0.4, 'discount_str': '40.00%', 'coupon_code': 'example_coupon', 'country': Country('VE'), 'currency': {'code': 'VES', 'symbol': 'Bs.', 'localized_symbol': 'VESBs.', 'conversion_rate': 36.092756259083146}})\r\n>>> parityvend.get_quota_info(\"190.206.117.0\")\r\nResponse({'status': 'ok', 'quota_limit': 1000000, 'quota_used': 4188, 'quota_left': 995812})\r\n>>>\r\n```\r\n\r\n### Caching\r\n\r\nThis library provides in-memory caching of API responses by default, using the [cachetools](https://cachetools.readthedocs.io/en/latest/) library. The caching mechanism employs a Least Recently Used (LRU) cache with a Time to Live (TTL) value. This means that cached values will be kept for a specified duration, and when the cache reaches its maximum size, the least recently used entries will be automatically removed to accommodate new ones.\r\n\r\nCaching helps optimize your API quota usage and reduces response times by serving cached data instead of making redundant API requests. However, it's important to note that cached data may become stale over time, so the cache should be invalidated or refreshed as needed, depending on your application's requirements.\r\n\r\n#### Default Caching Options\r\n\r\nBy default, the following caching options are applied:\r\n\r\n- **Maximum Cache Size**: 4096 entries (using multiples of 2 for memory efficiency)\r\n- **Time to Live (TTL)**: 24 hours (86,400 seconds)\r\n\r\nThese default settings aim to provide a balance between cache performance and memory usage. However, you can modify these settings to suit your specific needs.\r\n\r\n#### Modifying Cache Options\r\n\r\nYou can customize the cache behavior by setting the `cache_options` keyword argument when initializing the handler. The `cache_options` parameter should be a dictionary, where the keys are keyword arguments accepted by the `cachetools` library. For more advanced caching options and configurations, refer to the [cachetools documentation](https://cachetools.readthedocs.io/en/latest/).\r\n\r\n```python\r\n>>> from parityvend_api import ParityVendAPI\r\n>>>\r\n>>> # the cache is enabled by default! you don't have to do anything.\r\n>>> parityvend = ParityVendAPI(\"your private key\")\r\n>>>\r\n>>> # let's measure the quota usage via the 'get_quota_info' endpoint\r\n>>> quota_used = parityvend.get_quota_info().quota_used\r\n>>>\r\n>>> # these three calls will only send one request and return the cached response\r\n>>> parityvend.get_country_from_ip(\"190.206.117.0\")\r\nCountry('VE')\r\n>>> parityvend.get_country_from_ip(\"190.206.117.0\")\r\nCountry('VE')\r\n>>> parityvend.get_country_from_ip(\"190.206.117.0\")\r\nCountry('VE')\r\n>>>\r\n>>> new_quota_used = parityvend.get_quota_info().quota_used\r\n>>> print(new_quota_used - quota_used) # this will show how much quota was used\r\n1\r\n>>> # Thanks to the cache, only 1 request was sent, even though we called the function 3 times.\r\n>>>\r\n>>> # specify the cache options like this:\r\n>>> ParityVendAPI(\r\n...     \"your private key\",\r\n...     cache_options={\r\n...         \"ttl\": 60 * 60 * 8,\r\n...         \"maxsize\": 2048,\r\n...     },\r\n... )\r\nParityVendAPI('...')\r\n>>>\r\n>>>\r\n```\r\n\r\n### Modifying Request Options\r\n\r\nThe library uses the popular `requests` (for synchronous requests) and `aiohttp` (for asynchronous requests) libraries under the hood to make API calls. You can modify the behavior of these requests by setting the `request_options` keyword argument when initializing the handler.\r\n\r\nThe `request_options` parameter should be a dictionary where the keys are keyword arguments accepted by the `requests` or `aiohttp` library, depending on whether you're using the synchronous or asynchronous handler. These options will be passed to each API request made by the handler, allowing you to customize various aspects of the requests, such as headers, timeouts, proxies, and more. For a complete list of available options and their descriptions, please refer to the documentation of the `requests` library (for synchronous handlers) or the `aiohttp` library (for asynchronous handlers).\r\n\r\n```python\r\n>>> from parityvend_api import ParityVendAPI\r\n>>>\r\n>>> parityvend = ParityVendAPI(\"your private key\", request_options={\r\n    \"headers\": {\r\n        \"User-Agent\": \"just an example\"\r\n    }\r\n})\r\n```\r\n\r\n## Contributing\r\n\r\nContributions to the ParityVend API Python Library are welcome and encouraged! We appreciate any feedback, bug reports, or feature requests that can help improve the library and make it more useful for the community.\r\n\r\nPlease refer to the [`CONTRIBUTING.md`](https://github.com/ParityVend/parityvend_api_python/blob/main/CONTRIBUTING.md) file for more detailed guidelines on how to contribute, including the environment setup, coding standards, and testing requirements.\r\n\r\n## License\r\n\r\nThe ParityVend API Python Library is released under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). This means that you are free to use, modify, and distribute this library in your commercial or non-commercial software products, as long as you comply with the terms of the license.\r\n\r\nThe Apache 2.0 License is a permissive open-source license that allows you to:\r\n\r\n- Use the library in your projects, both commercial and non-commercial.\r\n- Modify the library's source code to suit your needs.\r\n- Distribute the library or your modified versions of it.\r\n\r\nHowever, you must include a copy of the Apache 2.0 License and the copyright notice in any distribution of the library or modified versions of it.\r\n\r\n## Support\r\n\r\nIf you encounter any issues or challenges during the integration process, we recommend referring to the ParityVend documentation as your first resource. It provides comprehensive guidance to help you troubleshoot and resolve any errors you may encounter. If you require further support, our team is always ready to assist you. Feel free to [contact us](https://www.ambeteco.com/ParityVend/contact-us/) for personalized assistance to ensure a seamless integration experience, or view the [FAQ section](https://www.ambeteco.com/ParityVend/support/) on the ParityVend Support page.\r\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "The official Python library for ParityVend API",
    "version": "1.0.0",
    "project_urls": {
        "Changelog": "https://raw.githubusercontent.com/ParityVend/parityvend_api_python/main/CHANGELOG.MD",
        "Documentation": "https://www.ambeteco.com/ParityVend/docs/index.html",
        "Homepage": "https://github.com/ParityVend/parityvend_api_python/",
        "Repository": "https://github.com/ParityVend/parityvend_api_python/"
    },
    "split_keywords": [
        "parityvend",
        "purchasing power parity",
        "purchasing power",
        "location based pricing",
        "pricing optimization",
        "api library",
        "geographical pricing",
        "dynamic pricing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8e1976f645e9d6fa882cb5b4932d8f07304176f16223e9f49d39347cb94ed4db",
                "md5": "e672cbd05ca3ebb23acbc87e51de74d8",
                "sha256": "c4712c7e946384adc9541fccb78802af13f1763890abc2b8c33118f655df74f9"
            },
            "downloads": -1,
            "filename": "parityvend_api-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e672cbd05ca3ebb23acbc87e51de74d8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 30111,
            "upload_time": "2024-03-15T19:41:10",
            "upload_time_iso_8601": "2024-03-15T19:41:10.179001Z",
            "url": "https://files.pythonhosted.org/packages/8e/19/76f645e9d6fa882cb5b4932d8f07304176f16223e9f49d39347cb94ed4db/parityvend_api-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7b61232c7ddce53e4bd9944859a762ee56c7604b7ba5a6488f94d880640ac031",
                "md5": "21029ac95a7e4d27ae7e72196b811952",
                "sha256": "08853a7ee8459370c5f7f4df41797d5d8549b1ffd7fc852f8fea9649a7aa5a38"
            },
            "downloads": -1,
            "filename": "parityvend_api-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "21029ac95a7e4d27ae7e72196b811952",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 44877,
            "upload_time": "2024-03-15T19:41:12",
            "upload_time_iso_8601": "2024-03-15T19:41:12.453956Z",
            "url": "https://files.pythonhosted.org/packages/7b/61/232c7ddce53e4bd9944859a762ee56c7604b7ba5a6488f94d880640ac031/parityvend_api-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-15 19:41:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "parityvend",
    "github_project": "api_python",
    "github_not_found": true,
    "lcname": "parityvend-api"
}
        
Elapsed time: 0.22698s