REST API client for Akeneo
Project description
Akeneo API Python Client
A simple Python client for the Akeneo PIM API
Requirements
- requests
pip install requests
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)
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
try:
for page in api.product_uuid_api.all():
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
Release history Release notifications | RSS feed
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.1.1.tar.gz
(15.0 kB
view hashes)
Built Distribution
Close
Hashes for akeneo_api_client-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49d153957328e8e474fb2ac1fa3f93d27c6ee286cb6138663ee9f7fc27cd3f69 |
|
MD5 | 246734e59e60f6b35a212eb0e2fa67cc |
|
BLAKE2b-256 | 142bd00a769ce2a931fd3063707dfa573942d12d199c51457706c121a1be8815 |