{"id":1598,"date":"2013-04-10T07:58:23","date_gmt":"2013-04-10T07:58:23","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=1598"},"modified":"2024-02-29T10:24:13","modified_gmt":"2024-02-29T10:24:13","slug":"add-own-api-function-in-magento","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/","title":{"rendered":"Add Own API Function In Magento"},"content":{"rendered":"\n<p>API function are those functions which call from another server&#8230;<\/p>\n\n\n\n<p>We know Magento provide more API &nbsp;functions here we learn how to make own API functions in magento module..<\/p>\n\n\n\n<p>For this, you just need to add some code in your module\u2019s&nbsp;<strong>YourModule\/etc\/api.xml&nbsp;<\/strong>file and add a new API functions&nbsp;<strong>YourModule\/Model\/Api.php<\/strong><\/p>\n\n\n\n<p>Here\u2019s the code:-<\/p>\n\n\n\n<p><strong>api.xml<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;config&gt;\n\t&lt;api&gt;\n\t\t&lt;resources&gt;\n\t\t\t&lt;yourmodule translate=&quot;title&quot; module=&quot;yourmodule&quot;&gt;\n\t\t\t&lt;model&gt;yourmodule\/api&lt;\/model&gt;\n\t\t\t&lt;title&gt;Customer Resource&lt;\/title&gt;\n\t\t\t&lt;acl&gt;yourmodule&lt;\/acl&gt;\n\t\t\t\t&lt;methods&gt;\n\t\t\t\t\t&lt;yourfunction1 translate=&quot;title&quot; module=&quot;yourmodule&quot;&gt; &lt;!-- this tag name by which you call your method--&gt;\n\t\t\t\t\t\t&lt;title&gt;title which you want&lt;\/title&gt;\n\t\t\t\t\t\t&lt;method&gt;yourfunction1&lt;\/method&gt;\n\t\t\t\t\t\t&lt;acl&gt;yourmodule\/yourfunction1&lt;\/acl&gt;\n\t\t\t\t\t&lt;\/yourfunction1&gt;\n\t\t\t\t\t&lt;yourfunction2 translate=&quot;title&quot; module=&quot;yourmodule&quot;&gt;\n\t\t\t\t\t\t&lt;title&gt;title which you want&lt;\/title&gt;\n\t\t\t\t\t\t&lt;method&gt;yourfunction2&lt;\/method&gt;\n\t\t\t\t\t\t&lt;acl&gt;yourmodule\/yourfunction2&lt;\/acl&gt;\n\t\t\t\t\t&lt;\/yourfunction2&gt;\t\t\t\t\t\n\t\t\t\t\t&lt;yourfunction3 translate=&quot;title&quot; module=&quot;yourmodule&quot;&gt;\n\t\t\t\t\t\t&lt;title&gt;title which you want&lt;\/title&gt;\n\t\t\t\t\t\t&lt;method&gt;yourfunction3&lt;\/method&gt;\n\t\t\t\t\t\t&lt;acl&gt;yourmodule\/yourfunction3&lt;\/acl&gt;\n\t\t\t\t\t&lt;\/yourfunction3&gt;\n\t\t\t\t\t&lt;yourfunction4 translate=&quot;title&quot; module=&quot;yourmodule&quot;&gt;\n\t\t\t\t\t\t&lt;title&gt;title which you want&lt;\/title&gt;\n\t\t\t\t\t\t&lt;method&gt;yourfunction4&lt;\/method&gt;\n\t\t\t\t\t\t&lt;acl&gt;yourmodule\/yourfunction4&lt;\/acl&gt;\n\t\t\t\t\t&lt;\/yourfunction4&gt;\n\t\t\t\t&lt;\/methods&gt;\n\t\t\t&lt;\/yourmodule&gt;\n\t\t&lt;\/resources&gt;\n\t&lt;\/api&gt;\n&lt;\/config&gt;<\/pre>\n\n\n\n<p><strong>Api.php<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n  class Yourcompany_Yourmodule_Model_Api extends Mage_Api_Model_Resource_Abstract\n    {\n\n        public function yourfunction1($data){\n\t\t\t\/\/in $data you get the values which you pass in API function\n\t\t\t\/\/do code according to your requirement\n\t\t\treturn true;\n        }\n\n       public function yourfunction2($data){\n\t\t\t\/\/in $data you get the values which you pass in API function\n\t\t\t\/\/do code according to your requirement\n\t\t\treturn $data&#091;&#039;erp_category_id&#039;];\n        }\n\n        public function yourfunction3($data){\n\t\t\t\/\/in $data you get the values which you pass in API function\n\t\t\t\/\/do code according to your requirement\n\t\t\treturn true;\n        }\n\n        public function yourfunction4($data){\n\t\t\t\/\/in $data you get the values which you pass in API function\n\t\t\t\/\/do code according to your requirement\n\t\t\treturn true;\n        }\n    }\n?&gt;<\/pre>\n\n\n\n<p>Now you call these function using<\/p>\n\n\n\n<p>1. yourmodule.yourfunction1($data);<\/p>\n\n\n\n<p>2.&nbsp;yourmodule.yourfunction2($data);<\/p>\n\n\n\n<p>3.yourmodule.yourfunction3($data);<\/p>\n\n\n\n<p>4.yourmodule.yourfunction4($data);<\/p>\n\n\n\n<p>Note:- for call these functions first you connect your server with magento using any <b>protocol<\/b>\u00a0like XML-RPC<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>&nbsp;<\/td><td><b>XML-RPC is the simplest XML-based protocol for exchanging information between computers.<\/b><\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>API function are those functions which call from another server&#8230; We know Magento provide more API &nbsp;functions here we learn how to make own API functions in magento module.. For this, you just need to add some code in your module\u2019s&nbsp;YourModule\/etc\/api.xml&nbsp;file and add a new API functions&nbsp;YourModule\/Model\/Api.php Here\u2019s the code:- api.xml Api.php Now you call <a href=\"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1598","post","type-post","status-publish","format-standard","hentry","category-magento"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Add Own API Function In Magento - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Add Own API Function In Magento - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"API function are those functions which call from another server&#8230; We know Magento provide more API &nbsp;functions here we learn how to make own API functions in magento module.. For this, you just need to add some code in your module\u2019s&nbsp;YourModule\/etc\/api.xml&nbsp;file and add a new API functions&nbsp;YourModule\/Model\/Api.php Here\u2019s the code:- api.xml Api.php Now you call [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2013-04-10T07:58:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-29T10:24:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Abhishek Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abhishek Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/\"},\"author\":{\"name\":\"Abhishek Singh\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/573e459f54796eb4195511990de4bfd0\"},\"headline\":\"Add Own API Function In Magento\",\"datePublished\":\"2013-04-10T07:58:23+00:00\",\"dateModified\":\"2024-02-29T10:24:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/\"},\"wordCount\":125,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"articleSection\":[\"magento\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/\",\"url\":\"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/\",\"name\":\"Add Own API Function In Magento - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2013-04-10T07:58:23+00:00\",\"dateModified\":\"2024-02-29T10:24:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Add Own API Function In Magento\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/573e459f54796eb4195511990de4bfd0\",\"name\":\"Abhishek Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d4ac7e0e671bf743359d7e3f140c262d1b16d71106f0a1aeaecca327a2805ae4?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d4ac7e0e671bf743359d7e3f140c262d1b16d71106f0a1aeaecca327a2805ae4?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Abhishek Singh\"},\"description\":\"Adobe Commerce certified Magento developer with over 12 years of experience at Webkul. Passionate about scalable Magento 2-based webshops, AI, and multi-channel integrations, Abhishek consistently delivers innovative and efficient e-commerce solutions that propel businesses forward.\",\"sameAs\":[\"http:\/\/webkul.com\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/abhishek\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Add Own API Function In Magento - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/","og_locale":"en_US","og_type":"article","og_title":"Add Own API Function In Magento - Webkul Blog","og_description":"API function are those functions which call from another server&#8230; We know Magento provide more API &nbsp;functions here we learn how to make own API functions in magento module.. For this, you just need to add some code in your module\u2019s&nbsp;YourModule\/etc\/api.xml&nbsp;file and add a new API functions&nbsp;YourModule\/Model\/Api.php Here\u2019s the code:- api.xml Api.php Now you call [...]","og_url":"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2013-04-10T07:58:23+00:00","article_modified_time":"2024-02-29T10:24:13+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Abhishek Singh","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Abhishek Singh","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/"},"author":{"name":"Abhishek Singh","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/573e459f54796eb4195511990de4bfd0"},"headline":"Add Own API Function In Magento","datePublished":"2013-04-10T07:58:23+00:00","dateModified":"2024-02-29T10:24:13+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/"},"wordCount":125,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"articleSection":["magento"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/","url":"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/","name":"Add Own API Function In Magento - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2013-04-10T07:58:23+00:00","dateModified":"2024-02-29T10:24:13+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/add-own-api-function-in-magento\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Add Own API Function In Magento"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/573e459f54796eb4195511990de4bfd0","name":"Abhishek Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d4ac7e0e671bf743359d7e3f140c262d1b16d71106f0a1aeaecca327a2805ae4?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d4ac7e0e671bf743359d7e3f140c262d1b16d71106f0a1aeaecca327a2805ae4?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Abhishek Singh"},"description":"Adobe Commerce certified Magento developer with over 12 years of experience at Webkul. Passionate about scalable Magento 2-based webshops, AI, and multi-channel integrations, Abhishek consistently delivers innovative and efficient e-commerce solutions that propel businesses forward.","sameAs":["http:\/\/webkul.com"],"url":"https:\/\/webkul.com\/blog\/author\/abhishek\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/1598","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=1598"}],"version-history":[{"count":9,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/1598\/revisions"}],"predecessor-version":[{"id":425353,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/1598\/revisions\/425353"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=1598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=1598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=1598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}