phpmagentomagento2magento-rest-api

Magento REST API using PHP


I have generated Consumer Key,Consumer Secret,Access Token & Access Token Secret. I'm not going to use OAuth. How can I integrate with PHP so that I can view products or insert product in Magento. I have latest version of Magento 2.x.

Thank You!


Solution

  • You need to create Integrations for that

    Admin => System => Extensions :: Integrations => Add New Integration

    assign Resource Access as per your needs and save

    on save the integration you will have followings

    you can use Access Token for REST API Calls in header

    Authorization : Bearer nptblbtpbh5oj2aag1sdjvvwsm******
    

    REST API Calls URL : http://yourMagento2.store/index.php/rest/

    Magento2 Rest API Reference : http://devdocs.magento.com/swagger/index.html#/

    you need to prefix all calls with the method you want to use

    for ex: Admin Token URL :

    http://yourMagento2.store/index.php/rest/V1/categories
    
    Method : GET
    

    Header

    Authorization: Bearer nptblbtpbh5oj2aag1sdjvvwsm******
    

    it will return JSON containing Category TREE