Skip to main content

REST API client for Akeneo

Project description

Akeneo API Python Client

A simple Python client for the Akeneo PIM API

Installation

pip install akeneo-api-client

Usage

Initialise the client

from akeneo_api_client.client_builder import ClientBuilder
from akeneo_api_client.client.akeneo_api_error import AkeneoApiError

cb = ClientBuilder(uri)
api = cb.build_authenticated_by_password(username, password, client_id, secret)

Or if you already have a cached version of the token you can use:

api = cb.build_authenticated_by_token(client_id, secret, token, refresh_token)

Fetch a product

try:
    response = api.product_uuid_api.get(uuid)
    print(response)
except AkeneoApiError as e:
    print(e.response.status_code)
    print(e.response_body)

Iterate over a list of products

from akeneo_api_client.search.search_builder import SearchBuilder

sb = SearchBuilder()
sb.add_filter('updated', '>', '2023-11-29 00:00:00')
sb.add_filter('completeness', '=', 100, {"scope": "ecommerce"})
sb.add_filter('enabled', '=', True)
search = sb.get_filters()

try:
    for page in api.product_uuid_api.all(query_params={"search": search}):
        for item in page:
            print(item["uuid"])
except AkeneoApiError as e:
    print(e.message)

Create a product

try:
    response = api.product_uuid_api.create(data={"family":"my_family"})
    print(response.headers.get("location"))
except AkeneoApiError as e:
    print(e.response_body)

Upsert a product

This call will create a product if it doesn't exist or update it if it does

data = {
    "values": {
        "Product_name": [
            {"scope": None, "locale": "en_GB", "data": "My product"}
        ]
    }
}

try:
    api.product_uuid_api.upsert(uuid, data)
except AkeneoApiError as e:
    print(e.message)

Upsert a list of products

products = [
    {
        "uuid": str(uuid.uuid4()),
        "values": {
            "Product_name": [
                {"scope": None, "locale": "en_GB", "data": "Product 1"}
            ]
        }
    },
    {
        "values": {
            "Product_name": [
                {"scope": None, "locale": "en_GB", "data": "Product 2"}
            ]
        }
    }
]

try:
    response = api.product_uuid_api.upsert_list(products)
    for item in response:
        if item['status_code'] >= 400:
            print(item)
except AkeneoApiError as e:
    print(e.response.reason)

Delete a product

try:
    api.product_uuid_api.delete(uuid)
except AkeneoApiError as e:
    print(e.response_body)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

akeneo_api_client-1.2.1.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

akeneo_api_client-1.2.1-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file akeneo_api_client-1.2.1.tar.gz.

File metadata

  • Download URL: akeneo_api_client-1.2.1.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for akeneo_api_client-1.2.1.tar.gz
Algorithm Hash digest
SHA256 ae9a7360e7ed9ab95d4a25f7972cd3f54f86b86c8383e01de61b025dc00d80bc
MD5 03e6bd72dbac4a38729b67e2b3c7de02
BLAKE2b-256 712b6b78600dcee7f61062d60edc331e8fd2fd78988ab565a3eeb52d216f1d95

See more details on using hashes here.

File details

Details for the file akeneo_api_client-1.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for akeneo_api_client-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7f467226077e1f9a5d6c147c7f28b57e29c0bf35704bb147f8683fe864d170b
MD5 8d896867d9b053a5b662c86912490508
BLAKE2b-256 6da062c01eb92ec3fdb100c16134004890e1ef2b07b65eaaca03c548eecf7bdf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page