Metadata-Version: 2.1
Name: ikea-api
Version: 0.6.1
Summary: IKEA API Client
Home-page: https://github.com/vrslev/ikea-api-client
Author: Lev Vereshchagin
Author-email: mail@vrslev.com
License: MIT
Keywords: IKEA,IKEA API,API,API client
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Description-Content-Type: text/markdown
License-File: LICENSE

Client for several IKEA APIs.

[![License](https://img.shields.io/pypi/l/ikea_api?color=green)](https://github.com/vrslev/ikea-api-client/blob/master/LICENSE)
[![Version](https://img.shields.io/pypi/v/ikea_api?color=green&label=version)](https://pypi.org/project/ikea_api/)
[![Python Version](https://img.shields.io/pypi/pyversions/ikea_api?color=green)](https://pypi.org/project/ikea_api/)
[![Downloads](https://img.shields.io/pypi/dm/ikea_api?color=green)](https://pypi.org/project/ikea_api/)

# Features

- Authorization (as guest or as user)
- Manage Cart
- Check available Delivery Services
- Retrieve Purchases History and information about specific order
- Fetch Product information

# Installation

```bash
pip install ikea_api
```

To use authorization you need to have Chrome on board.

# Initialization

```python
from ikea_api import IkeaApi

api = IkeaApi(
    token=...,  # If you already have a token and stored it somewhere
    country_code="ru",
    language_code="ru",
)
```

# Endpoints

## [Authorization](https://github.com/vrslev/ikea-api-client/blob/master/src/ikea_api/auth.py)

### [As Guest](https://github.com/vrslev/ikea-api-client/blob/03c1add4fd03fc41a7fef41c35bd2aa9c0c36d4b/src/ikea_api/auth.py#L35-L35)

```python
api.login_as_guest()
```

First time you open IKEA.com guest token is being generated and stored in Cookies. It expires in 30 days.

### [As Registered User](https://github.com/vrslev/ikea-api-client/blob/03c1add4fd03fc41a7fef41c35bd2aa9c0c36d4b/src/ikea_api/auth.py#L56-L56)

Token lasts 1 day. It may take a while to get authorized token because of it uses headless Chrome to proceed. Note, that Chrome is required to login.

```python
api.login(username=..., password=...)
```

## [Cart](https://github.com/vrslev/ikea-api-client/blob/master/src/ikea_api/endpoints/cart/__init__.py)

This API endpoint allows you to do everything you would be able to do on the site, and even more:

- Add, Delete and Update items
- Show cart
- Clear cart
- Set and Delete Coupon
- Copy cart from another user

Works with and without authorization. If you logged in all changes apply to the _real_ cart. Use case: programmatically add items to cart and order it manually on IKEA.com.

Example:

```python
cart = api.Cart
cart.add_items({"30457903": 1})
print(cart.show())
```

## [Order Capture](https://github.com/vrslev/ikea-api-client/blob/master/src/ikea_api/endpoints/order_capture/__init__.py)

Check availability for Pickup or Delivery. This is the only way.

If you need to know whether items are available in stores, check out [ikea-availability-checker](https://github.com/Ephigenia/ikea-availability-checker).

```python
api.OrderCapture(zip_code="101000")
```

## [Purchases](https://github.com/vrslev/ikea-api-client/blob/master/src/ikea_api/endpoints/purchases/__init__.py)

### [Order History](https://github.com/vrslev/ikea-api-client/blob/fc264640ca1f27f4a58c1c57891a917414518a7d/src/ikea_api/endpoints/purchases/__init__.py#L34-L34)

```python
api.login(username=..., password=...)
history = api.Purchases.history()
```

### [Order Info](https://github.com/vrslev/ikea-api-client/blob/fc264640ca1f27f4a58c1c57891a917414518a7d/src/ikea_api/endpoints/purchases/__init__.py#L44-L44)

```python
api.login(username=..., password=...)
order = api.Purchases.order_info(order_number=...)

# Or use it without authorization, email is required
api.login_as_guest()
order = api.order_info(order_number=..., email=...)
```

## [Item Specs](https://github.com/vrslev/ikea-api-client/tree/master/src/ikea_api/endpoints/item)

Get information about item by item number

```python
item_codes = ["30457903"]

items = api.fetch_items_specs.iows(item_codes)

# or
items = api.fetch_items_specs.ingka(item_codes)

# or
item_codes_dict = {d: True for d in items}  # True — is SPR i. e. combination
items = api.fetch_items_specs.pip(item_codes_dict)
```

There are many ways because information about some items is not available in some endpoints.

# Response Examples

You can review response examples for all endpoint before using it [here](https://github.com/vrslev/ikea-api-client/tree/master/response_examples)

# Changelog

<!--next-version-placeholder-->

## v0.6.1 (2021-08-31)
### Fix
* Don't handle SIGINT, SIGTERM, SIGHUP when running pypupeteer in some cases ([`7eb142d`](https://github.com/vrslev/ikea-api-client/commit/7eb142d109f1cbb5913a24dd2d5fb07184f64347))

## v0.6.0 (2021-08-24)
### Feature
* **Auth:** Use pyppeteer for authorization ([`9c25d97`](https://github.com/vrslev/ikea-api-client/commit/9c25d9796b2ec5be7d4db28f07cea5460fa0518f))

### Fix
* **Item:** Use `staticmethod` for various item fetch types ([`2555866`](https://github.com/vrslev/ikea-api-client/commit/2555866921d707ae0d2cac747c83131094104eb6))
* **Item:** If `item_code` param is list, get unique item codes in `parse_item_code` ([`6cbbd06`](https://github.com/vrslev/ikea-api-client/commit/6cbbd06a01e1914cf225a284b6f5f8d932f04e18))

## v0.5.1 (2021-08-08)
### Fix
* GraphqlError—add "errors" attr, error message not causing TypeError ([`6258b70`](https://github.com/vrslev/ikea-api-client/commit/6258b7078aa06df379a26c334793d31666a5d412))

## v0.5.0 (2021-08-06)
### Feature
* Use Poetry as package manager ([`02d45f4`](https://github.com/vrslev/ikea-api-client/commit/02d45f47caad1050c13b513e2966c04d03cf29c8))

## v0.4.1 (2021-08-03)
### Fix
* **OrderCapture:** Add error code to exception ([`455c055`](https://github.com/vrslev/ikea-api-client/commit/455c055694c87403ee2da185d4f8430013386373))

## v0.4.0 (2021-08-03)
### Feature
* **Purchases:** Add ProductListOrder query, allow choosing queries in request, add helpful comments in `fragments` ([`90a94c6`](https://github.com/vrslev/ikea-api-client/commit/90a94c6ad90bd634df3e3277048770209157892e))

### Fix
* Show status code on JSONDecodeError ([`f70a664`](https://github.com/vrslev/ikea-api-client/commit/f70a664a50b3f2e3111fc14c2c3ef2636d8d14f1))

## v0.3.0 (2021-08-03)
### Feature
* **README:** Improve features list ([`70ac22a`](https://github.com/vrslev/ikea-api-client/commit/70ac22af6bdcdc5ce38f6c58e910c6ca188a78ed))
* Add core `IkeaApi` object for ease of usage ([`df8e94a`](https://github.com/vrslev/ikea-api-client/commit/df8e94a6faf33d9f88fea44f5bdf0b7c22d4a4a8))
* Raise if can't find cookie with token in Auth and save screenshot ([`03c1add`](https://github.com/vrslev/ikea-api-client/commit/03c1add4fd03fc41a7fef41c35bd2aa9c0c36d4b))
* Make getting guest token inherit from API class ([`29b6108`](https://github.com/vrslev/ikea-api-client/commit/29b6108b8a72c29a37b32d3018464e73a4ad732e))
* Add method choice in API.call_api ([`49c95ed`](https://github.com/vrslev/ikea-api-client/commit/49c95ed05a554389d51dcc85f32344932425ec27))
* Add `Secrets` class in which is concentrated all the "secret" data ([`4dac46d`](https://github.com/vrslev/ikea-api-client/commit/4dac46d40f40b10dada515dc1138d2d18995a4e9))
* Make `OrderCapture` class callable ([`9c8a619`](https://github.com/vrslev/ikea-api-client/commit/9c8a6191f6a460c7413b2054483beebc6b7599b5))
* Make many variables private ([`0567497`](https://github.com/vrslev/ikea-api-client/commit/05674971c82769098c6e8518b0cc64a970565f63))
* Cover code base with type hints, ([`e8d58e8`](https://github.com/vrslev/ikea-api-client/commit/e8d58e869fda8ad39cb9a0d6a4985e8c12080002))
* Update README: ([`c5e783e`](https://github.com/vrslev/ikea-api-client/commit/c5e783ee400892e9af6d95c9784a80607d63490d))

### Fix
* Semantic release build command ([`e0ef1d6`](https://github.com/vrslev/ikea-api-client/commit/e0ef1d69fb0a1352e92111cffe380410963cc26e))
* Python version in pre-commit action ([`bd23667`](https://github.com/vrslev/ikea-api-client/commit/bd23667455c58775dcb571ac1b9109bdf21384d0))
* **README:** Links to code, grammar, remove link in header `Response Examples` ([`332f455`](https://github.com/vrslev/ikea-api-client/commit/332f45582555194d1c403a15b5f57c17e3d46e3b))
* OrderCapture method ([`6284553`](https://github.com/vrslev/ikea-api-client/commit/62845534805d185aa9fef8c9ffc65e8af214afa8))
* Issues due to latest commit ([`5d6c06a`](https://github.com/vrslev/ikea-api-client/commit/5d6c06a8953c1b4528d339f7d5c8aca91b73b6aa))
* Python 3.7 support ([`924ab0e`](https://github.com/vrslev/ikea-api-client/commit/924ab0e040558d5134526e58fde0a16baea98c86))
* Install pre-commit hooks ([`fda6bdd`](https://github.com/vrslev/ikea-api-client/commit/fda6bdd5da61da45a002871008b373f810aab908))
* **Item:** Annotations, linting issues with `fetch_items_specs` ([`d80bb39`](https://github.com/vrslev/ikea-api-client/commit/d80bb3926248ed2234c4fffb42d61db473d11c5c))
* Python 3.7 support ([`d11258c`](https://github.com/vrslev/ikea-api-client/commit/d11258c1e068c2459e753221bc7e2eb101becdb5))
* Basic error handler ([`bef8498`](https://github.com/vrslev/ikea-api-client/commit/bef8498db5da2d66c89ac3b90f3387a10463efe3))


