- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
It's my first time using Django and REST API but I would like to get a list of attribute sets from my store.
Is there a Python package or tutorial I could follow?
I'm working on connecting to the API right now
Cheers
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hii nikkawat,
We are Magento developer and feel free to ask any question anytime.
Now going through your problem I conclude that you need an API to get attribute list from Magento.
To get attribute list from Magento you need admin credentials. If you are using token-based authentication then generate a token for the admin credential as follows:
curl -X POST "http://mymagento.com/rest/V1/integration/admin/token" -H "Content-Type: application/json" -d '{"username":"<admin_user_name>","password": "<password>"}'
You will get response token like this:
xyzqstrasvbdbxhsbjanjxsbchqs
Now the URL to get list of attributes :
http://mymagento.com/rest/V1/products/attribute-sets/sets/list?searchCriteria=0 -H "Authorization: Bearer xyzqstrasvbdbxhsbjanjxsbchqs"
use "searchCriteria=0" as url paramater key.
In response you will get :
{ "items": [ { "attribute_set_id": 4, "attribute_set_name": "Default", "sort_order": 1, "entity_type_id": 4 }, { "attribute_set_id": 9, "attribute_set_name": "Top", "sort_order": 0, "entity_type_id": 4 }, { "attribute_set_id": 10, "attribute_set_name": "Bottom", "sort_order": 0, "entity_type_id": 4 }, { "attribute_set_id": 11, "attribute_set_name": "Gear", "sort_order": 0, "entity_type_id": 4 }, { "attribute_set_id": 12, "attribute_set_name": "Sprite Stasis Ball", "sort_order": 0, "entity_type_id": 4 }, { "attribute_set_id": 13, "attribute_set_name": "Sprite Yoga Strap", "sort_order": 0, "entity_type_id": 4 }, { "attribute_set_id": 14, "attribute_set_name": "Downloadable", "sort_order": 0, "entity_type_id": 4 }, { "attribute_set_id": 15, "attribute_set_name": "Bag", "sort_order": 0, "entity_type_id": 4 } ], "search_criteria": { "filter_groups": [ { "filters": [ { "field": "entity_type_code", "value": "catalog_product", "condition_type": "eq" } ] } ] }, "total_count": 8 }
Have a look on this image:
Now the python part, Truely we have no idea much about python here are some reference to make API call from python.
https://github.com/openlabs/magento
https://github.com/krukas/Mage2Gen
http://stackoverflow.com/questions/17301938/making-a-request-to-a-restful-api-using-python
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hii nikkawat,
We are Magento developer and feel free to ask any question anytime.
Now going through your problem I conclude that you need an API to get attribute list from Magento.
To get attribute list from Magento you need admin credentials. If you are using token-based authentication then generate a token for the admin credential as follows:
curl -X POST "http://mymagento.com/rest/V1/integration/admin/token" -H "Content-Type: application/json" -d '{"username":"<admin_user_name>","password": "<password>"}'
You will get response token like this:
xyzqstrasvbdbxhsbjanjxsbchqs
Now the URL to get list of attributes :
http://mymagento.com/rest/V1/products/attribute-sets/sets/list?searchCriteria=0 -H "Authorization: Bearer xyzqstrasvbdbxhsbjanjxsbchqs"
use "searchCriteria=0" as url paramater key.
In response you will get :
{ "items": [ { "attribute_set_id": 4, "attribute_set_name": "Default", "sort_order": 1, "entity_type_id": 4 }, { "attribute_set_id": 9, "attribute_set_name": "Top", "sort_order": 0, "entity_type_id": 4 }, { "attribute_set_id": 10, "attribute_set_name": "Bottom", "sort_order": 0, "entity_type_id": 4 }, { "attribute_set_id": 11, "attribute_set_name": "Gear", "sort_order": 0, "entity_type_id": 4 }, { "attribute_set_id": 12, "attribute_set_name": "Sprite Stasis Ball", "sort_order": 0, "entity_type_id": 4 }, { "attribute_set_id": 13, "attribute_set_name": "Sprite Yoga Strap", "sort_order": 0, "entity_type_id": 4 }, { "attribute_set_id": 14, "attribute_set_name": "Downloadable", "sort_order": 0, "entity_type_id": 4 }, { "attribute_set_id": 15, "attribute_set_name": "Bag", "sort_order": 0, "entity_type_id": 4 } ], "search_criteria": { "filter_groups": [ { "filters": [ { "field": "entity_type_code", "value": "catalog_product", "condition_type": "eq" } ] } ] }, "total_count": 8 }
Have a look on this image:
Now the python part, Truely we have no idea much about python here are some reference to make API call from python.
https://github.com/openlabs/magento
https://github.com/krukas/Mage2Gen
http://stackoverflow.com/questions/17301938/making-a-request-to-a-restful-api-using-python
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Magento 2 use REST API to get list of attribute sets for Django/Python app
Hi ipragmatech,
Thank you for the response! I have managed to fetch all attributes from an attribute set.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Magento 2 use REST API to get list of attribute sets for Django/Python app
I want to place an order using magento2 rest api,but...my website admin not open the option about 'po_number',so there is nothing about the parameter po_number at all,I can't see anything about po_number in my magento2 database.What should I do?