Hey, this is Anetwork Dynamicad Python client, if you want to test our REST API or want to use it as fast as possible this package is for you, with this package you can simply fetch your products, update them, delete them and finally manage your products logo. here is how we do it.
Support
- Python: ^2.7
Installation
Install anetwork dynamicad from pip
pip install anetwork_dynamicad
Usage
from Anetwork.DynamicAd import Client
You should set your API token before using the API Client:
client = Client('YOUR-GENERATED-TOKEN')
Manage products
You can manage your products in this part, you can insert, update, delete or get the products list in here.
Get
This method returns your products list and let you limit the results.
# return all products, limit them to 1000 items per request
client.product().get()
# return product with id equals to 1
client.product().id(1).get()
# return product which limited to 10 and offset 2
client.product().limit(10, 2).get()
Insert
Following Dynamicad structure you should post id
, title
, image
and url
as required fields:
data = {
'id' : 'abc',
'title' : 'this is title',
'url' : 'http://google.com',
'image' : 'http://i.telegraph.co.uk/multimedia/archive/03589/Wellcome_Image_Awa_3589699k.jpg'
}
client.product().post(data)
troubleshooting
Error | Descriptions | Solution |
---|---|---|
017 | Logo does not exist! | You should add new logo yo DynamicAd which explained in this part. |
Update
You can also update your products with id
, title
, image
and url
as required fields:
data = {
'id' : 'abc',
'title' : 'this is title',
'url' : 'http://google.com',
'image' : 'http://i.telegraph.co.uk/multimedia/archive/03589/Wellcome_Image_Awa_3589699k.jpg'
}
client.product().update(data)
Delete
And you can simply delete your product with product id
:
client.product().delete(1)
Manage logos
You can manage your products logos in this part, you can insert, update, delete or get the logos list in here.
Get
This method returns your products logos list and let you limit the results.
# return all logos, limit them to 1000 items per request
client.logo().get()
# return logo with id equals to 1
client.logo().id(1).get()
# return logos which limited to 10 and offset 2
client.logo().limit(10, 2).get()
Insert
You should post image
as required field:
data = {
'image' : 'http://i.telegraph.co.uk/multimedia/archive/03589/Wellcome_Image_Awa_3589699k.jpg',
'default' : '1'
}
client.logo().post(data)
Update
You can also update your products logo with id
as required field:
data = {
'id' : 'abc',
'default' : '1',
'image' : 'http://i.telegraph.co.uk/multimedia/archive/03589/Wellcome_Image_Awa_3589699k.jpg'
}
client.logo().update(data)
Delete
And you can simply delete your product logo with product id
:
client.logo().delete(1)